Fix displaying payment toast on failure
This commit is contained in:
parent
4daa3dd321
commit
90f630a0cd
@ -136,17 +136,6 @@ export default class PopupPayment extends PopupElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.hide();
|
this.hide();
|
||||||
showSuccessToast();
|
|
||||||
};
|
|
||||||
|
|
||||||
const showSuccessToast = () => {
|
|
||||||
toastNew({
|
|
||||||
langPackKey: 'PaymentInfoHint',
|
|
||||||
langPackArguments: [
|
|
||||||
paymentsWrapCurrencyAmount(getTotalTotal(), currency),
|
|
||||||
wrapEmojiText(mediaInvoice.title)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.listenerSetter.add(rootScope)('payment_sent', ({peerId, mid}) => {
|
this.listenerSetter.add(rootScope)('payment_sent', ({peerId, mid}) => {
|
||||||
|
@ -24,8 +24,7 @@ import { MOUNT_CLASS_TO } from '../../config/debug';
|
|||||||
import appNavigationController from '../../components/appNavigationController';
|
import appNavigationController from '../../components/appNavigationController';
|
||||||
import AppPrivateSearchTab from '../../components/sidebarRight/tabs/search';
|
import AppPrivateSearchTab from '../../components/sidebarRight/tabs/search';
|
||||||
import I18n, { i18n, join, LangPackKey } from '../langPack';
|
import I18n, { i18n, join, LangPackKey } from '../langPack';
|
||||||
import { ChatFull, ChatInvite, ChatParticipant, ChatParticipants, SendMessageAction } from '../../layer';
|
import { ChatFull, ChatInvite, ChatParticipants, Message, MessageAction, MessageMedia, SendMessageAction } from '../../layer';
|
||||||
import { hslaStringToHex } from '../../helpers/color';
|
|
||||||
import PeerTitle from '../../components/peerTitle';
|
import PeerTitle from '../../components/peerTitle';
|
||||||
import PopupPeer from '../../components/popups/peer';
|
import PopupPeer from '../../components/popups/peer';
|
||||||
import blurActiveElement from '../../helpers/dom/blurActiveElement';
|
import blurActiveElement from '../../helpers/dom/blurActiveElement';
|
||||||
@ -87,8 +86,8 @@ import groupCallsController from '../calls/groupCallsController';
|
|||||||
import callsController from '../calls/callsController';
|
import callsController from '../calls/callsController';
|
||||||
import getFilesFromEvent from '../../helpers/files/getFilesFromEvent';
|
import getFilesFromEvent from '../../helpers/files/getFilesFromEvent';
|
||||||
import apiManagerProxy from '../mtproto/mtprotoworker';
|
import apiManagerProxy from '../mtproto/mtprotoworker';
|
||||||
import wrapPeerTitle from '../../components/wrappers/peerTitle';
|
|
||||||
import appRuntimeManager from './appRuntimeManager';
|
import appRuntimeManager from './appRuntimeManager';
|
||||||
|
import paymentsWrapCurrencyAmount from '../../helpers/paymentsWrapCurrencyAmount';
|
||||||
|
|
||||||
export const CHAT_ANIMATION_GROUP = 'chat';
|
export const CHAT_ANIMATION_GROUP = 'chat';
|
||||||
|
|
||||||
@ -343,6 +342,22 @@ export class AppImManager extends EventListenerBase<{
|
|||||||
description: wrapRichText(update.message)
|
description: wrapRichText(update.message)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rootScope.addEventListener('payment_sent', async({peerId, mid, receiptMessage}) => {
|
||||||
|
const message = await this.managers.appMessagesManager.getMessageByPeer(peerId, mid);
|
||||||
|
if(!message) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const action = receiptMessage.action as MessageAction.messageActionPaymentSent;
|
||||||
|
toastNew({
|
||||||
|
langPackKey: 'PaymentInfoHint',
|
||||||
|
langPackArguments: [
|
||||||
|
paymentsWrapCurrencyAmount(action.total_amount, action.currency),
|
||||||
|
wrapEmojiText(((message as Message.message).media as MessageMedia.messageMediaInvoice).title)
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
apiManagerProxy.addEventListener('notificationBuild', (options) => {
|
apiManagerProxy.addEventListener('notificationBuild', (options) => {
|
||||||
if(this.chat.peerId === options.message.peerId && !idleController.isIdle) {
|
if(this.chat.peerId === options.message.peerId && !idleController.isIdle) {
|
||||||
|
@ -4030,7 +4030,8 @@ export class AppMessagesManager extends AppManager {
|
|||||||
if(message._ === 'messageService' && message.action._ === 'messageActionPaymentSent') {
|
if(message._ === 'messageService' && message.action._ === 'messageActionPaymentSent') {
|
||||||
this.rootScope.dispatchEvent('payment_sent', {
|
this.rootScope.dispatchEvent('payment_sent', {
|
||||||
peerId: message.reply_to.reply_to_peer_id ? getPeerId(message.reply_to.reply_to_peer_id) : message.peerId,
|
peerId: message.reply_to.reply_to_peer_id ? getPeerId(message.reply_to.reply_to_peer_id) : message.peerId,
|
||||||
mid: message.reply_to_mid
|
mid: message.reply_to_mid,
|
||||||
|
receiptMessage: message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ export type BroadcastEvents = {
|
|||||||
|
|
||||||
'logging_out': void,
|
'logging_out': void,
|
||||||
|
|
||||||
'payment_sent': {peerId: PeerId, mid: number}
|
'payment_sent': {peerId: PeerId, mid: number, receiptMessage: Message.messageService}
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BroadcastEventsListeners = {
|
export type BroadcastEventsListeners = {
|
||||||
|
Loading…
Reference in New Issue
Block a user