mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-04 10:00:55 +01:00
Improved mosaic caching
This commit is contained in:
parent
656d3b3b0c
commit
b7f10cfd04
2 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
import { Constants } from './constants';
|
||||
|
||||
export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia> => {
|
||||
export const handleMosaic = async (mediaList: TweetMedia[], userAgent: string): Promise<TweetMedia> => {
|
||||
let mosaicDomains = Constants.MOSAIC_DOMAIN_LIST;
|
||||
let selectedDomain: string | null = null;
|
||||
while (selectedDomain === null && mosaicDomains.length > 0) {
|
||||
|
@ -26,7 +26,8 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
|
|||
''
|
||||
);
|
||||
console.log('mosaicMedia', mosaicMedia);
|
||||
let constructUrl = `https://${selectedDomain}/1`;
|
||||
// TODO: use a better system for this, 0 gets png 1 gets webp, usually
|
||||
let constructUrl = `https://${selectedDomain}/${userAgent.indexOf('Telegram') > -1 ? '0' : '1'}`;
|
||||
if (mosaicMedia[0]) {
|
||||
constructUrl += `/${mosaicMedia[0]}`;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ export const handleStatus = async (
|
|||
processMedia(firstMedia);
|
||||
} else if (mediaList.length > 1) {
|
||||
console.log('Handling mosaic');
|
||||
processMedia(await handleMosaic(mediaList));
|
||||
processMedia(await handleMosaic(mediaList, userAgent || ''));
|
||||
renderedMosaic = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue