Display service notifications about errors in popup (#1585)

This commit is contained in:
Alexander Zinchuk 2021-12-21 12:16:48 +03:00
parent 219c1c462a
commit 3b433c8ae9
2 changed files with 19 additions and 10 deletions

View File

@ -339,17 +339,26 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
}, DELETE_MISSING_CHANNEL_MESSAGE_DELAY); }, DELETE_MISSING_CHANNEL_MESSAGE_DELAY);
} }
} else if (update instanceof GramJs.UpdateServiceNotification) { } else if (update instanceof GramJs.UpdateServiceNotification) {
const currentDate = Date.now() / 1000 + serverTimeOffset; if (update.popup) {
const message = buildApiMessageFromNotification(update, currentDate); onUpdate({
'@type': 'error',
error: {
message: update.message,
},
});
} else {
const currentDate = Date.now() / 1000 + serverTimeOffset;
const message = buildApiMessageFromNotification(update, currentDate);
if (isMessageWithMedia(update)) { if (isMessageWithMedia(update)) {
addMessageToLocalDb(buildMessageFromUpdate(message.id, message.chatId, update)); addMessageToLocalDb(buildMessageFromUpdate(message.id, message.chatId, update));
}
onUpdate({
'@type': 'updateServiceNotification',
message,
});
} }
onUpdate({
'@type': 'updateServiceNotification',
message,
});
} else if (( } else if ((
originRequest instanceof GramJs.messages.SendMessage originRequest instanceof GramJs.messages.SendMessage
|| originRequest instanceof GramJs.messages.SendMedia || originRequest instanceof GramJs.messages.SendMedia

View File

@ -66,7 +66,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
if (paymentShippingError) { if (paymentShippingError) {
actions.addPaymentError({ error: paymentShippingError }); actions.addPaymentError({ error: paymentShippingError });
} else if (actions.showDialog) { } else if (actions.showDialog) {
actions.showDialog({ data: { ...update.error, hasErrorKey: true } }); actions.showDialog({ data: update.error });
} }
break; break;