From 3b433c8ae945816947194d7123bf92162c777538 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 21 Dec 2021 12:16:48 +0300 Subject: [PATCH] Display service notifications about errors in popup (#1585) --- src/api/gramjs/updater.ts | 27 ++++++++++++++-------- src/modules/actions/apiUpdaters/initial.ts | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/api/gramjs/updater.ts b/src/api/gramjs/updater.ts index 38bbd1016..e13b85d6c 100644 --- a/src/api/gramjs/updater.ts +++ b/src/api/gramjs/updater.ts @@ -339,17 +339,26 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) { }, DELETE_MISSING_CHANNEL_MESSAGE_DELAY); } } else if (update instanceof GramJs.UpdateServiceNotification) { - const currentDate = Date.now() / 1000 + serverTimeOffset; - const message = buildApiMessageFromNotification(update, currentDate); + if (update.popup) { + onUpdate({ + '@type': 'error', + error: { + message: update.message, + }, + }); + } else { + const currentDate = Date.now() / 1000 + serverTimeOffset; + const message = buildApiMessageFromNotification(update, currentDate); - if (isMessageWithMedia(update)) { - addMessageToLocalDb(buildMessageFromUpdate(message.id, message.chatId, update)); + if (isMessageWithMedia(update)) { + addMessageToLocalDb(buildMessageFromUpdate(message.id, message.chatId, update)); + } + + onUpdate({ + '@type': 'updateServiceNotification', + message, + }); } - - onUpdate({ - '@type': 'updateServiceNotification', - message, - }); } else if (( originRequest instanceof GramJs.messages.SendMessage || originRequest instanceof GramJs.messages.SendMedia diff --git a/src/modules/actions/apiUpdaters/initial.ts b/src/modules/actions/apiUpdaters/initial.ts index ac86fc6fd..d87794b62 100644 --- a/src/modules/actions/apiUpdaters/initial.ts +++ b/src/modules/actions/apiUpdaters/initial.ts @@ -66,7 +66,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => { if (paymentShippingError) { actions.addPaymentError({ error: paymentShippingError }); } else if (actions.showDialog) { - actions.showDialog({ data: { ...update.error, hasErrorKey: true } }); + actions.showDialog({ data: update.error }); } break;