diff --git a/src/api/gramjs/methods/symbols.ts b/src/api/gramjs/methods/symbols.ts index 1f8f48882..2d47beaae 100644 --- a/src/api/gramjs/methods/symbols.ts +++ b/src/api/gramjs/methods/symbols.ts @@ -163,7 +163,7 @@ export async function fetchStickers( stickerset: 'id' in stickerSetInfo ? buildInputStickerSet(stickerSetInfo.id, stickerSetInfo.accessHash) : buildInputStickerSetShortName(stickerSetInfo.shortName), - })); + }), undefined, true); if (!(result instanceof GramJs.messages.StickerSet)) { return undefined; diff --git a/src/global/actions/api/symbols.ts b/src/global/actions/api/symbols.ts index 57c10420c..b9e6709d5 100644 --- a/src/global/actions/api/symbols.ts +++ b/src/global/actions/api/symbols.ts @@ -5,9 +5,11 @@ import { } from '../../index'; import type { ActionReturnType, GlobalState, TabArgs } from '../../types'; -import type { ApiStickerSetInfo } from '../../../api/types'; +import type { + ApiError, ApiSticker, ApiStickerSet, ApiStickerSetInfo, +} from '../../../api/types'; import { callApi } from '../../../api/gramjs'; -import { onTickEnd, pause, throttle } from '../../../util/schedulers'; +import { pause, throttle } from '../../../util/schedulers'; import { updateStickerSets, updateStickerSet, @@ -537,27 +539,33 @@ async function loadStickers( stickerSetInfo: ApiStickerSetInfo, ...[tabId = getCurrentTabId()]: TabArgs ) { - const stickerSet = await callApi( - 'fetchStickers', - { stickerSetInfo }, - ); - global = getGlobal(); - - if (!stickerSet) { - onTickEnd(() => { + let stickerSet: { set: ApiStickerSet; stickers: ApiSticker[]; packs: Record } | undefined; + try { + stickerSet = await callApi( + 'fetchStickers', + { stickerSetInfo }, + ); + } catch (error) { + if ((error as ApiError).message === 'STICKERSET_INVALID') { actions.showNotification({ message: translate('StickerPack.ErrorNotFound'), tabId, }); - }); - if ('shortName' in stickerSetInfo - && selectTabState(global, tabId).openedStickerSetShortName === stickerSetInfo.shortName) { - global = updateTabState(global, { - openedStickerSetShortName: undefined, - }, tabId); - setGlobal(global); + if ('shortName' in stickerSetInfo + && selectTabState(global, tabId).openedStickerSetShortName === stickerSetInfo.shortName) { + global = updateTabState(global, { + openedStickerSetShortName: undefined, + }, tabId); + setGlobal(global); + } + return; } + } + global = getGlobal(); + + if (!stickerSet) { + // TODO handle this case when sticker cache is implemented return; } @@ -729,10 +737,6 @@ addActionHandler('openStickerSet', async (global, actions, payload): Promise