@@ -57,7 +57,6 @@ import { requestMeasure, requestNextMutation } from '../../lib/fasterdom/fasterd
5757import {
5858 canEditMedia ,
5959 getAllowedAttachmentOptions ,
60- getPeerTitle ,
6160 getReactionKey ,
6261 getStoryKey ,
6362 isChatAdmin ,
@@ -68,6 +67,7 @@ import {
6867 isUserId ,
6968} from '../../global/helpers' ;
7069import { getChatNotifySettings } from '../../global/helpers/notifications' ;
70+ import { getPeerTitle } from '../../global/helpers/peers' ;
7171import {
7272 selectBot ,
7373 selectCanPlayAnimatedEmojis ,
@@ -288,6 +288,8 @@ type StateProps =
288288 shouldPaidMessageAutoApprove ?: boolean ;
289289 isSilentPosting ?: boolean ;
290290 isPaymentMessageConfirmDialogOpen : boolean ;
291+ starsBalance : number ;
292+ isStarsBalanceModalOpen : boolean ;
291293 } ;
292294
293295enum MainButtonState {
@@ -406,6 +408,8 @@ const Composer: FC<OwnProps & StateProps> = ({
406408 onBlur,
407409 onForward,
408410 isPaymentMessageConfirmDialogOpen,
411+ starsBalance,
412+ isStarsBalanceModalOpen,
409413} ) => {
410414 const {
411415 sendMessage,
@@ -520,8 +524,13 @@ const Composer: FC<OwnProps & StateProps> = ({
520524 canSendStickers, canSendGifs, canAttachMedia, canAttachPolls, canAttachEmbedLinks,
521525 canSendVoices, canSendPlainText, canSendAudios, canSendVideos, canSendPhotos, canSendDocuments,
522526 } = useMemo (
523- ( ) => getAllowedAttachmentOptions ( chat , chatFullInfo , isChatWithBot , isInStoryViewer ) ,
524- [ chat , chatFullInfo , isChatWithBot , isInStoryViewer ] ,
527+ ( ) => getAllowedAttachmentOptions ( chat ,
528+ chatFullInfo ,
529+ isChatWithBot ,
530+ isInStoryViewer ,
531+ paidMessagesStars ,
532+ isInScheduledList ) ,
533+ [ chat , chatFullInfo , isChatWithBot , isInStoryViewer , paidMessagesStars , isInScheduledList ] ,
525534 ) ;
526535
527536 const isNeedPremium = isContactRequirePremium && isInStoryViewer ;
@@ -541,7 +550,7 @@ const Composer: FC<OwnProps & StateProps> = ({
541550 shouldAutoApprove : shouldPaidMessageAutoApprove ,
542551 setAutoApprove : setShouldPaidMessageAutoApprove ,
543552 handleWithConfirmation : handleActionWithPaymentConfirmation ,
544- } = usePaidMessageConfirmation ( starsForAllMessages ) ;
553+ } = usePaidMessageConfirmation ( starsForAllMessages , isStarsBalanceModalOpen , starsBalance ) ;
545554
546555 const hasWebPagePreview = ! hasAttachments && canAttachEmbedLinks && ! noWebPage && Boolean ( webPagePreview ) ;
547556 const isComposerBlocked = isSendTextBlocked && ! editingMessage ;
@@ -1391,19 +1400,23 @@ const Composer: FC<OwnProps & StateProps> = ({
13911400
13921401 if ( isInScheduledList ) {
13931402 requestCalendar ( ( scheduledAt ) => {
1394- handleMessageSchedule ( { poll } , scheduledAt , currentMessageList ) ;
1403+ handleActionWithPaymentConfirmation (
1404+ handleMessageSchedule ,
1405+ { poll } ,
1406+ scheduledAt ,
1407+ currentMessageList ,
1408+ ) ;
13951409 } ) ;
13961410 closePollModal ( ) ;
13971411 } else {
1398- sendMessage ( { messageList : currentMessageList , poll, isSilent : isSilentPosting } ) ;
1412+ handleActionWithPaymentConfirmation (
1413+ sendMessage ,
1414+ { messageList : currentMessageList , poll, isSilent : isSilentPosting } ,
1415+ ) ;
13991416 closePollModal ( ) ;
14001417 }
14011418 } ) ;
14021419
1403- const handlePollSendWithPaymentConfirmation = useLastCallback ( ( poll : ApiNewPoll ) => {
1404- handleActionWithPaymentConfirmation ( handlePollSend , poll ) ;
1405- } ) ;
1406-
14071420 const sendSilent = useLastCallback ( ( additionalArgs ?: ScheduledMessageArgs ) => {
14081421 if ( isInScheduledList ) {
14091422 requestCalendar ( ( scheduledAt ) => {
@@ -1587,7 +1600,7 @@ const Composer: FC<OwnProps & StateProps> = ({
15871600 message : oldLang ( 'VoiceMessagesRestrictedByPrivacy' , chat ?. title ) ,
15881601 } ) ;
15891602 } else if ( ! canSendVoices ) {
1590- showAllowedMessageTypesNotification ( { chatId } ) ;
1603+ showAllowedMessageTypesNotification ( { chatId, messageListType } ) ;
15911604 }
15921605 } else {
15931606 setIsViewOnceEnabled ( false ) ;
@@ -1812,7 +1825,7 @@ const Composer: FC<OwnProps & StateProps> = ({
18121825 isQuiz = { pollModal . isQuiz }
18131826 shouldBeAnonymous = { isChannel }
18141827 onClear = { closePollModal }
1815- onSend = { handlePollSendWithPaymentConfirmation }
1828+ onSend = { handlePollSend }
18161829 />
18171830 < SendAsMenu
18181831 isOpen = { isSendAsMenuOpen }
@@ -1998,6 +2011,7 @@ const Composer: FC<OwnProps & StateProps> = ({
19982011 onFocus = { markInputHasFocus }
19992012 onBlur = { unmarkInputHasFocus }
20002013 isNeedPremium = { isNeedPremium }
2014+ messageListType = { messageListType }
20012015 />
20022016 { isInMessageList && (
20032017 < >
@@ -2084,6 +2098,8 @@ const Composer: FC<OwnProps & StateProps> = ({
20842098 theme = { theme }
20852099 onMenuOpen = { onAttachMenuOpen }
20862100 onMenuClose = { onAttachMenuClose }
2101+ messageListType = { messageListType }
2102+ paidMessagesStars = { paidMessagesStars }
20872103 />
20882104 ) }
20892105 { isInMessageList && Boolean ( botKeyboardMessageId ) && (
@@ -2354,6 +2370,8 @@ export default memo(withGlobal<OwnProps>(
23542370
23552371 const maxMessageLength = global . config ?. maxMessageLength || DEFAULT_MAX_MESSAGE_LENGTH ;
23562372 const isForwarding = chatId === tabState . forwardMessages . toChatId ;
2373+ const starsBalance = global . stars ?. balance . amount || 0 ;
2374+ const isStarsBalanceModalOpen = Boolean ( tabState . starsBalanceModal ) ;
23572375
23582376 return {
23592377 availableReactions : global . reactions . availableReactions ,
@@ -2436,6 +2454,8 @@ export default memo(withGlobal<OwnProps>(
24362454 shouldPaidMessageAutoApprove,
24372455 isSilentPosting,
24382456 isPaymentMessageConfirmDialogOpen : tabState . isPaymentMessageConfirmDialogOpen ,
2457+ starsBalance,
2458+ isStarsBalanceModalOpen,
24392459 } ;
24402460 } ,
24412461) ( Composer ) ) ;
0 commit comments