|
|
@ -46,7 +46,8 @@ export class AppStickersManager { |
|
|
|
id: string, |
|
|
|
id: string, |
|
|
|
access_hash: string |
|
|
|
access_hash: string |
|
|
|
}, params: Partial<{ |
|
|
|
}, params: Partial<{ |
|
|
|
overwrite: boolean |
|
|
|
overwrite: boolean, |
|
|
|
|
|
|
|
useCache: boolean |
|
|
|
}> = {}): Promise<MessagesStickerSet> { |
|
|
|
}> = {}): Promise<MessagesStickerSet> { |
|
|
|
if(this.getStickerSetPromises[set.id]) { |
|
|
|
if(this.getStickerSetPromises[set.id]) { |
|
|
|
return this.getStickerSetPromises[set.id]; |
|
|
|
return this.getStickerSetPromises[set.id]; |
|
|
@ -55,7 +56,7 @@ export class AppStickersManager { |
|
|
|
return this.getStickerSetPromises[set.id] = new Promise(async(resolve) => { |
|
|
|
return this.getStickerSetPromises[set.id] = new Promise(async(resolve) => { |
|
|
|
if(!params.overwrite) { |
|
|
|
if(!params.overwrite) { |
|
|
|
const cachedSet = await this.storage.get(set.id); |
|
|
|
const cachedSet = await this.storage.get(set.id); |
|
|
|
if(cachedSet && cachedSet.documents?.length && (Date.now() - cachedSet.refreshTime) < CACHE_TIME) { |
|
|
|
if(cachedSet && cachedSet.documents?.length && ((Date.now() - cachedSet.refreshTime) < CACHE_TIME || params.useCache)) { |
|
|
|
this.saveStickers(cachedSet.documents); |
|
|
|
this.saveStickers(cachedSet.documents); |
|
|
|
resolve(cachedSet); |
|
|
|
resolve(cachedSet); |
|
|
|
delete this.getStickerSetPromises[set.id]; |
|
|
|
delete this.getStickerSetPromises[set.id]; |
|
|
@ -236,7 +237,7 @@ export class AppStickersManager { |
|
|
|
|
|
|
|
|
|
|
|
public preloadStickerSets() { |
|
|
|
public preloadStickerSets() { |
|
|
|
return this.getAllStickers().then(allStickers => { |
|
|
|
return this.getAllStickers().then(allStickers => { |
|
|
|
return Promise.all((allStickers as MessagesAllStickers.messagesAllStickers).sets.map(set => this.getStickerSet(set))); |
|
|
|
return Promise.all((allStickers as MessagesAllStickers.messagesAllStickers).sets.map(set => this.getStickerSet(set, {useCache: true}))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|