Fix payments in channels (#1439)

This commit is contained in:
Alexander Zinchuk 2021-09-16 11:27:05 +03:00
parent f4257d779a
commit 8192836662
2 changed files with 23 additions and 23 deletions

View File

@ -58,6 +58,8 @@ import Button from '../ui/Button';
import MobileSearch from './MobileSearch.async'; import MobileSearch from './MobileSearch.async';
import MessageSelectToolbar from './MessageSelectToolbar.async'; import MessageSelectToolbar from './MessageSelectToolbar.async';
import UnpinAllMessagesModal from '../common/UnpinAllMessagesModal.async'; import UnpinAllMessagesModal from '../common/UnpinAllMessagesModal.async';
import PaymentModal from '../payment/PaymentModal.async';
import ReceiptModal from '../payment/ReceiptModal.async';
import './MiddleColumn.scss'; import './MiddleColumn.scss';
@ -82,6 +84,8 @@ type StateProps = {
isBackgroundBlurred?: boolean; isBackgroundBlurred?: boolean;
isMobileSearchActive?: boolean; isMobileSearchActive?: boolean;
isSelectModeActive?: boolean; isSelectModeActive?: boolean;
isPaymentModalOpen?: boolean;
isReceiptModalOpen?: boolean;
animationLevel?: number; animationLevel?: number;
shouldSkipHistoryAnimations?: boolean; shouldSkipHistoryAnimations?: boolean;
currentTransitionKey: number; currentTransitionKey: number;
@ -89,7 +93,8 @@ type StateProps = {
}; };
type DispatchProps = Pick<GlobalActions, ( type DispatchProps = Pick<GlobalActions, (
'openChat' | 'unpinAllMessages' | 'loadUser' | 'closeLocalTextSearch' | 'exitMessageSelectMode' 'openChat' | 'unpinAllMessages' | 'loadUser' | 'closeLocalTextSearch' | 'exitMessageSelectMode' |
'closePaymentModal' | 'clearReceipt'
)>; )>;
const CLOSE_ANIMATION_DURATION = IS_SINGLE_COLUMN_LAYOUT ? 450 + ANIMATION_END_DELAY : undefined; const CLOSE_ANIMATION_DURATION = IS_SINGLE_COLUMN_LAYOUT ? 450 + ANIMATION_END_DELAY : undefined;
@ -119,6 +124,8 @@ const MiddleColumn: FC<StateProps & DispatchProps> = ({
isBackgroundBlurred, isBackgroundBlurred,
isMobileSearchActive, isMobileSearchActive,
isSelectModeActive, isSelectModeActive,
isPaymentModalOpen,
isReceiptModalOpen,
animationLevel, animationLevel,
shouldSkipHistoryAnimations, shouldSkipHistoryAnimations,
currentTransitionKey, currentTransitionKey,
@ -127,6 +134,8 @@ const MiddleColumn: FC<StateProps & DispatchProps> = ({
loadUser, loadUser,
closeLocalTextSearch, closeLocalTextSearch,
exitMessageSelectMode, exitMessageSelectMode,
closePaymentModal,
clearReceipt,
}) => { }) => {
const { width: windowWidth } = useWindowSize(); const { width: windowWidth } = useWindowSize();
@ -386,6 +395,14 @@ const MiddleColumn: FC<StateProps & DispatchProps> = ({
isActive={isSelectModeActive} isActive={isSelectModeActive}
canPost={renderingCanPost} canPost={renderingCanPost}
/> />
<PaymentModal
isOpen={Boolean(isPaymentModalOpen)}
onClose={closePaymentModal}
/>
<ReceiptModal
isOpen={Boolean(isReceiptModalOpen)}
onClose={clearReceipt}
/>
</div> </div>
</> </>
)} )}
@ -434,6 +451,8 @@ export default memo(withGlobal(
isBackgroundBlurred, isBackgroundBlurred,
isMobileSearchActive: Boolean(IS_SINGLE_COLUMN_LAYOUT && selectCurrentTextSearch(global)), isMobileSearchActive: Boolean(IS_SINGLE_COLUMN_LAYOUT && selectCurrentTextSearch(global)),
isSelectModeActive: selectIsInSelectMode(global), isSelectModeActive: selectIsInSelectMode(global),
isPaymentModalOpen: global.payment.isPaymentModalOpen,
isReceiptModalOpen: Boolean(global.payment.receipt),
animationLevel: global.settings.byKey.animationLevel, animationLevel: global.settings.byKey.animationLevel,
currentTransitionKey: Math.max(0, global.messages.messageLists.length - 1), currentTransitionKey: Math.max(0, global.messages.messageLists.length - 1),
}; };
@ -475,5 +494,6 @@ export default memo(withGlobal(
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [
'openChat', 'unpinAllMessages', 'loadUser', 'closeLocalTextSearch', 'exitMessageSelectMode', 'openChat', 'unpinAllMessages', 'loadUser', 'closeLocalTextSearch', 'exitMessageSelectMode',
'closePaymentModal', 'clearReceipt',
]), ]),
)(MiddleColumn)); )(MiddleColumn));

