Mini Apps: Fix modal freeze when opening mini app via button (#4994)

This commit is contained in:
Alexander Zinchuk 2024-09-24 14:48:47 +02:00
parent 10629eb69a
commit 8f9731a5cf
3 changed files with 7 additions and 2 deletions

View File

@ -670,7 +670,7 @@ addActionHandler('loadPreviewMedias', async (global, actions, payload): Promise<
addActionHandler('requestAppWebView', async (global, actions, payload): Promise<void> => { addActionHandler('requestAppWebView', async (global, actions, payload): Promise<void> => {
const { const {
botId, appName, startApp, theme, isWriteAllowed, isFromConfirm, botId, appName, startApp, theme, isWriteAllowed, isFromConfirm, shouldSkipBotTrustRequest,
tabId = getCurrentTabId(), tabId = getCurrentTabId(),
} = payload; } = payload;
@ -719,7 +719,10 @@ addActionHandler('requestAppWebView', async (global, actions, payload): Promise<
return; return;
} }
if (botApp.isInactive || !selectIsTrustedBot(global, botId)) { const shouldRequestBotTrust = !shouldSkipBotTrustRequest && (botApp.isInactive || !selectIsTrustedBot(global, botId));
if (shouldRequestBotTrust) {
payload.shouldSkipBotTrustRequest = true;
global = updateTabState(global, { global = updateTabState(global, {
botTrustRequest: { botTrustRequest: {
botId, botId,

View File

@ -2891,6 +2891,7 @@ export async function checkWebAppExists<T extends GlobalState>(
if (!botName || !appName) return false; if (!botName || !appName) return false;
global = getGlobal(); global = getGlobal();
const chatByUsername = await fetchChatByUsername(global, botName); const chatByUsername = await fetchChatByUsername(global, botName);
global = getGlobal();
const bot = chatByUsername && selectUser(global, chatByUsername.id); const bot = chatByUsername && selectUser(global, chatByUsername.id);
const botApp = bot && await callApi('fetchBotApp', { const botApp = bot && await callApi('fetchBotApp', {
bot, bot,

View File

@ -2961,6 +2961,7 @@ export interface ActionPayloads {
startApp?: string; startApp?: string;
isWriteAllowed?: boolean; isWriteAllowed?: boolean;
isFromConfirm?: boolean; isFromConfirm?: boolean;
shouldSkipBotTrustRequest?: boolean;
} & WithTabId; } & WithTabId;
loadPreviewMedias: { loadPreviewMedias: {
botId: string; botId: string;