From cefdb6302fc6b9759f6d5f178e0e0b67d1f5fceb Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Sat, 19 Jun 2021 03:07:12 +0300 Subject: [PATCH] Use cached stickersets for stickers helper --- src/lib/appManagers/appStickersManager.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/appManagers/appStickersManager.ts b/src/lib/appManagers/appStickersManager.ts index a2bcf81b..d91873e6 100644 --- a/src/lib/appManagers/appStickersManager.ts +++ b/src/lib/appManagers/appStickersManager.ts @@ -46,7 +46,8 @@ export class AppStickersManager { id: string, access_hash: string }, params: Partial<{ - overwrite: boolean + overwrite: boolean, + useCache: boolean }> = {}): Promise { if(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) => { if(!params.overwrite) { 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); resolve(cachedSet); delete this.getStickerSetPromises[set.id]; @@ -236,7 +237,7 @@ export class AppStickersManager { public preloadStickerSets() { 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}))); }); }