View File

@ -94,8 +94,6 @@ import DropArea, { DropAreaState } from './DropArea.async';
import WebPagePreview from './WebPagePreview'; import WebPagePreview from './WebPagePreview';
import Portal from '../../ui/Portal'; import Portal from '../../ui/Portal';
import CalendarModal from '../../common/CalendarModal.async'; import CalendarModal from '../../common/CalendarModal.async';
import PaymentModal from '../../payment/PaymentModal.async';
import ReceiptModal from '../../payment/ReceiptModal.async';
import './Composer.scss'; import './Composer.scss';
@ -118,8 +116,6 @@ type StateProps = {
isSelectModeActive?: boolean; isSelectModeActive?: boolean;
isForwarding?: boolean; isForwarding?: boolean;
isPollModalOpen?: boolean; isPollModalOpen?: boolean;
isPaymentModalOpen?: boolean;
isReceiptModalOpen?: boolean;
botKeyboardMessageId?: number; botKeyboardMessageId?: number;
botKeyboardPlaceholder?: string; botKeyboardPlaceholder?: string;
withScheduledButton?: boolean; withScheduledButton?: boolean;
@ -146,8 +142,8 @@ type StateProps = {
type DispatchProps = Pick<GlobalActions, ( type DispatchProps = Pick<GlobalActions, (
'sendMessage' | 'editMessage' | 'saveDraft' | 'forwardMessages' | 'sendMessage' | 'editMessage' | 'saveDraft' | 'forwardMessages' |
'clearDraft' | 'showDialog' | 'setStickerSearchQuery' | 'setGifSearchQuery' | 'clearDraft' | 'showDialog' | 'setStickerSearchQuery' | 'setGifSearchQuery' |
'openPollModal' | 'closePollModal' | 'loadScheduledHistory' | 'openChat' | 'closePaymentModal' | 'openPollModal' | 'closePollModal' | 'loadScheduledHistory' | 'openChat' |
'clearReceipt' | 'addRecentEmoji' | 'sendInlineBotResult' 'addRecentEmoji' | 'sendInlineBotResult'
)>; )>;
enum MainButtonState { enum MainButtonState {
@ -187,8 +183,6 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
isSelectModeActive, isSelectModeActive,
isForwarding, isForwarding,
isPollModalOpen, isPollModalOpen,
isPaymentModalOpen,
isReceiptModalOpen,
botKeyboardMessageId, botKeyboardMessageId,
botKeyboardPlaceholder, botKeyboardPlaceholder,
withScheduledButton, withScheduledButton,
@ -219,9 +213,7 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
openPollModal, openPollModal,
closePollModal, closePollModal,
loadScheduledHistory, loadScheduledHistory,
closePaymentModal,
openChat, openChat,
clearReceipt,
addRecentEmoji, addRecentEmoji,
sendInlineBotResult, sendInlineBotResult,
}) => { }) => {
@ -820,14 +812,6 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
onClear={closePollModal} onClear={closePollModal}
onSend={handlePollSend} onSend={handlePollSend}
/> />
<PaymentModal
isOpen={Boolean(isPaymentModalOpen)}
onClose={closePaymentModal}
/>
<ReceiptModal
isOpen={Boolean(isReceiptModalOpen)}
onClose={clearReceipt}
/>
{renderedEditedMessage && ( {renderedEditedMessage && (
<DeleteMessageModal <DeleteMessageModal
isOpen={isDeleteModalOpen} isOpen={isDeleteModalOpen}
@ -1111,8 +1095,6 @@ export default memo(withGlobal<OwnProps>(
usersById: global.users.byId, usersById: global.users.byId,
lastSyncTime: global.lastSyncTime, lastSyncTime: global.lastSyncTime,
contentToBeScheduled: global.messages.contentToBeScheduled, contentToBeScheduled: global.messages.contentToBeScheduled,
isPaymentModalOpen: global.payment.isPaymentModalOpen,
isReceiptModalOpen: Boolean(global.payment.receipt),
shouldSuggestStickers: global.settings.byKey.shouldSuggestStickers, shouldSuggestStickers: global.settings.byKey.shouldSuggestStickers,
recentEmojis: global.recentEmojis, recentEmojis: global.recentEmojis,
baseEmojiKeywords: baseEmojiKeywords?.keywords, baseEmojiKeywords: baseEmojiKeywords?.keywords,
@ -1135,8 +1117,6 @@ export default memo(withGlobal<OwnProps>(
'forwardMessages', 'forwardMessages',
'openPollModal', 'openPollModal',
'closePollModal', 'closePollModal',
'closePaymentModal',
'clearReceipt',
'loadScheduledHistory', 'loadScheduledHistory',
'openChat', 'openChat',
'addRecentEmoji', 'addRecentEmoji',