Stickers: Fix popup after failed load (#2498)
This commit is contained in:
parent
49a977360c
commit
d000a80d35
@ -163,7 +163,7 @@ export async function fetchStickers(
|
|||||||
stickerset: 'id' in stickerSetInfo
|
stickerset: 'id' in stickerSetInfo
|
||||||
? buildInputStickerSet(stickerSetInfo.id, stickerSetInfo.accessHash)
|
? buildInputStickerSet(stickerSetInfo.id, stickerSetInfo.accessHash)
|
||||||
: buildInputStickerSetShortName(stickerSetInfo.shortName),
|
: buildInputStickerSetShortName(stickerSetInfo.shortName),
|
||||||
}));
|
}), undefined, true);
|
||||||
|
|
||||||
if (!(result instanceof GramJs.messages.StickerSet)) {
|
if (!(result instanceof GramJs.messages.StickerSet)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@ -5,9 +5,11 @@ import {
|
|||||||
} from '../../index';
|
} from '../../index';
|
||||||
|
|
||||||
import type { ActionReturnType, GlobalState, TabArgs } from '../../types';
|
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 { callApi } from '../../../api/gramjs';
|
||||||
import { onTickEnd, pause, throttle } from '../../../util/schedulers';
|
import { pause, throttle } from '../../../util/schedulers';
|
||||||
import {
|
import {
|
||||||
updateStickerSets,
|
updateStickerSets,
|
||||||
updateStickerSet,
|
updateStickerSet,
|
||||||
@ -537,27 +539,33 @@ async function loadStickers<T extends GlobalState>(
|
|||||||
stickerSetInfo: ApiStickerSetInfo,
|
stickerSetInfo: ApiStickerSetInfo,
|
||||||
...[tabId = getCurrentTabId()]: TabArgs<T>
|
...[tabId = getCurrentTabId()]: TabArgs<T>
|
||||||
) {
|
) {
|
||||||
const stickerSet = await callApi(
|
let stickerSet: { set: ApiStickerSet; stickers: ApiSticker[]; packs: Record<string, ApiSticker[]> } | undefined;
|
||||||
'fetchStickers',
|
try {
|
||||||
{ stickerSetInfo },
|
stickerSet = await callApi(
|
||||||
);
|
'fetchStickers',
|
||||||
global = getGlobal();
|
{ stickerSetInfo },
|
||||||
|
);
|
||||||
if (!stickerSet) {
|
} catch (error) {
|
||||||
onTickEnd(() => {
|
if ((error as ApiError).message === 'STICKERSET_INVALID') {
|
||||||
actions.showNotification({
|
actions.showNotification({
|
||||||
message: translate('StickerPack.ErrorNotFound'),
|
message: translate('StickerPack.ErrorNotFound'),
|
||||||
tabId,
|
tabId,
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if ('shortName' in stickerSetInfo
|
if ('shortName' in stickerSetInfo
|
||||||
&& selectTabState(global, tabId).openedStickerSetShortName === stickerSetInfo.shortName) {
|
&& selectTabState(global, tabId).openedStickerSetShortName === stickerSetInfo.shortName) {
|
||||||
global = updateTabState(global, {
|
global = updateTabState(global, {
|
||||||
openedStickerSetShortName: undefined,
|
openedStickerSetShortName: undefined,
|
||||||
}, tabId);
|
}, tabId);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
global = getGlobal();
|
||||||
|
|
||||||
|
if (!stickerSet) {
|
||||||
|
// TODO handle this case when sticker cache is implemented
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,10 +737,6 @@ addActionHandler('openStickerSet', async (global, actions, payload): Promise<voi
|
|||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
const set = selectStickerSet(global, stickerSetInfo);
|
const set = selectStickerSet(global, stickerSetInfo);
|
||||||
if (!set?.shortName) {
|
if (!set?.shortName) {
|
||||||
actions.showNotification({
|
|
||||||
message: translate('StickerPack.ErrorNotFound'),
|
|
||||||
tabId,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user