Mini Apps: Allow forcing sticker set refresh (#5175)

This commit is contained in:
zubiden 2024-11-27 20:33:22 +04:00 committed by Alexander Zinchuk
parent 1e822ea234
commit 110c59a231
5 changed files with 12 additions and 5 deletions

View File

@ -382,9 +382,9 @@ const WebAppModalTabContent: FC<OwnProps & StateProps> = ({
function handleEvent(event: WebAppInboundEvent) { function handleEvent(event: WebAppInboundEvent) {
const { eventType, eventData } = event; const { eventType, eventData } = event;
if (eventType === 'web_app_open_tg_link' && !isPaymentModalOpen) { if (eventType === 'web_app_open_tg_link') {
const linkUrl = TME_LINK_PREFIX + eventData.path_full; const linkUrl = TME_LINK_PREFIX + eventData.path_full;
openTelegramLink({ url: linkUrl }); openTelegramLink({ url: linkUrl, shouldIgnoreCache: eventData.force_request });
closeActiveWebApp(); closeActiveWebApp();
} }

View File

@ -1270,6 +1270,7 @@ addActionHandler('openChatByPhoneNumber', async (global, actions, payload): Prom
addActionHandler('openTelegramLink', async (global, actions, payload): Promise<void> => { addActionHandler('openTelegramLink', async (global, actions, payload): Promise<void> => {
const { const {
url, url,
shouldIgnoreCache,
tabId = getCurrentTabId(), tabId = getCurrentTabId(),
} = payload; } = payload;
@ -1357,6 +1358,7 @@ addActionHandler('openTelegramLink', async (global, actions, payload): Promise<v
stickerSetInfo: { stickerSetInfo: {
shortName: part2, shortName: part2,
}, },
shouldIgnoreCache,
tabId, tabId,
}); });
return; return;

View File

@ -764,8 +764,8 @@ addActionHandler('loadFeaturedEmojiStickers', async (global): Promise<void> => {
}); });
addActionHandler('openStickerSet', async (global, actions, payload): Promise<void> => { addActionHandler('openStickerSet', async (global, actions, payload): Promise<void> => {
const { stickerSetInfo, tabId = getCurrentTabId() } = payload; const { stickerSetInfo, shouldIgnoreCache, tabId = getCurrentTabId() } = payload;
if (!selectStickerSet(global, stickerSetInfo)) { if (shouldIgnoreCache || !selectStickerSet(global, stickerSetInfo)) {
await loadStickers(global, actions, stickerSetInfo); await loadStickers(global, actions, stickerSetInfo);
} }

View File

@ -1813,6 +1813,7 @@ export interface ActionPayloads {
}; };
openTelegramLink: { openTelegramLink: {
url: string; url: string;
shouldIgnoreCache?: boolean;
} & WithTabId; } & WithTabId;
resolveBusinessChatLink: { resolveBusinessChatLink: {
slug: string; slug: string;
@ -2997,7 +2998,10 @@ export interface ActionPayloads {
stickerSet: ApiStickerSet; stickerSet: ApiStickerSet;
}; };
openStickerSet: { stickerSetInfo: ApiStickerSetInfo } & WithTabId; openStickerSet: {
stickerSetInfo: ApiStickerSetInfo;
shouldIgnoreCache?: boolean;
} & WithTabId;
closeStickerSetModal: WithTabId | undefined; closeStickerSetModal: WithTabId | undefined;
loadStickersForEmoji: { loadStickersForEmoji: {

View File

@ -47,6 +47,7 @@ export type WebAppInboundEvent =
}> | }> |
WebAppEvent<'web_app_open_tg_link', { WebAppEvent<'web_app_open_tg_link', {
path_full: string; path_full: string;
force_request?: boolean;
}> | }> |
WebAppEvent<'web_app_open_invoice', { WebAppEvent<'web_app_open_invoice', {
slug: string; slug: string;