From 8b1358dd8b67b8d4599203d8c3f77d7f020505b4 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Fri, 19 Sep 2025 14:35:16 +0200 Subject: [PATCH] TeactN: Force full state return in `withGlobal` (#6240) --- CLAUDE.md | 3 ++- src/@types/global.d.ts | 4 ++++ src/components/App.tsx | 2 +- src/components/auth/Auth.tsx | 2 +- src/components/auth/AuthCode.tsx | 4 +++- src/components/auth/AuthPassword.tsx | 4 +++- src/components/auth/AuthPhoneNumber.tsx | 4 ++-- src/components/auth/AuthQrCode.tsx | 2 +- src/components/auth/AuthRegister.tsx | 4 +++- src/components/auth/CountryCodeInput.tsx | 2 +- src/components/calls/ActiveCallHeader.tsx | 2 +- src/components/calls/group/GroupCall.tsx | 2 +- .../calls/group/GroupCallParticipant.tsx | 2 +- .../calls/group/GroupCallParticipantList.tsx | 3 +-- .../calls/group/GroupCallParticipantMenu.tsx | 2 +- .../calls/group/GroupCallParticipantVideo.tsx | 2 +- .../calls/group/GroupCallTopPane.tsx | 2 +- .../calls/group/MicrophoneButton.tsx | 2 +- src/components/calls/phone/PhoneCall.tsx | 2 +- src/components/common/Audio.tsx | 2 +- src/components/common/AvatarStoryCircle.tsx | 2 +- src/components/common/Composer.tsx | 2 +- src/components/common/CustomEmojiPicker.tsx | 2 +- .../common/CustomEmojiSetsModal.tsx | 2 +- src/components/common/DeleteChatModal.tsx | 2 +- src/components/common/DeleteMessageModal.tsx | 3 +-- src/components/common/GroupChatInfo.tsx | 2 +- src/components/common/MessageSummary.tsx | 2 +- src/components/common/PeerChip.tsx | 7 +++++-- src/components/common/PinMessageModal.tsx | 2 +- .../common/PrivacySettingsNoticeModal.tsx | 2 +- src/components/common/PrivateChatInfo.tsx | 2 +- src/components/common/ProfileInfo.tsx | 8 +++---- src/components/common/RecipientPicker.tsx | 2 +- src/components/common/SeenByModal.tsx | 6 ++++-- .../common/SensitiveContentConfirmModal.tsx | 2 +- src/components/common/StickerSet.tsx | 2 +- src/components/common/StickerSetModal.tsx | 2 +- src/components/common/TypingStatus.tsx | 4 ++-- src/components/common/UiLoader.tsx | 2 +- .../common/VerificationMonetizationModal.tsx | 2 +- src/components/common/WebLink.tsx | 2 +- .../common/embedded/EmbeddedStoryForward.tsx | 2 +- src/components/common/gift/GiftRibbon.tsx | 2 +- src/components/common/gift/SavedGift.tsx | 2 +- .../common/paidMessage/PaidMessagePrice.tsx | 2 +- src/components/common/profile/ChatExtra.tsx | 2 +- .../common/profile/UserBirthday.tsx | 2 +- src/components/left/ChatFolderModal.tsx | 2 +- src/components/left/LeftColumn.tsx | 2 +- src/components/left/main/Chat.tsx | 8 +++---- src/components/left/main/ChatFolders.tsx | 2 +- src/components/left/main/ContactList.tsx | 2 +- src/components/left/main/EmptyFolder.tsx | 2 +- src/components/left/main/EmptyForum.tsx | 2 +- src/components/left/main/ForumPanel.tsx | 2 +- src/components/left/main/LeftMainHeader.tsx | 2 +- .../left/main/LeftSideMenuItems.tsx | 2 +- src/components/left/main/StatusButton.tsx | 2 +- src/components/left/main/StatusPickerMenu.tsx | 2 +- src/components/left/newChat/NewChatStep1.tsx | 2 +- src/components/left/newChat/NewChatStep2.tsx | 2 +- src/components/left/search/BotAppResults.tsx | 2 +- src/components/left/search/ChatMessage.tsx | 9 ++++---- .../left/search/ChatMessageResults.tsx | 2 +- src/components/left/search/ChatResults.tsx | 4 ++-- src/components/left/search/LeftSearch.tsx | 2 +- .../left/search/LeftSearchResultChat.tsx | 2 +- .../left/search/LeftSearchResultTopic.tsx | 2 +- .../left/search/PublicPostsResults.tsx | 2 +- .../left/search/PublicPostsSearchLauncher.tsx | 2 +- src/components/left/search/RecentContacts.tsx | 2 +- .../left/settings/BlockUserModal.tsx | 2 +- .../left/settings/PrivacyMessages.tsx | 2 +- .../left/settings/SettingsAcceptedGift.tsx | 2 +- .../left/settings/SettingsActiveSessions.tsx | 9 +++----- .../left/settings/SettingsActiveWebsite.tsx | 2 +- .../left/settings/SettingsActiveWebsites.tsx | 2 +- .../left/settings/SettingsCustomEmoji.tsx | 2 +- .../left/settings/SettingsDataStorage.tsx | 2 +- .../left/settings/SettingsDoNotTranslate.tsx | 2 +- .../left/settings/SettingsEditProfile.tsx | 16 +++----------- .../left/settings/SettingsExperimental.tsx | 2 +- .../left/settings/SettingsGeneral.tsx | 2 +- .../settings/SettingsGeneralBackground.tsx | 2 +- .../SettingsGeneralBackgroundColor.tsx | 2 +- .../left/settings/SettingsLanguage.tsx | 2 +- src/components/left/settings/SettingsMain.tsx | 2 +- .../left/settings/SettingsNotifications.tsx | 2 +- .../left/settings/SettingsPerformance.tsx | 2 +- .../left/settings/SettingsPrivacy.tsx | 2 +- .../settings/SettingsPrivacyBlockedUsers.tsx | 2 +- .../left/settings/SettingsPrivacyLastSeen.tsx | 2 +- .../settings/SettingsPrivacyVisibility.tsx | 4 ++-- ...SettingsPrivacyVisibilityExceptionList.tsx | 2 +- .../left/settings/SettingsQuickReaction.tsx | 8 +++---- .../left/settings/SettingsStickers.tsx | 2 +- .../folders/SettingsFoldersChatFilters.tsx | 2 +- .../settings/folders/SettingsFoldersEdit.tsx | 2 +- .../settings/folders/SettingsFoldersMain.tsx | 2 +- .../folders/SettingsShareChatlist.tsx | 2 +- .../settings/passcode/SettingsPasscode.tsx | 2 +- .../left/settings/twoFa/SettingsTwoFa.tsx | 2 +- .../settings/twoFa/SettingsTwoFaEmailCode.tsx | 8 +++---- src/components/main/Dialogs.tsx | 2 +- src/components/main/DownloadManager.tsx | 2 +- .../main/ForwardRecipientPicker.tsx | 2 +- src/components/main/GameModal.tsx | 2 +- src/components/main/HistoryCalendar.tsx | 2 +- src/components/main/LockScreen.tsx | 2 +- src/components/main/Main.tsx | 2 +- src/components/main/NewContactModal.tsx | 2 +- src/components/main/Notifications.tsx | 2 +- .../main/PermissionCheckboxList.tsx | 2 +- src/components/main/premium/GiveawayModal.tsx | 5 +---- .../main/premium/GiveawayUserPickerModal.tsx | 7 +++++-- .../main/premium/PremiumMainModal.tsx | 2 +- .../main/premium/StarsGiftingPickerModal.tsx | 2 +- .../common/PremiumLimitReachedModal.tsx | 2 +- .../PremiumFeaturePreviewStickers.tsx | 2 +- .../previews/PremiumFeaturePreviewStories.tsx | 2 +- .../main/visualEffects/ConfettiContainer.tsx | 2 +- .../main/visualEffects/WaveContainer.tsx | 2 +- src/components/mediaViewer/MediaViewer.tsx | 14 ++++++++++++- .../mediaViewer/MediaViewerActions.tsx | 2 +- .../mediaViewer/MediaViewerContent.tsx | 2 +- src/components/mediaViewer/SenderInfo.tsx | 2 +- src/components/middle/ChatLanguageModal.tsx | 2 +- src/components/middle/ContactGreeting.tsx | 4 ++-- .../middle/EmojiInteractionAnimation.tsx | 2 +- .../middle/FloatingActionButtons.tsx | 4 ++-- src/components/middle/HeaderActions.tsx | 4 ++-- src/components/middle/HeaderMenuContainer.tsx | 4 ++-- src/components/middle/MessageList.tsx | 8 +++---- .../middle/MessageListHistoryHandler.tsx | 2 +- .../middle/MessageSelectToolbar.tsx | 2 +- src/components/middle/MiddleColumn.tsx | 6 +++--- src/components/middle/MiddleHeader.tsx | 2 +- src/components/middle/MiddleHeaderPanes.tsx | 2 +- .../middle/PremiumRequiredPlaceholder.tsx | 2 +- src/components/middle/ReactorListModal.tsx | 2 +- .../middle/RequirementToContactMessage.tsx | 2 +- .../middle/composer/AttachmentModal.tsx | 3 +-- .../middle/composer/BotKeyboardMenu.tsx | 10 ++++----- .../composer/ComposerEmbeddedMessage.tsx | 2 +- .../middle/composer/CustomEmojiTooltip.tsx | 2 +- .../middle/composer/EmojiPicker.tsx | 2 +- src/components/middle/composer/GifPicker.tsx | 2 +- .../middle/composer/MessageInput.tsx | 2 +- .../middle/composer/StickerPicker.tsx | 2 +- .../middle/composer/StickerTooltip.tsx | 2 +- src/components/middle/composer/SymbolMenu.tsx | 2 +- .../middle/composer/ToDoListModal.tsx | 2 +- .../middle/composer/WebPagePreview.tsx | 2 +- .../middle/message/ActionMessage.tsx | 2 +- .../middle/message/ActionMessageText.tsx | 2 +- src/components/middle/message/Album.tsx | 2 +- src/components/middle/message/Contact.tsx | 2 +- .../middle/message/ContextMenuContainer.tsx | 5 ++++- src/components/middle/message/Giveaway.tsx | 2 +- src/components/middle/message/MentionLink.tsx | 2 +- src/components/middle/message/Message.tsx | 21 ++++++++----------- src/components/middle/message/Photo.tsx | 2 +- .../middle/message/SenderGroupContainer.tsx | 2 +- .../middle/message/SimilarChannels.tsx | 2 +- .../middle/message/SponsoredMessage.tsx | 2 +- src/components/middle/message/Sticker.tsx | 2 +- src/components/middle/message/Story.tsx | 2 +- .../middle/message/StoryMention.tsx | 2 +- src/components/middle/message/TodoList.tsx | 2 +- src/components/middle/message/Video.tsx | 2 +- src/components/middle/message/WebPage.tsx | 2 +- .../middle/message/actions/Gift.tsx | 2 +- .../middle/message/actions/GiveawayPrize.tsx | 2 +- .../middle/message/actions/StarGift.tsx | 2 +- .../middle/message/actions/StarGiftUnique.tsx | 2 +- .../middle/message/actions/SuggestedPhoto.tsx | 2 +- .../message/actions/SuggestedPostApproval.tsx | 2 +- .../actions/SuggestedPostBalanceTooLow.tsx | 2 +- .../message/actions/SuggestedPostRejected.tsx | 2 +- .../message/reactions/ReactionPicker.tsx | 2 +- .../reactions/ReactionPickerLimited.tsx | 5 +---- src/components/middle/panes/AudioPlayer.tsx | 2 +- src/components/middle/panes/BotAdPane.tsx | 2 +- .../middle/panes/BotVerificationPane.tsx | 2 +- .../middle/panes/ChatReportPane.tsx | 2 +- .../middle/panes/HeaderPinnedMessage.tsx | 8 +++---- .../middle/panes/PaidMessageChargePane.tsx | 2 +- src/components/middle/search/MiddleSearch.tsx | 9 ++++---- src/components/modals/ModalContainer.tsx | 4 ++-- .../modals/aboutAds/AboutAdsModal.tsx | 2 +- .../ageVerification/AgeVerificationModal.tsx | 2 +- src/components/modals/boost/BoostModal.tsx | 2 +- .../modals/chatlist/ChatlistModal.tsx | 2 +- .../collectible/CollectibleInfoModal.tsx | 2 +- .../deleteAccount/DeleteAccountModal.tsx | 2 +- .../EmojiStatusAccessModal.tsx | 2 +- .../frozenAccount/FrozenAccountModal.tsx | 2 +- src/components/modals/gift/GiftComposer.tsx | 2 +- .../modals/gift/GiftItemPremium.tsx | 2 +- src/components/modals/gift/GiftItemStar.tsx | 2 +- src/components/modals/gift/GiftModal.tsx | 2 +- .../modals/gift/GiftModalResaleScreen.tsx | 2 +- .../modals/gift/GiftResaleFilters.tsx | 2 +- .../gift/ResaleGiftMenuAttributeSticker.tsx | 2 +- .../modals/gift/StarGiftCategoryList.tsx | 4 ++-- .../modals/gift/UniqueGiftManageButtons.tsx | 2 +- .../modals/gift/info/GiftInfoModal.tsx | 2 +- .../gift/recipient/GiftRecipientPicker.tsx | 2 +- .../resale/GiftResalePriceComposerModal.tsx | 2 +- .../gift/status/GiftStatusInfoModal.tsx | 2 +- .../gift/transfer/GiftTransferModal.tsx | 2 +- .../modals/gift/upgrade/GiftUpgradeModal.tsx | 2 +- .../gift/withdraw/GiftWithdrawModal.tsx | 2 +- .../modals/giftcode/GiftCodeModal.tsx | 2 +- .../inviteViaLink/InviteViaLinkModal.tsx | 2 +- .../locationAccess/LocationAccessModal.tsx | 2 +- .../modals/paidReaction/PaidReactionModal.tsx | 2 +- .../modals/priceConfirm/PriceConfirmModal.tsx | 2 +- .../profileRating/ProfileRatingModal.tsx | 2 +- .../SharePreparedMessageModal.tsx | 2 +- .../modals/stars/StarsBalanceModal.tsx | 2 +- .../modals/stars/StarsPaymentModal.tsx | 2 +- .../stars/chatRefund/ChatRefundModal.tsx | 2 +- .../modals/stars/gift/StarsGiftModal.tsx | 2 +- .../subscription/StarsSubscriptionModal.tsx | 2 +- .../transaction/StarsTransactionModal.tsx | 2 +- .../suggestMessage/SuggestMessageModal.tsx | 2 +- .../SuggestedPostApprovalModal.tsx | 2 +- .../suggestedStatus/SuggestedStatusModal.tsx | 2 +- .../modals/urlAuth/UrlAuthModal.tsx | 2 +- .../modals/webApp/MinimizedWebAppModal.tsx | 2 +- .../modals/webApp/MoreAppsTabContent.tsx | 2 +- .../modals/webApp/WebAppGridItem.tsx | 2 +- src/components/modals/webApp/WebAppModal.tsx | 2 +- .../modals/webApp/WebAppModalTabContent.tsx | 3 +-- src/components/payment/PasswordConfirm.tsx | 2 +- src/components/payment/PaymentModal.tsx | 19 +++++++---------- src/components/payment/ReceiptModal.tsx | 2 +- src/components/right/AddChatMembers.tsx | 2 +- src/components/right/CreateTopic.tsx | 2 +- src/components/right/DeleteMemberModal.tsx | 2 +- src/components/right/EditTopic.tsx | 2 +- src/components/right/GifSearch.tsx | 3 ++- src/components/right/PollAnswerResults.tsx | 2 +- src/components/right/PollResults.tsx | 10 +++------ src/components/right/Profile.tsx | 7 ++++--- src/components/right/RightColumn.tsx | 3 +-- src/components/right/RightHeader.tsx | 2 +- src/components/right/StickerSearch.tsx | 2 +- src/components/right/StickerSetResult.tsx | 2 +- .../right/gifts/StarGiftCollectionList.tsx | 2 +- .../right/management/JoinRequest.tsx | 3 +-- src/components/right/management/ManageBot.tsx | 8 +++---- .../right/management/ManageChannel.tsx | 2 +- .../management/ManageChatAdministrators.tsx | 2 +- .../management/ManageChatPrivacyType.tsx | 2 +- .../management/ManageChatRemovedUsers.tsx | 2 +- .../right/management/ManageDiscussion.tsx | 2 +- .../right/management/ManageGroup.tsx | 2 +- .../management/ManageGroupAdminRights.tsx | 2 +- .../right/management/ManageGroupMembers.tsx | 2 +- .../management/ManageGroupPermissions.tsx | 2 +- .../management/ManageGroupUserPermissions.tsx | 2 +- .../ManageGroupUserPermissionsCreate.tsx | 2 +- .../right/management/ManageInvite.tsx | 2 +- .../right/management/ManageInviteInfo.tsx | 5 ++--- .../right/management/ManageInvites.tsx | 2 +- .../right/management/ManageJoinRequests.tsx | 2 +- .../right/management/ManageReactions.tsx | 2 +- .../right/management/ManageUser.tsx | 2 +- .../right/management/Management.tsx | 2 +- .../right/management/NewDiscussionGroup.tsx | 2 +- .../right/management/RemoveGroupUserModal.tsx | 2 +- .../right/statistics/BoostStatistics.tsx | 2 +- .../right/statistics/MessageStatistics.tsx | 2 +- .../statistics/MonetizationStatistics.tsx | 2 +- .../right/statistics/Statistics.tsx | 2 +- .../right/statistics/StoryStatistics.tsx | 2 +- .../right/stories/StoryAlbumList.tsx | 2 +- src/components/story/MediaStory.tsx | 2 +- src/components/story/StealthModeModal.tsx | 2 +- src/components/story/Story.tsx | 2 +- src/components/story/StoryPreview.tsx | 2 +- src/components/story/StoryRibbon.tsx | 2 +- src/components/story/StorySettings.tsx | 2 +- src/components/story/StorySlides.tsx | 2 +- src/components/story/StoryToggler.tsx | 2 +- src/components/story/StoryViewModal.tsx | 4 +--- src/components/story/StoryViewer.tsx | 2 +- .../story/mediaArea/MediaAreaWeather.tsx | 2 +- src/components/test/ErrorTest.tsx | 2 +- src/components/test/Test.tsx | 2 +- src/components/ui/ModalStarBalanceBar.tsx | 2 +- src/lib/teact/teactn.tsx | 10 +++++---- 295 files changed, 402 insertions(+), 410 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a8e99497d..9b6e52111 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -250,7 +250,7 @@ const Component = ({ id, className, stateValue, onClick }: OwnProps & StateProps ); } -export default memo(withGlobal((global, { id }): StateProps => { +export default memo(withGlobal((global, { id }): Complete => { const stateValue = selectValue(global, id); return { @@ -311,6 +311,7 @@ Global State is our single, app-wide store, similar to Redux or Zustand. All its * Wrap `withGlobal` in `memo` so the component re-renders only on real data changes. * **Don't** return new arrays or objects inside `withGlobal`; that defeats memoization. * If you need to filter or map a list, **pass IDs as props** and do the heavy work in a `useMemo` hook. +* Force `Complete` return type for `withGlobal` parameter, as it ensures that all defined properties are passed. ### 3. Example Component diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index d69cd3ad0..cb2531ca1 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -47,6 +47,10 @@ type AnyToVoidFunction = (...args: any[]) => void; type BooleanToVoidFunction = (value: boolean) => void; type NoneToVoidFunction = () => void; +type Complete = { + [P in keyof Required]: Pick extends Required> ? T[P] : (T[P] | undefined); +}; + type EmojiCategory = { id: string; name: string; diff --git a/src/components/App.tsx b/src/components/App.tsx index cabb2f810..3845ffce2 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -250,7 +250,7 @@ const App: FC = ({ }; export default withGlobal( - (global): StateProps => { + (global): Complete => { return { authState: global.authState, isScreenLocked: global.passcode?.isScreenLocked, diff --git a/src/components/auth/Auth.tsx b/src/components/auth/Auth.tsx index d56cc000a..0df374b8b 100644 --- a/src/components/auth/Auth.tsx +++ b/src/components/auth/Auth.tsx @@ -99,7 +99,7 @@ const Auth: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { authState: global.authState, }; diff --git a/src/components/auth/AuthCode.tsx b/src/components/auth/AuthCode.tsx index 67039547d..67cdb6f64 100644 --- a/src/components/auth/AuthCode.tsx +++ b/src/components/auth/AuthCode.tsx @@ -132,5 +132,7 @@ const AuthCode: FC = ({ }; export default memo(withGlobal( - (global): StateProps => pick(global, ['authPhoneNumber', 'authIsCodeViaApp', 'authIsLoading', 'authErrorKey']), + (global): Complete => ( + pick(global, ['authPhoneNumber', 'authIsCodeViaApp', 'authIsLoading', 'authErrorKey']) as Complete + ), )(AuthCode)); diff --git a/src/components/auth/AuthPassword.tsx b/src/components/auth/AuthPassword.tsx index 62e265405..da7cb3702 100644 --- a/src/components/auth/AuthPassword.tsx +++ b/src/components/auth/AuthPassword.tsx @@ -50,5 +50,7 @@ const AuthPassword: FC = ({ }; export default memo(withGlobal( - (global): StateProps => pick(global, ['authIsLoading', 'authErrorKey', 'authHint']), + (global): Complete => ( + pick(global, ['authIsLoading', 'authErrorKey', 'authHint']) as Complete + ), )(AuthPassword)); diff --git a/src/components/auth/AuthPhoneNumber.tsx b/src/components/auth/AuthPhoneNumber.tsx index 02db92f7a..babcc1c0b 100644 --- a/src/components/auth/AuthPhoneNumber.tsx +++ b/src/components/auth/AuthPhoneNumber.tsx @@ -314,7 +314,7 @@ const AuthPhoneNumber: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { sharedState: { settings: { language } }, countryList: { phoneCodes: phoneCodeList }, @@ -335,6 +335,6 @@ export default memo(withGlobal( language, phoneCodeList, isTestServer: config?.isTestServer, - }; + } as Complete; }, )(AuthPhoneNumber)); diff --git a/src/components/auth/AuthQrCode.tsx b/src/components/auth/AuthQrCode.tsx index f13808631..8f00eb8bf 100644 --- a/src/components/auth/AuthQrCode.tsx +++ b/src/components/auth/AuthQrCode.tsx @@ -205,7 +205,7 @@ const AuthCode = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { connectionState, authState, authQrCode, } = global; diff --git a/src/components/auth/AuthRegister.tsx b/src/components/auth/AuthRegister.tsx index b24dc15c6..626680382 100644 --- a/src/components/auth/AuthRegister.tsx +++ b/src/components/auth/AuthRegister.tsx @@ -86,5 +86,7 @@ const AuthRegister: FC = ({ }; export default memo(withGlobal( - (global): StateProps => pick(global, ['authIsLoading', 'authErrorKey']), + (global): Complete => ( + pick(global, ['authIsLoading', 'authErrorKey']) as Complete + ), )(AuthRegister)); diff --git a/src/components/auth/CountryCodeInput.tsx b/src/components/auth/CountryCodeInput.tsx index 90f68e21d..3bf4296a0 100644 --- a/src/components/auth/CountryCodeInput.tsx +++ b/src/components/auth/CountryCodeInput.tsx @@ -182,7 +182,7 @@ function getFilteredList(countryList: ApiCountryCode[], filter = ''): ApiCountry } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { countryList: { phoneCodes: phoneCodeList } } = global; return { phoneCodeList, diff --git a/src/components/calls/ActiveCallHeader.tsx b/src/components/calls/ActiveCallHeader.tsx index 72445ce93..a9c040d01 100644 --- a/src/components/calls/ActiveCallHeader.tsx +++ b/src/components/calls/ActiveCallHeader.tsx @@ -57,7 +57,7 @@ const ActiveCallHeader: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); return { groupCall: tabState.isMasterTab ? selectActiveGroupCall(global) : undefined, diff --git a/src/components/calls/group/GroupCall.tsx b/src/components/calls/group/GroupCall.tsx index 342d37dac..215b94871 100644 --- a/src/components/calls/group/GroupCall.tsx +++ b/src/components/calls/group/GroupCall.tsx @@ -552,7 +552,7 @@ const GroupCall: FC = ({ }; export default memo(withGlobal( - (global, { groupCallId }): StateProps => { + (global, { groupCallId }): Complete => { const { connectionState, title, participants, participantsCount, chatId, } = selectGroupCall(global, groupCallId) || {}; diff --git a/src/components/calls/group/GroupCallParticipant.tsx b/src/components/calls/group/GroupCallParticipant.tsx index 68f0c1a49..bac22298e 100644 --- a/src/components/calls/group/GroupCallParticipant.tsx +++ b/src/components/calls/group/GroupCallParticipant.tsx @@ -149,7 +149,7 @@ const GroupCallParticipant: FC = ({ }; export default memo(withGlobal( - (global, { participant }): StateProps => { + (global, { participant }): Complete => { return { peer: selectUser(global, participant.id) || selectChat(global, participant.id), }; diff --git a/src/components/calls/group/GroupCallParticipantList.tsx b/src/components/calls/group/GroupCallParticipantList.tsx index de7030e2d..ddbb95607 100644 --- a/src/components/calls/group/GroupCallParticipantList.tsx +++ b/src/components/calls/group/GroupCallParticipantList.tsx @@ -24,7 +24,6 @@ type OwnProps = { type StateProps = { participantsCount: number; participants?: Record; - canInvite?: boolean; }; const GroupCallParticipantList: FC = ({ @@ -81,7 +80,7 @@ function compareParticipants(a: TypeGroupCallParticipant, b: TypeGroupCallPartic } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { participantsCount, participants } = selectActiveGroupCall(global) || {}; return { diff --git a/src/components/calls/group/GroupCallParticipantMenu.tsx b/src/components/calls/group/GroupCallParticipantMenu.tsx index f6871dfdb..d14e77d81 100644 --- a/src/components/calls/group/GroupCallParticipantMenu.tsx +++ b/src/components/calls/group/GroupCallParticipantMenu.tsx @@ -250,7 +250,7 @@ const GroupCallParticipantMenu: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { isAdmin: selectIsAdminInActiveGroupCall(global), }; diff --git a/src/components/calls/group/GroupCallParticipantVideo.tsx b/src/components/calls/group/GroupCallParticipantVideo.tsx index 732810d12..a7eae8ca4 100644 --- a/src/components/calls/group/GroupCallParticipantVideo.tsx +++ b/src/components/calls/group/GroupCallParticipantVideo.tsx @@ -317,7 +317,7 @@ const GroupCallParticipantVideo: FC = ({ }; export default memo(withGlobal( - (global, { participant }): StateProps => { + (global, { participant }): Complete => { return { user: participant.isUser ? selectUser(global, participant.id) : undefined, chat: !participant.isUser ? selectChat(global, participant.id) : undefined, diff --git a/src/components/calls/group/GroupCallTopPane.tsx b/src/components/calls/group/GroupCallTopPane.tsx index 2fc4f7825..d95e53270 100644 --- a/src/components/calls/group/GroupCallTopPane.tsx +++ b/src/components/calls/group/GroupCallTopPane.tsx @@ -104,7 +104,7 @@ const GroupCallTopPane: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId)!; const groupCall = selectChatGroupCall(global, chatId); const activeGroupCallId = selectTabState(global).isMasterTab ? global.groupCalls.activeGroupCallId : undefined; diff --git a/src/components/calls/group/MicrophoneButton.tsx b/src/components/calls/group/MicrophoneButton.tsx index d0b827231..9bcc44001 100644 --- a/src/components/calls/group/MicrophoneButton.tsx +++ b/src/components/calls/group/MicrophoneButton.tsx @@ -161,7 +161,7 @@ const MicrophoneButton: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const groupCall = selectActiveGroupCall(global); const { connectionState } = groupCall || {}; diff --git a/src/components/calls/phone/PhoneCall.tsx b/src/components/calls/phone/PhoneCall.tsx index 9f1232681..39131985d 100644 --- a/src/components/calls/phone/PhoneCall.tsx +++ b/src/components/calls/phone/PhoneCall.tsx @@ -363,7 +363,7 @@ const PhoneCall: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { phoneCall, currentUserId } = global; const { isCallPanelVisible, isMasterTab } = selectTabState(global); const user = selectPhoneCallUser(global); diff --git a/src/components/common/Audio.tsx b/src/components/common/Audio.tsx index 69114dbc5..8ba1d0d1f 100644 --- a/src/components/common/Audio.tsx +++ b/src/components/common/Audio.tsx @@ -728,7 +728,7 @@ function renderSeekline( export default memo(withGlobal( (global, { message, - }): StateProps => { + }): Complete => { const webPage = selectWebPageFromMessage(global, message); const mediaDuration = selectMessageMediaDuration(global, message); diff --git a/src/components/common/AvatarStoryCircle.tsx b/src/components/common/AvatarStoryCircle.tsx index 0af8a74ea..de92a5993 100644 --- a/src/components/common/AvatarStoryCircle.tsx +++ b/src/components/common/AvatarStoryCircle.tsx @@ -115,7 +115,7 @@ function AvatarStoryCircle({ ); } -export default memo(withGlobal((global, { peerId }): StateProps => { +export default memo(withGlobal((global, { peerId }): Complete => { const peerStories = selectPeerStories(global, peerId); const appTheme = selectTheme(global); diff --git a/src/components/common/Composer.tsx b/src/components/common/Composer.tsx index 80059fc85..fd90ba128 100644 --- a/src/components/common/Composer.tsx +++ b/src/components/common/Composer.tsx @@ -2466,7 +2466,7 @@ const Composer: FC = ({ export default memo(withGlobal( (global, { chatId, threadId, storyId, messageListType, isMobile, type, - }): StateProps => { + }): Complete => { const appConfig = global.appConfig; const chat = selectChat(global, chatId); const chatBot = !isSystemBot(chatId) ? selectBot(global, chatId) : undefined; diff --git a/src/components/common/CustomEmojiPicker.tsx b/src/components/common/CustomEmojiPicker.tsx index c9f69b03e..17389bad6 100644 --- a/src/components/common/CustomEmojiPicker.tsx +++ b/src/components/common/CustomEmojiPicker.tsx @@ -481,7 +481,7 @@ const CustomEmojiPicker: FC = ({ }; export default memo(withGlobal( - (global, { chatId, isStatusPicker, isReactionPicker }): StateProps => { + (global, { chatId, isStatusPicker, isReactionPicker }): Complete => { const { stickers: { setsById: stickerSetsById, diff --git a/src/components/common/CustomEmojiSetsModal.tsx b/src/components/common/CustomEmojiSetsModal.tsx index ef0f8c24c..2e0f3784b 100644 --- a/src/components/common/CustomEmojiSetsModal.tsx +++ b/src/components/common/CustomEmojiSetsModal.tsx @@ -83,7 +83,7 @@ const CustomEmojiSetsModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { canPlayAnimatedEmojis: selectCanPlayAnimatedEmojis(global), }; diff --git a/src/components/common/DeleteChatModal.tsx b/src/components/common/DeleteChatModal.tsx index c01052d00..0ee811a42 100644 --- a/src/components/common/DeleteChatModal.tsx +++ b/src/components/common/DeleteChatModal.tsx @@ -239,7 +239,7 @@ const DeleteChatModal: FC = ({ }; export default memo(withGlobal( - (global, { chat, isSavedDialog }): StateProps => { + (global, { chat, isSavedDialog }): Complete => { const isPrivateChat = isUserId(chat.id); const isChatWithSelf = selectIsChatWithSelf(global, chat.id); const user = isPrivateChat && selectUser(global, getPrivateChatUserId(chat)!); diff --git a/src/components/common/DeleteMessageModal.tsx b/src/components/common/DeleteMessageModal.tsx index de0ec2239..514a9661b 100644 --- a/src/components/common/DeleteMessageModal.tsx +++ b/src/components/common/DeleteMessageModal.tsx @@ -59,7 +59,6 @@ export type OwnProps = { type StateProps = { chat?: ApiChat; - isGroup?: boolean; isChannel?: boolean; isSuperGroup?: boolean; messageIds?: number[]; @@ -492,7 +491,7 @@ const DeleteMessageModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { deleteMessageModal, } = selectTabState(global); diff --git a/src/components/common/GroupChatInfo.tsx b/src/components/common/GroupChatInfo.tsx index 3fa9359ad..eb7b510a1 100644 --- a/src/components/common/GroupChatInfo.tsx +++ b/src/components/common/GroupChatInfo.tsx @@ -288,7 +288,7 @@ const GroupChatInfo: FC = ({ }; export default memo(withGlobal( - (global, { chatId, threadId }): StateProps => { + (global, { chatId, threadId }): Complete => { const chat = selectChat(global, chatId); const threadInfo = threadId ? selectThreadInfo(global, chatId, threadId) : undefined; const onlineCount = chat ? selectChatOnlineCount(global, chat) : undefined; diff --git a/src/components/common/MessageSummary.tsx b/src/components/common/MessageSummary.tsx index 51e7f5823..c9e466b08 100644 --- a/src/components/common/MessageSummary.tsx +++ b/src/components/common/MessageSummary.tsx @@ -119,7 +119,7 @@ function MessageSummary({ } export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const poll = selectPollFromMessage(global, message); const webPage = selectWebPageFromMessage(global, message); const storyData = message.content.storyData; diff --git a/src/components/common/PeerChip.tsx b/src/components/common/PeerChip.tsx index 092949529..d1e6e9e3c 100644 --- a/src/components/common/PeerChip.tsx +++ b/src/components/common/PeerChip.tsx @@ -130,9 +130,12 @@ const PeerChip = ({ }; export default memo(withGlobal( - (global, { peerId, forceShowSelf }): StateProps => { + (global, { peerId, forceShowSelf }): Complete => { if (!peerId) { - return {}; + return { + peer: undefined, + isSavedMessages: undefined, + }; } const peer = selectPeer(global, peerId); diff --git a/src/components/common/PinMessageModal.tsx b/src/components/common/PinMessageModal.tsx index 7cf7080d2..467c7666a 100644 --- a/src/components/common/PinMessageModal.tsx +++ b/src/components/common/PinMessageModal.tsx @@ -104,7 +104,7 @@ const PinMessageModal = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const isPrivateChat = isUserId(chatId); const isChatWithSelf = selectIsChatWithSelf(global, chatId); const chat = selectChat(global, chatId); diff --git a/src/components/common/PrivacySettingsNoticeModal.tsx b/src/components/common/PrivacySettingsNoticeModal.tsx index a29d085a5..a3b86babf 100644 --- a/src/components/common/PrivacySettingsNoticeModal.tsx +++ b/src/components/common/PrivacySettingsNoticeModal.tsx @@ -136,7 +136,7 @@ const PrivacySettingsNoticeModal = ({ isOpen, isReadDate, user }: OwnProps & Sta }; export default memo( - withGlobal((global): StateProps => { + withGlobal((global): Complete => { const { chatId, isReadDate } = selectTabState(global).privacySettingsNoticeModal || {}; const user = chatId ? selectUser(global, chatId) : undefined; diff --git a/src/components/common/PrivateChatInfo.tsx b/src/components/common/PrivateChatInfo.tsx index f437f37fd..f78f12fc0 100644 --- a/src/components/common/PrivateChatInfo.tsx +++ b/src/components/common/PrivateChatInfo.tsx @@ -262,7 +262,7 @@ const PrivateChatInfo: FC = ({ }; export default memo(withGlobal( - (global, { userId, forceShowSelf }): StateProps => { + (global, { userId, forceShowSelf }): Complete => { const { isSynced } = global; const user = userId ? selectUser(global, userId) : undefined; const userStatus = userId ? selectUserStatus(global, userId) : undefined; diff --git a/src/components/common/ProfileInfo.tsx b/src/components/common/ProfileInfo.tsx index 7eccc6d7c..26e507b30 100644 --- a/src/components/common/ProfileInfo.tsx +++ b/src/components/common/ProfileInfo.tsx @@ -450,7 +450,7 @@ const ProfileInfo: FC = ({ }; export default memo(withGlobal( - (global, { peerId }): StateProps => { + (global, { peerId }): Complete => { const user = selectUser(global, peerId); const userFullInfo = user ? selectUserFullInfo(global, peerId) : undefined; const userStatus = selectUserStatus(global, peerId); @@ -477,10 +477,8 @@ export default memo(withGlobal( emojiStatusSticker, emojiStatusSlug, profilePhotos, - ...(topic && { - topic, - messagesCount: selectThreadMessagesCount(global, peerId, currentTopicId!), - }), + topic, + messagesCount: topic ? selectThreadMessagesCount(global, peerId, currentTopicId!) : undefined, }; }, )(ProfileInfo)); diff --git a/src/components/common/RecipientPicker.tsx b/src/components/common/RecipientPicker.tsx index d39d997c1..d8ee54e1c 100644 --- a/src/components/common/RecipientPicker.tsx +++ b/src/components/common/RecipientPicker.tsx @@ -143,7 +143,7 @@ const RecipientPicker: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chats: { listIds, diff --git a/src/components/common/SeenByModal.tsx b/src/components/common/SeenByModal.tsx index 8b5500c3a..4790883fe 100644 --- a/src/components/common/SeenByModal.tsx +++ b/src/components/common/SeenByModal.tsx @@ -99,10 +99,12 @@ function SeenByModal({ } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chatId, messageId } = selectTabState(global).seenByModal || {}; if (!chatId || !messageId) { - return {}; + return { + seenByDates: undefined, + }; } return { diff --git a/src/components/common/SensitiveContentConfirmModal.tsx b/src/components/common/SensitiveContentConfirmModal.tsx index de663e02f..6154d6847 100644 --- a/src/components/common/SensitiveContentConfirmModal.tsx +++ b/src/components/common/SensitiveContentConfirmModal.tsx @@ -51,7 +51,7 @@ const SensitiveContentConfirmModal = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const appConfig = global.appConfig; const verifyAgeMin = appConfig.verifyAgeMin; diff --git a/src/components/common/StickerSet.tsx b/src/components/common/StickerSet.tsx index 6c37e8b0b..a2db1891e 100644 --- a/src/components/common/StickerSet.tsx +++ b/src/components/common/StickerSet.tsx @@ -444,7 +444,7 @@ const StickerSet: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const collectibleStatuses = global.collectibleEmojiStatuses?.statuses; return { collectibleStatuses }; diff --git a/src/components/common/StickerSetModal.tsx b/src/components/common/StickerSetModal.tsx index 2d97aa55c..edfb8c575 100644 --- a/src/components/common/StickerSetModal.tsx +++ b/src/components/common/StickerSetModal.tsx @@ -256,7 +256,7 @@ const StickerSetModal: FC = ({ }; export default memo(withGlobal( - (global, { fromSticker, stickerSetShortName }): StateProps => { + (global, { fromSticker, stickerSetShortName }): Complete => { const currentMessageList = selectCurrentMessageList(global); const { chatId, threadId } = currentMessageList || {}; const chat = chatId && selectChat(global, chatId); diff --git a/src/components/common/TypingStatus.tsx b/src/components/common/TypingStatus.tsx index b51b498c3..581ae761a 100644 --- a/src/components/common/TypingStatus.tsx +++ b/src/components/common/TypingStatus.tsx @@ -41,9 +41,9 @@ const TypingStatus: FC = ({ typingStatus, typingUser }) = }; export default memo(withGlobal( - (global, { typingStatus }): StateProps => { + (global, { typingStatus }): Complete => { if (!typingStatus.userId) { - return {}; + return { typingUser: undefined }; } const typingUser = selectUser(global, typingStatus.userId); diff --git a/src/components/common/UiLoader.tsx b/src/components/common/UiLoader.tsx index 0090847dd..838d35cde 100644 --- a/src/components/common/UiLoader.tsx +++ b/src/components/common/UiLoader.tsx @@ -171,7 +171,7 @@ const UiLoader: FC = ({ }; export default withGlobal( - (global, { isMobile }): StateProps => { + (global, { isMobile }): Complete => { const tabState = selectTabState(global); return { diff --git a/src/components/common/VerificationMonetizationModal.tsx b/src/components/common/VerificationMonetizationModal.tsx index fe668b4f8..4500de612 100644 --- a/src/components/common/VerificationMonetizationModal.tsx +++ b/src/components/common/VerificationMonetizationModal.tsx @@ -88,7 +88,7 @@ const VerificationMonetizationModal = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { twoFaSettings: { hint: passwordHint, diff --git a/src/components/common/WebLink.tsx b/src/components/common/WebLink.tsx index b6f89d51b..7b1e4a929 100644 --- a/src/components/common/WebLink.tsx +++ b/src/components/common/WebLink.tsx @@ -139,7 +139,7 @@ const WebLink = ({ export default memo(withGlobal( (global, { message, - }): StateProps => { + }): Complete => { const webPage = selectWebPageFromMessage(global, message); return { diff --git a/src/components/common/embedded/EmbeddedStoryForward.tsx b/src/components/common/embedded/EmbeddedStoryForward.tsx index c5f85b510..a1e7cd8a3 100644 --- a/src/components/common/embedded/EmbeddedStoryForward.tsx +++ b/src/components/common/embedded/EmbeddedStoryForward.tsx @@ -134,7 +134,7 @@ const EmbeddedStoryForward: FC = ({ }; export default memo(withGlobal( - (global, { forwardInfo }): StateProps => { + (global, { forwardInfo }): Complete => { const sender = forwardInfo.fromPeerId ? selectPeer(global, forwardInfo.fromPeerId) : undefined; const story = forwardInfo.storyId && forwardInfo.fromPeerId ? selectPeerStory(global, forwardInfo.fromPeerId, forwardInfo.storyId) : undefined; diff --git a/src/components/common/gift/GiftRibbon.tsx b/src/components/common/gift/GiftRibbon.tsx index 2a334f7e2..539a0dba6 100644 --- a/src/components/common/gift/GiftRibbon.tsx +++ b/src/components/common/gift/GiftRibbon.tsx @@ -69,7 +69,7 @@ const GiftRibbon = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { theme: selectTheme(global), }; diff --git a/src/components/common/gift/SavedGift.tsx b/src/components/common/gift/SavedGift.tsx index 160619b4a..6ff291d5f 100644 --- a/src/components/common/gift/SavedGift.tsx +++ b/src/components/common/gift/SavedGift.tsx @@ -229,7 +229,7 @@ const SavedGift = ({ }; export default memo(withGlobal( - (global, { peerId, gift }): StateProps => { + (global, { peerId, gift }): Complete => { const fromPeer = gift.fromId ? selectPeer(global, gift.fromId) : undefined; const chat = selectChat(global, peerId); const hasAdminRights = chat && getHasAdminRight(chat, 'postMessages'); diff --git a/src/components/common/paidMessage/PaidMessagePrice.tsx b/src/components/common/paidMessage/PaidMessagePrice.tsx index 586d995f2..68933dabd 100644 --- a/src/components/common/paidMessage/PaidMessagePrice.tsx +++ b/src/components/common/paidMessage/PaidMessagePrice.tsx @@ -98,7 +98,7 @@ function PaidMessagePrice({ } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const starsUsdWithdrawRateX1000 = global.appConfig.starsUsdWithdrawRateX1000; const starsUsdWithdrawRate = starsUsdWithdrawRateX1000 ? starsUsdWithdrawRateX1000 / 1000 : 1; const configStarsPaidMessageCommissionPermille = global.appConfig.starsPaidMessageCommissionPermille; diff --git a/src/components/common/profile/ChatExtra.tsx b/src/components/common/profile/ChatExtra.tsx index 56ea29679..17cf2fc87 100644 --- a/src/components/common/profile/ChatExtra.tsx +++ b/src/components/common/profile/ChatExtra.tsx @@ -484,7 +484,7 @@ const ChatExtra: FC = ({ }; export default memo(withGlobal( - (global, { chatOrUserId, isSavedDialog }): StateProps => { + (global, { chatOrUserId, isSavedDialog }): Complete => { const { countryList: { phoneCodes: phoneCodeList } } = global; const chat = chatOrUserId ? selectChat(global, chatOrUserId) : undefined; diff --git a/src/components/common/profile/UserBirthday.tsx b/src/components/common/profile/UserBirthday.tsx index c3e6e5edd..334beb1ce 100644 --- a/src/components/common/profile/UserBirthday.tsx +++ b/src/components/common/profile/UserBirthday.tsx @@ -218,7 +218,7 @@ const UserBirthday = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { birthdayNumbers, animatedEmojiEffects } = global; return { birthdayNumbers, diff --git a/src/components/left/ChatFolderModal.tsx b/src/components/left/ChatFolderModal.tsx index 881644896..ccc7e3a28 100644 --- a/src/components/left/ChatFolderModal.tsx +++ b/src/components/left/ChatFolderModal.tsx @@ -117,7 +117,7 @@ const ChatFolderModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { byId: foldersById, orderedIds: folderOrderedIds } = global.chatFolders; return { diff --git a/src/components/left/LeftColumn.tsx b/src/components/left/LeftColumn.tsx index decf055c4..47e77374e 100644 --- a/src/components/left/LeftColumn.tsx +++ b/src/components/left/LeftColumn.tsx @@ -565,7 +565,7 @@ function LeftColumn({ } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const { globalSearch: { diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index 397982460..165959d2c 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -496,13 +496,13 @@ const Chat: FC = ({ export default memo(withGlobal( (global, { chatId, isSavedDialog, isPreview, previewMessageId, - }): StateProps => { + }): Complete => { const chat = selectChat(global, chatId); const user = selectUser(global, chatId); if (!chat) { return { currentUserId: global.currentUserId!, - }; + } as Complete; } const folderIds = getChatFolderIds(chatId); @@ -553,9 +553,7 @@ export default memo(withGlobal( isForumPanelOpen: selectIsForumPanelOpen(global), canScrollDown: isSelected && messageListType === 'thread', canChangeFolder: (global.chatFolders.orderedIds?.length || 0) > 1, - ...(isOutgoing && lastMessage && { - lastMessageOutgoingStatus: selectOutgoingStatus(global, lastMessage), - }), + lastMessageOutgoingStatus: isOutgoing && lastMessage ? selectOutgoingStatus(global, lastMessage) : undefined, user, userStatus, lastMessageTopic, diff --git a/src/components/left/main/ChatFolders.tsx b/src/components/left/main/ChatFolders.tsx index 40e3f68c3..33b5cefd2 100644 --- a/src/components/left/main/ChatFolders.tsx +++ b/src/components/left/main/ChatFolders.tsx @@ -408,7 +408,7 @@ const ChatFolders: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chatFolders: { byId: chatFoldersById, diff --git a/src/components/left/main/ContactList.tsx b/src/components/left/main/ContactList.tsx index 62b2c6205..59c1b19fc 100644 --- a/src/components/left/main/ContactList.tsx +++ b/src/components/left/main/ContactList.tsx @@ -108,7 +108,7 @@ const ContactList: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { userIds: contactIds } = global.contactList || {}; const { byId: usersById, statusesById: userStatusesById } = global.users; diff --git a/src/components/left/main/EmptyFolder.tsx b/src/components/left/main/EmptyFolder.tsx index 7c231c1b3..c1684808e 100644 --- a/src/components/left/main/EmptyFolder.tsx +++ b/src/components/left/main/EmptyFolder.tsx @@ -69,7 +69,7 @@ const EmptyFolder: FC = ({ ); }; -export default memo(withGlobal((global, { folderId, folderType }): StateProps => { +export default memo(withGlobal((global, { folderId, folderType }): Complete => { const chatFolder = folderId && folderType === 'folder' ? selectChatFolder(global, folderId) : undefined; return { diff --git a/src/components/left/main/EmptyForum.tsx b/src/components/left/main/EmptyForum.tsx index cd0dbb7f7..9b43f3872 100644 --- a/src/components/left/main/EmptyForum.tsx +++ b/src/components/left/main/EmptyForum.tsx @@ -65,7 +65,7 @@ const EmptyForum: FC = ({ ); }; -export default memo(withGlobal((global, { chatId }): StateProps => { +export default memo(withGlobal((global, { chatId }): Complete => { const chat = selectChat(global, chatId); const canManageTopics = chat && (chat.isCreator || getHasAdminRight(chat, 'manageTopics')); diff --git a/src/components/left/main/ForumPanel.tsx b/src/components/left/main/ForumPanel.tsx index 3c39875d1..0e001cf34 100644 --- a/src/components/left/main/ForumPanel.tsx +++ b/src/components/left/main/ForumPanel.tsx @@ -288,7 +288,7 @@ const ForumPanel: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const chatId = selectTabState(global).forumPanelChatId; const chat = chatId ? selectChat(global, chatId) : undefined; const { diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index e00cd9a55..02cd05792 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -354,7 +354,7 @@ const LeftMainHeader: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const { query: searchQuery, fetchingStatus, chatId, minDate, diff --git a/src/components/left/main/LeftSideMenuItems.tsx b/src/components/left/main/LeftSideMenuItems.tsx index 2c3f4d819..872e914bf 100644 --- a/src/components/left/main/LeftSideMenuItems.tsx +++ b/src/components/left/main/LeftSideMenuItems.tsx @@ -258,7 +258,7 @@ const LeftSideMenuItems = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const { currentUserId, archiveSettings, diff --git a/src/components/left/main/StatusButton.tsx b/src/components/left/main/StatusButton.tsx index 67a80aeb3..f518dd619 100644 --- a/src/components/left/main/StatusButton.tsx +++ b/src/components/left/main/StatusButton.tsx @@ -105,7 +105,7 @@ const StatusButton: FC = ({ emojiStatus, collectibleStatuses, isAcco ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { currentUserId } = global; const currentUser = currentUserId ? selectUser(global, currentUserId) : undefined; const collectibleStatuses = global.collectibleEmojiStatuses?.statuses; diff --git a/src/components/left/main/StatusPickerMenu.tsx b/src/components/left/main/StatusPickerMenu.tsx index ed03cf2dd..0df6b91c4 100644 --- a/src/components/left/main/StatusPickerMenu.tsx +++ b/src/components/left/main/StatusPickerMenu.tsx @@ -82,7 +82,7 @@ const StatusPickerMenu: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { return { areFeaturedStickersLoaded: Boolean(global.customEmojis.featuredIds?.length), isTranslucent: selectIsContextMenuTranslucent(global), diff --git a/src/components/left/newChat/NewChatStep1.tsx b/src/components/left/newChat/NewChatStep1.tsx index 492012514..d3ef49764 100644 --- a/src/components/left/newChat/NewChatStep1.tsx +++ b/src/components/left/newChat/NewChatStep1.tsx @@ -131,7 +131,7 @@ const NewChatStep1: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { userIds: localContactIds } = global.contactList || {}; const { diff --git a/src/components/left/newChat/NewChatStep2.tsx b/src/components/left/newChat/NewChatStep2.tsx index 2451ad5fe..01af4203a 100644 --- a/src/components/left/newChat/NewChatStep2.tsx +++ b/src/components/left/newChat/NewChatStep2.tsx @@ -222,7 +222,7 @@ const NewChatStep2: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { progress: creationProgress, error: creationError, diff --git a/src/components/left/search/BotAppResults.tsx b/src/components/left/search/BotAppResults.tsx index a1818853d..3f2092023 100644 --- a/src/components/left/search/BotAppResults.tsx +++ b/src/components/left/search/BotAppResults.tsx @@ -145,7 +145,7 @@ const BotAppResults: FC = ({ ); }; -export default memo(withGlobal((global) => { +export default memo(withGlobal((global): Complete => { const globalSearch = selectTabState(global).globalSearch; const foundIds = globalSearch.popularBotApps?.peerIds; diff --git a/src/components/left/search/ChatMessage.tsx b/src/components/left/search/ChatMessage.tsx index 1542cdefd..3ac980174 100644 --- a/src/components/left/search/ChatMessage.tsx +++ b/src/components/left/search/ChatMessage.tsx @@ -3,7 +3,7 @@ import { memo } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import type { - ApiChat, ApiMessage, ApiMessageOutgoingStatus, + ApiChat, ApiMessage, ApiUser, } from '../../../api/types'; @@ -46,7 +46,6 @@ type OwnProps = { type StateProps = { chat?: ApiChat; privateChatUser?: ApiUser; - lastMessageOutgoingStatus?: ApiMessageOutgoingStatus; }; const ChatMessage: FC = ({ @@ -141,10 +140,10 @@ function renderSummary( } export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); if (!chat) { - return {}; + return {} as Complete; } const privateChatUserId = getPrivateChatUserId(chat); @@ -152,7 +151,7 @@ export default memo(withGlobal( return { chat, - ...(privateChatUserId && { privateChatUser }), + privateChatUser, }; }, )(ChatMessage)); diff --git a/src/components/left/search/ChatMessageResults.tsx b/src/components/left/search/ChatMessageResults.tsx index 6b0a9b218..0cc044a08 100644 --- a/src/components/left/search/ChatMessageResults.tsx +++ b/src/components/left/search/ChatMessageResults.tsx @@ -167,7 +167,7 @@ const ChatMessageResults: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { byId: chatsById } = global.chats; const { currentUserId, messages: { byChatId: globalMessagesByChatId } } = global; const { diff --git a/src/components/left/search/ChatResults.tsx b/src/components/left/search/ChatResults.tsx index 07c98f785..75ee3b86e 100644 --- a/src/components/left/search/ChatResults.tsx +++ b/src/components/left/search/ChatResults.tsx @@ -498,14 +498,14 @@ const ChatResults: FC = ({ }; export default memo(withGlobal( - (global, { isChannelList }): StateProps => { + (global, { isChannelList }): Complete => { const { userIds: contactIds } = global.contactList || {}; const { currentUserId, messages, } = global; if (!contactIds) { - return {}; + return {} as Complete; } const { diff --git a/src/components/left/search/LeftSearch.tsx b/src/components/left/search/LeftSearch.tsx index 62c717318..301b83e32 100644 --- a/src/components/left/search/LeftSearch.tsx +++ b/src/components/left/search/LeftSearch.tsx @@ -197,7 +197,7 @@ const LeftSearch: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { currentContent, chatId } = selectTabState(global).globalSearch; const { animationLevel } = selectSharedSettings(global); diff --git a/src/components/left/search/LeftSearchResultChat.tsx b/src/components/left/search/LeftSearchResultChat.tsx index 0f83166f6..24d6d7ab0 100644 --- a/src/components/left/search/LeftSearchResultChat.tsx +++ b/src/components/left/search/LeftSearchResultChat.tsx @@ -158,7 +158,7 @@ const LeftSearchResultChat: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const user = selectUser(global, chatId); const isPinned = selectIsChatPinned(global, chatId); diff --git a/src/components/left/search/LeftSearchResultTopic.tsx b/src/components/left/search/LeftSearchResultTopic.tsx index 0a5303d66..8c2c9a2c4 100644 --- a/src/components/left/search/LeftSearchResultTopic.tsx +++ b/src/components/left/search/LeftSearchResultTopic.tsx @@ -59,7 +59,7 @@ const LeftSearchResultTopic: FC = ({ }; export default memo(withGlobal( - (global, { chatId, topicId }): StateProps => { + (global, { chatId, topicId }): Complete => { const topic = selectTopic(global, chatId, topicId); return { diff --git a/src/components/left/search/PublicPostsResults.tsx b/src/components/left/search/PublicPostsResults.tsx index 9bf771f3c..e4b5ac418 100644 --- a/src/components/left/search/PublicPostsResults.tsx +++ b/src/components/left/search/PublicPostsResults.tsx @@ -149,7 +149,7 @@ const PublicPostsResults = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { messages: { byChatId: globalMessagesByChatId } } = global; const { resultsByType, searchFlood, fetchingStatus } = selectTabState(global).globalSearch; const publicPostsResult = resultsByType?.publicPosts; diff --git a/src/components/left/search/PublicPostsSearchLauncher.tsx b/src/components/left/search/PublicPostsSearchLauncher.tsx index 2c6e22321..aafc714b9 100644 --- a/src/components/left/search/PublicPostsSearchLauncher.tsx +++ b/src/components/left/search/PublicPostsSearchLauncher.tsx @@ -270,7 +270,7 @@ const PublicPostsSearchLauncher = ({ ); }; -export default memo(withGlobal((global): StateProps => ({ +export default memo(withGlobal((global): Complete => ({ isCurrentUserPremium: selectIsCurrentUserPremium(global), starsBalance: global.stars?.balance?.amount || 0, }))(PublicPostsSearchLauncher)); diff --git a/src/components/left/search/RecentContacts.tsx b/src/components/left/search/RecentContacts.tsx index 433442a83..68b52bd29 100644 --- a/src/components/left/search/RecentContacts.tsx +++ b/src/components/left/search/RecentContacts.tsx @@ -130,7 +130,7 @@ const RecentContacts: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { userIds: topUserIds } = global.topPeers; const usersById = global.users.byId; const { recentlyFoundChatIds } = global; diff --git a/src/components/left/settings/BlockUserModal.tsx b/src/components/left/settings/BlockUserModal.tsx index 3b1ba08ad..fe6a09cb5 100644 --- a/src/components/left/settings/BlockUserModal.tsx +++ b/src/components/left/settings/BlockUserModal.tsx @@ -86,7 +86,7 @@ const BlockUserModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { users: { byId: usersById, diff --git a/src/components/left/settings/PrivacyMessages.tsx b/src/components/left/settings/PrivacyMessages.tsx index 37de4a3f7..e236b268b 100644 --- a/src/components/left/settings/PrivacyMessages.tsx +++ b/src/components/left/settings/PrivacyMessages.tsx @@ -226,7 +226,7 @@ function PrivacyMessages({ ); } -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { settings: { privacy, diff --git a/src/components/left/settings/SettingsAcceptedGift.tsx b/src/components/left/settings/SettingsAcceptedGift.tsx index 3c013c743..284e9ed1f 100644 --- a/src/components/left/settings/SettingsAcceptedGift.tsx +++ b/src/components/left/settings/SettingsAcceptedGift.tsx @@ -141,7 +141,7 @@ const SettingsAcceptedGift = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { settings: { byKey: { diff --git a/src/components/left/settings/SettingsActiveSessions.tsx b/src/components/left/settings/SettingsActiveSessions.tsx index 9be62ed05..978b80eaf 100644 --- a/src/components/left/settings/SettingsActiveSessions.tsx +++ b/src/components/left/settings/SettingsActiveSessions.tsx @@ -5,6 +5,7 @@ import { import { getActions, withGlobal } from '../../../global'; import type { ApiSession } from '../../../api/types'; +import type { GlobalState } from '../../../global/types'; import { formatPastTimeShort } from '../../../util/dates/dateFormat'; import getSessionIcon from './helpers/getSessionIcon'; @@ -26,11 +27,7 @@ type OwnProps = { onReset: () => void; }; -type StateProps = { - byHash: Record; - orderedHashes: string[]; - ttlDays?: number; -}; +type StateProps = GlobalState['activeSessions']; const SettingsActiveSessions: FC = ({ isActive, @@ -286,5 +283,5 @@ function getLocation(session: ApiSession) { } export default memo(withGlobal( - (global): StateProps => global.activeSessions, + (global): Complete => global.activeSessions as Complete, )(SettingsActiveSessions)); diff --git a/src/components/left/settings/SettingsActiveWebsite.tsx b/src/components/left/settings/SettingsActiveWebsite.tsx index 815c1b4e7..733071b6d 100644 --- a/src/components/left/settings/SettingsActiveWebsite.tsx +++ b/src/components/left/settings/SettingsActiveWebsite.tsx @@ -101,7 +101,7 @@ const SettingsActiveWebsite: FC = ({ ); }; -export default memo(withGlobal((global, { hash }): StateProps => { +export default memo(withGlobal((global, { hash }): Complete => { const session = hash ? global.activeWebSessions.byHash[hash] : undefined; const bot = session ? global.users.byId[session.botId] : undefined; diff --git a/src/components/left/settings/SettingsActiveWebsites.tsx b/src/components/left/settings/SettingsActiveWebsites.tsx index 6510576ca..d64641f22 100644 --- a/src/components/left/settings/SettingsActiveWebsites.tsx +++ b/src/components/left/settings/SettingsActiveWebsites.tsx @@ -164,7 +164,7 @@ const SettingsActiveWebsites: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { byHash, orderedHashes } = global.activeWebSessions; return { byHash, diff --git a/src/components/left/settings/SettingsCustomEmoji.tsx b/src/components/left/settings/SettingsCustomEmoji.tsx index 5b8d70e95..c5edc1856 100644 --- a/src/components/left/settings/SettingsCustomEmoji.tsx +++ b/src/components/left/settings/SettingsCustomEmoji.tsx @@ -94,7 +94,7 @@ const SettingsCustomEmoji: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { ...pick(global.settings.byKey, [ 'shouldSuggestCustomEmoji', diff --git a/src/components/left/settings/SettingsDataStorage.tsx b/src/components/left/settings/SettingsDataStorage.tsx index 3ed4d2716..5f36cfab7 100644 --- a/src/components/left/settings/SettingsDataStorage.tsx +++ b/src/components/left/settings/SettingsDataStorage.tsx @@ -161,7 +161,7 @@ const SettingsDataStorage: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return pick(global.settings.byKey, [ 'canAutoLoadPhotoFromContacts', 'canAutoLoadPhotoInPrivateChats', diff --git a/src/components/left/settings/SettingsDoNotTranslate.tsx b/src/components/left/settings/SettingsDoNotTranslate.tsx index c74afee25..99dd3a342 100644 --- a/src/components/left/settings/SettingsDoNotTranslate.tsx +++ b/src/components/left/settings/SettingsDoNotTranslate.tsx @@ -132,7 +132,7 @@ const SettingsDoNotTranslate: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { doNotTranslate, } = global.settings.byKey; diff --git a/src/components/left/settings/SettingsEditProfile.tsx b/src/components/left/settings/SettingsEditProfile.tsx index 5deceaddf..265ad8472 100644 --- a/src/components/left/settings/SettingsEditProfile.tsx +++ b/src/components/left/settings/SettingsEditProfile.tsx @@ -301,7 +301,7 @@ const SettingsEditProfile: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { currentUserId } = global; const { progress, isUsernameAvailable, checkedUsername, error: editUsernameError, @@ -310,23 +310,13 @@ export default memo(withGlobal( const maxBioLength = selectCurrentLimit(global, 'aboutLength'); - if (!currentUser) { - return { - progress, - checkedUsername, - isUsernameAvailable, - editUsernameError, - maxBioLength, - }; - } - const { firstName: currentFirstName, lastName: currentLastName, usernames, - } = currentUser; + } = currentUser || {}; const currentUserFullInfo = currentUserId ? selectUserFullInfo(global, currentUserId) : undefined; - const currentAvatarHash = getChatAvatarHash(currentUser); + const currentAvatarHash = currentUser && getChatAvatarHash(currentUser); return { currentAvatarHash, diff --git a/src/components/left/settings/SettingsExperimental.tsx b/src/components/left/settings/SettingsExperimental.tsx index 58841c5d6..b404c3e0f 100644 --- a/src/components/left/settings/SettingsExperimental.tsx +++ b/src/components/left/settings/SettingsExperimental.tsx @@ -185,7 +185,7 @@ const SettingsExperimental = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { shouldForceHttpTransport, shouldAllowHttpTransport, diff --git a/src/components/left/settings/SettingsGeneral.tsx b/src/components/left/settings/SettingsGeneral.tsx index 1f3f56b78..00f5615b5 100644 --- a/src/components/left/settings/SettingsGeneral.tsx +++ b/src/components/left/settings/SettingsGeneral.tsx @@ -182,7 +182,7 @@ const SettingsGeneral: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { theme, shouldUseSystemTheme, diff --git a/src/components/left/settings/SettingsGeneralBackground.tsx b/src/components/left/settings/SettingsGeneralBackground.tsx index 7012d191e..06ce128f8 100644 --- a/src/components/left/settings/SettingsGeneralBackground.tsx +++ b/src/components/left/settings/SettingsGeneralBackground.tsx @@ -171,7 +171,7 @@ const SettingsGeneralBackground: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const theme = selectTheme(global); const { background, isBlurred } = selectThemeValues(global, theme) || {}; const { loadedWallpapers } = global.settings; diff --git a/src/components/left/settings/SettingsGeneralBackgroundColor.tsx b/src/components/left/settings/SettingsGeneralBackgroundColor.tsx index 0a1d89ad6..b95510cd9 100644 --- a/src/components/left/settings/SettingsGeneralBackgroundColor.tsx +++ b/src/components/left/settings/SettingsGeneralBackgroundColor.tsx @@ -347,7 +347,7 @@ function drawHue(canvas: HTMLCanvasElement) { } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const theme = selectTheme(global); const { backgroundColor } = selectThemeValues(global, theme) || {}; return { diff --git a/src/components/left/settings/SettingsLanguage.tsx b/src/components/left/settings/SettingsLanguage.tsx index 1e1721840..d36a7fad4 100644 --- a/src/components/left/settings/SettingsLanguage.tsx +++ b/src/components/left/settings/SettingsLanguage.tsx @@ -181,7 +181,7 @@ const SettingsLanguage: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { canTranslate, canTranslateChats, doNotTranslate, } = global.settings.byKey; diff --git a/src/components/left/settings/SettingsMain.tsx b/src/components/left/settings/SettingsMain.tsx index 1cab3111b..ad5f018c2 100644 --- a/src/components/left/settings/SettingsMain.tsx +++ b/src/components/left/settings/SettingsMain.tsx @@ -257,7 +257,7 @@ const SettingsMain: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { currentUserId } = global; const isGiveawayAvailable = selectIsGiveawayGiftsPurchaseAvailable(global); const starsBalance = global.stars?.balance; diff --git a/src/components/left/settings/SettingsNotifications.tsx b/src/components/left/settings/SettingsNotifications.tsx index f0c65d1b5..5ea7feb62 100644 --- a/src/components/left/settings/SettingsNotifications.tsx +++ b/src/components/left/settings/SettingsNotifications.tsx @@ -239,7 +239,7 @@ const SettingsNotifications: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { hasContactJoinedNotifications: Boolean(global.settings.byKey.hasContactJoinedNotifications), hasWebNotifications: global.settings.byKey.hasWebNotifications, diff --git a/src/components/left/settings/SettingsPerformance.tsx b/src/components/left/settings/SettingsPerformance.tsx index 6cc7d5009..382c99285 100644 --- a/src/components/left/settings/SettingsPerformance.tsx +++ b/src/components/left/settings/SettingsPerformance.tsx @@ -226,7 +226,7 @@ function SettingsPerformance({ ); } -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { return { performanceSettings: selectPerformanceSettings(global), }; diff --git a/src/components/left/settings/SettingsPrivacy.tsx b/src/components/left/settings/SettingsPrivacy.tsx index 422b217ce..72ae8d9d4 100644 --- a/src/components/left/settings/SettingsPrivacy.tsx +++ b/src/components/left/settings/SettingsPrivacy.tsx @@ -461,7 +461,7 @@ const SettingsPrivacy: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { settings: { byKey: { diff --git a/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx b/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx index e5e6b7f47..65bcb6382 100644 --- a/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx +++ b/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx @@ -156,7 +156,7 @@ const SettingsPrivacyBlockedUsers: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chats: { byId: chatsByIds, diff --git a/src/components/left/settings/SettingsPrivacyLastSeen.tsx b/src/components/left/settings/SettingsPrivacyLastSeen.tsx index cb95640d9..6339d7f59 100644 --- a/src/components/left/settings/SettingsPrivacyLastSeen.tsx +++ b/src/components/left/settings/SettingsPrivacyLastSeen.tsx @@ -74,7 +74,7 @@ const SettingsPrivacyLastSeen = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { isCurrentUserPremium: selectIsCurrentUserPremium(global), shouldHideReadMarks: Boolean(selectShouldHideReadMarks(global)), diff --git a/src/components/left/settings/SettingsPrivacyVisibility.tsx b/src/components/left/settings/SettingsPrivacyVisibility.tsx index 1a02021bc..adb5d7226 100644 --- a/src/components/left/settings/SettingsPrivacyVisibility.tsx +++ b/src/components/left/settings/SettingsPrivacyVisibility.tsx @@ -402,7 +402,7 @@ function PrivacySubsection({ } export default memo(withGlobal( - (global, { screen }): StateProps => { + (global, { screen }): Complete => { let primaryPrivacy: ApiPrivacySettings | undefined; let secondaryPrivacy: ApiPrivacySettings | undefined; @@ -468,7 +468,7 @@ export default memo(withGlobal( currentUserId: currentUserId!, hasCurrentUserFullInfo: Boolean(currentUserFullInfo), currentUserFallbackPhoto: currentUserFullInfo?.fallbackPhoto, - }; + } as Complete; } return { diff --git a/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx b/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx index 0a5998f66..69b64c6e7 100644 --- a/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx +++ b/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx @@ -259,7 +259,7 @@ function getCurrentPrivacySettings(global: GlobalState, screen: SettingsScreens) } export default memo(withGlobal( - (global, { screen }): StateProps => { + (global, { screen }): Complete => { return { currentUserId: global.currentUserId, settings: getCurrentPrivacySettings(global, screen), diff --git a/src/components/left/settings/SettingsQuickReaction.tsx b/src/components/left/settings/SettingsQuickReaction.tsx index 0279196ef..c1171c5d9 100644 --- a/src/components/left/settings/SettingsQuickReaction.tsx +++ b/src/components/left/settings/SettingsQuickReaction.tsx @@ -2,7 +2,7 @@ import type { FC } from '../../../lib/teact/teact'; import { memo, useCallback, useMemo } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; -import type { ApiAvailableReaction } from '../../../api/types'; +import type { ApiAvailableReaction, ApiReaction } from '../../../api/types'; import useHistoryBack from '../../../hooks/useHistoryBack'; @@ -16,7 +16,7 @@ type OwnProps = { type StateProps = { availableReactions?: ApiAvailableReaction[]; - selectedReaction?: string; + selectedReaction?: ApiReaction; }; const SettingsQuickReaction: FC = ({ @@ -56,7 +56,7 @@ const SettingsQuickReaction: FC = ({ @@ -65,7 +65,7 @@ const SettingsQuickReaction: FC = ({ }; export default memo(withGlobal( - (global) => { + (global): Complete => { const { config, reactions } = global; return { diff --git a/src/components/left/settings/SettingsStickers.tsx b/src/components/left/settings/SettingsStickers.tsx index e9fec00c1..3b89c1d52 100644 --- a/src/components/left/settings/SettingsStickers.tsx +++ b/src/components/left/settings/SettingsStickers.tsx @@ -164,7 +164,7 @@ const SettingsStickers: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { ...pick(global.settings.byKey, [ 'shouldSuggestStickers', diff --git a/src/components/left/settings/folders/SettingsFoldersChatFilters.tsx b/src/components/left/settings/folders/SettingsFoldersChatFilters.tsx index 7109db8c2..7005e430c 100644 --- a/src/components/left/settings/folders/SettingsFoldersChatFilters.tsx +++ b/src/components/left/settings/folders/SettingsFoldersChatFilters.tsx @@ -170,7 +170,7 @@ const SettingsFoldersChatFilters: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { maxChats: selectCurrentLimit(global, 'dialogFiltersChats'), }; diff --git a/src/components/left/settings/folders/SettingsFoldersEdit.tsx b/src/components/left/settings/folders/SettingsFoldersEdit.tsx index ef9e9fdb5..b9e00295f 100644 --- a/src/components/left/settings/folders/SettingsFoldersEdit.tsx +++ b/src/components/left/settings/folders/SettingsFoldersEdit.tsx @@ -472,7 +472,7 @@ const SettingsFoldersEdit: FC = ({ }; export default memo(withGlobal( - (global, { state }): StateProps => { + (global, { state }): Complete => { const { listIds } = global.chats; const { byId, invites } = global.chatFolders; const chatListCount = Object.values(byId).reduce((acc, el) => acc + (el.isChatList ? 1 : 0), 0); diff --git a/src/components/left/settings/folders/SettingsFoldersMain.tsx b/src/components/left/settings/folders/SettingsFoldersMain.tsx index 11759fd5a..3e928de4e 100644 --- a/src/components/left/settings/folders/SettingsFoldersMain.tsx +++ b/src/components/left/settings/folders/SettingsFoldersMain.tsx @@ -416,7 +416,7 @@ const SettingsFoldersMain: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { orderedIds: folderIds, byId: foldersById, diff --git a/src/components/left/settings/folders/SettingsShareChatlist.tsx b/src/components/left/settings/folders/SettingsShareChatlist.tsx index e28b7f32a..c1c7b68cf 100644 --- a/src/components/left/settings/folders/SettingsShareChatlist.tsx +++ b/src/components/left/settings/folders/SettingsShareChatlist.tsx @@ -210,7 +210,7 @@ const SettingsShareChatlist: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { folderId, url, isLoading } = selectTabState(global).shareFolderScreen || {}; const folder = folderId ? selectChatFolder(global, folderId) : undefined; const invite = folderId ? global.chatFolders.invites[folderId]?.find((i) => i.url === url) : undefined; diff --git a/src/components/left/settings/passcode/SettingsPasscode.tsx b/src/components/left/settings/passcode/SettingsPasscode.tsx index b4c0c6532..890013be8 100644 --- a/src/components/left/settings/passcode/SettingsPasscode.tsx +++ b/src/components/left/settings/passcode/SettingsPasscode.tsx @@ -220,5 +220,5 @@ const SettingsPasscode: FC = ({ }; export default memo(withGlobal( - (global): StateProps => ({ ...global.passcode }), + (global): Complete => ({ ...global.passcode } as Complete), )(SettingsPasscode)); diff --git a/src/components/left/settings/twoFa/SettingsTwoFa.tsx b/src/components/left/settings/twoFa/SettingsTwoFa.tsx index 2b38d3e12..8b23be835 100644 --- a/src/components/left/settings/twoFa/SettingsTwoFa.tsx +++ b/src/components/left/settings/twoFa/SettingsTwoFa.tsx @@ -402,5 +402,5 @@ const SettingsTwoFa: FC = ({ }; export default memo(withGlobal( - (global): StateProps => ({ ...global.twoFaSettings }), + (global): Complete => ({ ...global.twoFaSettings } as Complete), )(SettingsTwoFa)); diff --git a/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx b/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx index c9e787a12..f8da64fbd 100644 --- a/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx +++ b/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx @@ -28,9 +28,9 @@ type OwnProps = { }; type StateProps = { - animatedEmoji: ApiSticker; - codeLength: number; - recoveryEmail: string; + animatedEmoji?: ApiSticker; + codeLength?: number; + recoveryEmail?: string; }; const ICON_SIZE = 160; @@ -108,7 +108,7 @@ const SettingsTwoFaEmailCode: FC = ({ ); }; -export default memo(withGlobal((global) => { +export default memo(withGlobal((global): Complete => { const tabState = selectTabState(global); const recoveryEmail = tabState.recoveryEmail; diff --git a/src/components/main/Dialogs.tsx b/src/components/main/Dialogs.tsx index 7d0d0d6e6..5f3a10c06 100644 --- a/src/components/main/Dialogs.tsx +++ b/src/components/main/Dialogs.tsx @@ -120,7 +120,7 @@ function getErrorHeader(error: ApiError) { } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { dialogs: selectTabState(global).dialogs, currentMessageList: selectCurrentMessageList(global), diff --git a/src/components/main/DownloadManager.tsx b/src/components/main/DownloadManager.tsx index 0757293a7..07b8c073a 100644 --- a/src/components/main/DownloadManager.tsx +++ b/src/components/main/DownloadManager.tsx @@ -100,7 +100,7 @@ const DownloadManager: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const activeDownloads = selectTabState(global).activeDownloads; return { diff --git a/src/components/main/ForwardRecipientPicker.tsx b/src/components/main/ForwardRecipientPicker.tsx index 28df35e43..06505f5b3 100644 --- a/src/components/main/ForwardRecipientPicker.tsx +++ b/src/components/main/ForwardRecipientPicker.tsx @@ -123,7 +123,7 @@ const ForwardRecipientPicker: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { messageIds, storyId } = selectTabState(global).forwardMessages; const isForwarding = (messageIds && messageIds.length > 0); return { diff --git a/src/components/main/GameModal.tsx b/src/components/main/GameModal.tsx index 445c78b04..b8b7fa551 100644 --- a/src/components/main/GameModal.tsx +++ b/src/components/main/GameModal.tsx @@ -90,7 +90,7 @@ const GameModal: FC = ({ openedGame, gameTitle, canPost } }; export default memo(withGlobal( - (global, { openedGame }): StateProps => { + (global, { openedGame }): Complete => { const { chatId } = openedGame || {}; const chat = chatId && selectChat(global, chatId); const chatFullInfo = chatId ? selectChatFullInfo(global, chatId) : undefined; diff --git a/src/components/main/HistoryCalendar.tsx b/src/components/main/HistoryCalendar.tsx index b5bbbc075..b8131d6d9 100644 --- a/src/components/main/HistoryCalendar.tsx +++ b/src/components/main/HistoryCalendar.tsx @@ -41,7 +41,7 @@ const HistoryCalendar: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { selectedAt: selectTabState(global).historyCalendarSelectedAt }; }, )(HistoryCalendar)); diff --git a/src/components/main/LockScreen.tsx b/src/components/main/LockScreen.tsx index 0d836b9a4..7200cd8db 100644 --- a/src/components/main/LockScreen.tsx +++ b/src/components/main/LockScreen.tsx @@ -155,7 +155,7 @@ const LockScreen: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { passcodeSettings: global.passcode, }; diff --git a/src/components/main/Main.tsx b/src/components/main/Main.tsx index 1e5d8570e..300e34ea9 100644 --- a/src/components/main/Main.tsx +++ b/src/components/main/Main.tsx @@ -605,7 +605,7 @@ const Main = ({ }; export default memo(withGlobal( - (global, { isMobile }): StateProps => { + (global, { isMobile }): Complete => { const { currentUserId, } = global; diff --git a/src/components/main/NewContactModal.tsx b/src/components/main/NewContactModal.tsx index aa9f89a07..22ddc3055 100644 --- a/src/components/main/NewContactModal.tsx +++ b/src/components/main/NewContactModal.tsx @@ -234,7 +234,7 @@ const NewContactModal: FC = ({ }; export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const user = userId ? selectUser(global, userId) : undefined; return { user, diff --git a/src/components/main/Notifications.tsx b/src/components/main/Notifications.tsx index ad083b669..871786b94 100644 --- a/src/components/main/Notifications.tsx +++ b/src/components/main/Notifications.tsx @@ -28,5 +28,5 @@ const Notifications: FC = ({ notifications }) => { }; export default memo(withGlobal( - (global): StateProps => pick(selectTabState(global), ['notifications']), + (global): Complete => pick(selectTabState(global), ['notifications']), )(Notifications)); diff --git a/src/components/main/PermissionCheckboxList.tsx b/src/components/main/PermissionCheckboxList.tsx index fe5297bfd..b1017462d 100644 --- a/src/components/main/PermissionCheckboxList.tsx +++ b/src/components/main/PermissionCheckboxList.tsx @@ -285,7 +285,7 @@ const PermissionCheckboxList: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = chatId ? selectChat(global, chatId) : undefined; const fullInfo = chat && selectChatFullInfo(global, chat.id); const hasLinkedChat = Boolean(fullInfo?.linkedChatId); diff --git a/src/components/main/premium/GiveawayModal.tsx b/src/components/main/premium/GiveawayModal.tsx index 7ca023769..43794fa83 100644 --- a/src/components/main/premium/GiveawayModal.tsx +++ b/src/components/main/premium/GiveawayModal.tsx @@ -13,7 +13,6 @@ import type { ApiPrepaidStarsGiveaway, ApiStarGiveawayOption, ApiTypePrepaidGiveaway, - ApiUser, } from '../../../api/types'; import { @@ -72,8 +71,6 @@ export type OwnProps = { type StateProps = { chatId?: string; gifts?: ApiPremiumGiftCodeOption[]; - isOpen?: boolean; - fromUser?: ApiUser; selectedMemberList?: string[] | undefined; selectedChannelList?: string[] | undefined; giveawayBoostPerPremiumLimit?: number; @@ -906,7 +903,7 @@ const GiveawayModal: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { giveawayModal, } = selectTabState(global); diff --git a/src/components/main/premium/GiveawayUserPickerModal.tsx b/src/components/main/premium/GiveawayUserPickerModal.tsx index 6e9eed5c8..7b777a60b 100644 --- a/src/components/main/premium/GiveawayUserPickerModal.tsx +++ b/src/components/main/premium/GiveawayUserPickerModal.tsx @@ -131,10 +131,13 @@ const GiveawayUserPickerModal = ({ ); }; -export default memo(withGlobal((global, { giveawayChatId }): StateProps => { +export default memo(withGlobal((global, { giveawayChatId }): Complete => { const chatFullInfo = giveawayChatId ? selectChatFullInfo(global, giveawayChatId) : undefined; if (!chatFullInfo) { - return {}; + return { + members: undefined, + adminMembersById: undefined, + }; } return { diff --git a/src/components/main/premium/PremiumMainModal.tsx b/src/components/main/premium/PremiumMainModal.tsx index 42ceb6122..51b631612 100644 --- a/src/components/main/premium/PremiumMainModal.tsx +++ b/src/components/main/premium/PremiumMainModal.tsx @@ -509,7 +509,7 @@ const PremiumMainModal: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { premiumModal, } = selectTabState(global); diff --git a/src/components/main/premium/StarsGiftingPickerModal.tsx b/src/components/main/premium/StarsGiftingPickerModal.tsx index a8689c239..79f1f0a0d 100644 --- a/src/components/main/premium/StarsGiftingPickerModal.tsx +++ b/src/components/main/premium/StarsGiftingPickerModal.tsx @@ -104,7 +104,7 @@ const StarsGiftingPickerModal: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { chats: { listIds, diff --git a/src/components/main/premium/common/PremiumLimitReachedModal.tsx b/src/components/main/premium/common/PremiumLimitReachedModal.tsx index 0b8e19b2b..31d14dc7f 100644 --- a/src/components/main/premium/common/PremiumLimitReachedModal.tsx +++ b/src/components/main/premium/common/PremiumLimitReachedModal.tsx @@ -218,7 +218,7 @@ const PremiumLimitReachedModal: FC = ({ }; export default memo(withGlobal( - (global, { limit }): StateProps => { + (global, { limit }): Complete => { const { limits } = global.appConfig; const isPremium = selectIsCurrentUserPremium(global); diff --git a/src/components/main/premium/previews/PremiumFeaturePreviewStickers.tsx b/src/components/main/premium/previews/PremiumFeaturePreviewStickers.tsx index b2d07f800..bb8d3875a 100644 --- a/src/components/main/premium/previews/PremiumFeaturePreviewStickers.tsx +++ b/src/components/main/premium/previews/PremiumFeaturePreviewStickers.tsx @@ -158,7 +158,7 @@ const PremiumFeaturePreviewStickers: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { stickers: global.stickers.premium.stickers, }; diff --git a/src/components/main/premium/previews/PremiumFeaturePreviewStories.tsx b/src/components/main/premium/previews/PremiumFeaturePreviewStories.tsx index ccaf4eb66..a64a1f316 100644 --- a/src/components/main/premium/previews/PremiumFeaturePreviewStories.tsx +++ b/src/components/main/premium/previews/PremiumFeaturePreviewStories.tsx @@ -119,7 +119,7 @@ const PremiumFeaturePreviewVideo = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { currentUser: selectUser(global, global.currentUserId!)!, }; diff --git a/src/components/main/visualEffects/ConfettiContainer.tsx b/src/components/main/visualEffects/ConfettiContainer.tsx index 0e966df17..80303d19b 100644 --- a/src/components/main/visualEffects/ConfettiContainer.tsx +++ b/src/components/main/visualEffects/ConfettiContainer.tsx @@ -214,7 +214,7 @@ const ConfettiContainer = ({ confetti }: StateProps) => { }; export default memo(withGlobal( - (global): StateProps => pick(selectTabState(global), ['confetti']), + (global): Complete => pick(selectTabState(global), ['confetti']) as Complete, )(ConfettiContainer)); function generateRandomPositionData( diff --git a/src/components/main/visualEffects/WaveContainer.tsx b/src/components/main/visualEffects/WaveContainer.tsx index 207103a5f..7f319e8c7 100644 --- a/src/components/main/visualEffects/WaveContainer.tsx +++ b/src/components/main/visualEffects/WaveContainer.tsx @@ -101,7 +101,7 @@ const WaveContainer = ({ waveInfo }: StateProps) => { }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); return { waveInfo: tabState.wave, diff --git a/src/components/mediaViewer/MediaViewer.tsx b/src/components/mediaViewer/MediaViewer.tsx index 1d8fae4b9..f1dbff135 100644 --- a/src/components/mediaViewer/MediaViewer.tsx +++ b/src/components/mediaViewer/MediaViewer.tsx @@ -488,7 +488,7 @@ const MediaViewer = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { mediaViewer, shouldSkipHistoryAnimations } = selectTabState(global); const { chatId, @@ -538,6 +538,14 @@ export default memo(withGlobal( isSynced, currentItem, viewableMedia, + chatId, + threadId, + messageId, + message: undefined, + collectedMessageIds: undefined, + chatMessages: undefined, + sponsoredMessage: undefined, + withDynamicLoading, }; } @@ -613,6 +621,10 @@ export default memo(withGlobal( isSynced, currentItem, viewableMedia, + canUpdateMedia: undefined, + avatar: undefined, + avatarOwner: undefined, + profilePhotos: undefined, }; }, )(MediaViewer)); diff --git a/src/components/mediaViewer/MediaViewerActions.tsx b/src/components/mediaViewer/MediaViewerActions.tsx index 57f4fa75e..e6e6d4906 100644 --- a/src/components/mediaViewer/MediaViewerActions.tsx +++ b/src/components/mediaViewer/MediaViewerActions.tsx @@ -392,7 +392,7 @@ const MediaViewerActions: FC = ({ export default memo(withGlobal( (global, { item, canUpdateMedia, - }): StateProps => { + }): Complete => { const tabState = selectTabState(global); const { origin } = tabState.mediaViewer; diff --git a/src/components/mediaViewer/MediaViewerContent.tsx b/src/components/mediaViewer/MediaViewerContent.tsx index e1f29d81c..abccc3ad7 100644 --- a/src/components/mediaViewer/MediaViewerContent.tsx +++ b/src/components/mediaViewer/MediaViewerContent.tsx @@ -244,7 +244,7 @@ const MediaViewerContent = ({ }; export default memo(withGlobal( - (global, { item }): StateProps => { + (global, { item }): Complete => { const { volume, isMuted, diff --git a/src/components/mediaViewer/SenderInfo.tsx b/src/components/mediaViewer/SenderInfo.tsx index 8ce2ccb6d..55dd4770b 100644 --- a/src/components/mediaViewer/SenderInfo.tsx +++ b/src/components/mediaViewer/SenderInfo.tsx @@ -127,7 +127,7 @@ const SenderInfo: FC = ({ }; export default withGlobal( - (global, { item }): StateProps => { + (global, { item }): Complete => { const message = item?.type === 'message' ? item.message : undefined; const messageSender = message && selectSender(global, message); diff --git a/src/components/middle/ChatLanguageModal.tsx b/src/components/middle/ChatLanguageModal.tsx index b2267629a..1e0023d81 100644 --- a/src/components/middle/ChatLanguageModal.tsx +++ b/src/components/middle/ChatLanguageModal.tsx @@ -147,7 +147,7 @@ const ChatLanguageModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chatId, messageId } = selectTabState(global).chatLanguageModal || {}; const currentLanguageCode = selectLanguageCode(global); diff --git a/src/components/middle/ContactGreeting.tsx b/src/components/middle/ContactGreeting.tsx index 2da7ea723..0f11211c2 100644 --- a/src/components/middle/ContactGreeting.tsx +++ b/src/components/middle/ContactGreeting.tsx @@ -122,11 +122,11 @@ const ContactGreeting: FC = ({ }; export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const { stickers } = global.stickers.greeting; const chat = selectChat(global, userId); if (!chat) { - return {}; + return {} as Complete; } const user = selectUser(global, userId); diff --git a/src/components/middle/EmojiInteractionAnimation.tsx b/src/components/middle/EmojiInteractionAnimation.tsx index 15afbf68d..d48bb8ec4 100644 --- a/src/components/middle/EmojiInteractionAnimation.tsx +++ b/src/components/middle/EmojiInteractionAnimation.tsx @@ -116,7 +116,7 @@ const EmojiInteractionAnimation: FC = ({ }; export default memo(withGlobal( - (global, { activeEmojiInteraction }): StateProps => { + (global, { activeEmojiInteraction }): Complete => { const animatedEffect = activeEmojiInteraction.animatedEffect !== undefined && selectAnimatedEmojiEffect(global, activeEmojiInteraction.animatedEffect); return { diff --git a/src/components/middle/FloatingActionButtons.tsx b/src/components/middle/FloatingActionButtons.tsx index 00276abd3..9d83f5d0b 100644 --- a/src/components/middle/FloatingActionButtons.tsx +++ b/src/components/middle/FloatingActionButtons.tsx @@ -161,10 +161,10 @@ const FloatingActionButtons: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentMessageList = selectCurrentMessageList(global); if (!currentMessageList) { - return {}; + return {} as Complete; } const { chatId, threadId, type: messageListType } = currentMessageList; diff --git a/src/components/middle/HeaderActions.tsx b/src/components/middle/HeaderActions.tsx index 74deb98ba..ef9c882a2 100644 --- a/src/components/middle/HeaderActions.tsx +++ b/src/components/middle/HeaderActions.tsx @@ -469,7 +469,7 @@ const HeaderActions: FC = ({ export default memo(withGlobal( (global, { chatId, threadId, messageListType, isMobile, - }): StateProps => { + }): Complete => { const chat = selectChat(global, chatId); const isChannel = Boolean(chat && isChatChannel(chat)); const isSuperGroup = Boolean(chat && isChatSuperGroup(chat)); @@ -485,7 +485,7 @@ export default memo(withGlobal( language, translationLanguage, doNotTranslate, - }; + } as Complete; } const bot = selectBot(global, chatId); diff --git a/src/components/middle/HeaderMenuContainer.tsx b/src/components/middle/HeaderMenuContainer.tsx index 529b5aefc..0c22267f6 100644 --- a/src/components/middle/HeaderMenuContainer.tsx +++ b/src/components/middle/HeaderMenuContainer.tsx @@ -842,11 +842,11 @@ const HeaderMenuContainer: FC = ({ }; export default memo(withGlobal( - (global, { chatId, threadId }): StateProps => { + (global, { chatId, threadId }): Complete => { const chat = selectChat(global, chatId); const isRestricted = selectIsChatRestricted(global, chatId); if (!chat || isRestricted) { - return {}; + return {} as Complete; } const isPrivate = isUserId(chat.id); const user = isPrivate ? selectUser(global, chatId) : undefined; diff --git a/src/components/middle/MessageList.tsx b/src/components/middle/MessageList.tsx index ad6d8d2a6..7c2e01c11 100644 --- a/src/components/middle/MessageList.tsx +++ b/src/components/middle/MessageList.tsx @@ -816,12 +816,12 @@ const MessageList: FC = ({ }; export default memo(withGlobal( - (global, { chatId, threadId, type }): StateProps => { + (global, { chatId, threadId, type }): Complete => { const currentUserId = global.currentUserId!; const chat = selectChat(global, chatId); const userFullInfo = selectUserFullInfo(global, chatId); if (!chat) { - return { currentUserId }; + return { currentUserId } as Complete; } const messageIds = selectCurrentMessageIds(global, chatId, threadId, type); @@ -835,7 +835,7 @@ export default memo(withGlobal( threadId !== MAIN_THREAD_ID && !isSavedDialog && !chat?.isForum && !(messagesById && threadId && messagesById[Number(threadId)]) ) { - return { currentUserId }; + return { currentUserId } as Complete; } const isRestricted = selectIsChatRestricted(global, chatId); @@ -902,7 +902,7 @@ export default memo(withGlobal( isEmptyThread, currentUserId, isChatProtected: selectIsChatProtected(global, chatId), - ...(withLastMessageWhenPreloading && { lastMessage }), + lastMessage: withLastMessageWhenPreloading ? lastMessage : undefined, isAccountFrozen, hasCustomGreeting, isAppConfigLoaded, diff --git a/src/components/middle/MessageListHistoryHandler.tsx b/src/components/middle/MessageListHistoryHandler.tsx index a8a5b02ec..4f06656db 100644 --- a/src/components/middle/MessageListHistoryHandler.tsx +++ b/src/components/middle/MessageListHistoryHandler.tsx @@ -45,7 +45,7 @@ const MessageListHistoryHandler: FC = ({ messageLists }) => { }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { messageLists: selectTabState(global).messageLists, }; diff --git a/src/components/middle/MessageSelectToolbar.tsx b/src/components/middle/MessageSelectToolbar.tsx index 23d4bcadf..13d2783ee 100644 --- a/src/components/middle/MessageSelectToolbar.tsx +++ b/src/components/middle/MessageSelectToolbar.tsx @@ -240,7 +240,7 @@ const MessageSelectToolbar: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const { shouldWarnAboutFiles } = selectSharedSettings(global); const chat = selectCurrentChat(global); diff --git a/src/components/middle/MiddleColumn.tsx b/src/components/middle/MiddleColumn.tsx index e89db3faa..663a06612 100644 --- a/src/components/middle/MiddleColumn.tsx +++ b/src/components/middle/MiddleColumn.tsx @@ -743,7 +743,7 @@ function MiddleColumn({ } export default memo(withGlobal( - (global, { isMobile }): StateProps => { + (global, { isMobile }): Complete => { const theme = selectTheme(global); const { isBlurred: isBackgroundBlurred, background: customBackground, backgroundColor, patternColor, @@ -780,7 +780,7 @@ export default memo(withGlobal( }; if (!currentMessageList) { - return state; + return state as Complete; } const { chatId, threadId, type: messageListType } = currentMessageList; @@ -883,7 +883,7 @@ export default memo(withGlobal( isAccountFrozen, freezeAppealChat, shouldBlockSendInMonoforum, - }; + } as Complete; }, )(MiddleColumn)); diff --git a/src/components/middle/MiddleHeader.tsx b/src/components/middle/MiddleHeader.tsx index d5574d297..1f721119a 100644 --- a/src/components/middle/MiddleHeader.tsx +++ b/src/components/middle/MiddleHeader.tsx @@ -374,7 +374,7 @@ const MiddleHeader: FC = ({ export default memo(withGlobal( (global, { chatId, threadId, messageListType, isMobile, - }): StateProps => { + }): Complete => { const { isLeftColumnShown, shouldSkipHistoryAnimations, audioPlayer, messageLists, } = selectTabState(global); diff --git a/src/components/middle/MiddleHeaderPanes.tsx b/src/components/middle/MiddleHeaderPanes.tsx index 79597dc04..15049c0a3 100644 --- a/src/components/middle/MiddleHeaderPanes.tsx +++ b/src/components/middle/MiddleHeaderPanes.tsx @@ -184,7 +184,7 @@ const MiddleHeaderPanes = ({ export default memo(withGlobal( (global, { chatId, - }): StateProps => { + }): Complete => { const { audioPlayer } = selectTabState(global); const chat = selectChat(global, chatId); const userFullInfo = selectUserFullInfo(global, chatId); diff --git a/src/components/middle/PremiumRequiredPlaceholder.tsx b/src/components/middle/PremiumRequiredPlaceholder.tsx index c399e7ef5..79be38105 100644 --- a/src/components/middle/PremiumRequiredPlaceholder.tsx +++ b/src/components/middle/PremiumRequiredPlaceholder.tsx @@ -32,7 +32,7 @@ function PremiumRequiredPlaceholder({ userName }: StateProps) { } export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const user = selectUser(global, userId); return { diff --git a/src/components/middle/ReactorListModal.tsx b/src/components/middle/ReactorListModal.tsx index 6738eb039..705643417 100644 --- a/src/components/middle/ReactorListModal.tsx +++ b/src/components/middle/ReactorListModal.tsx @@ -265,7 +265,7 @@ const ReactorListModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chatId, messageId } = selectTabState(global).reactorModal || {}; const message = chatId && messageId ? selectChatMessage(global, chatId, messageId) : undefined; diff --git a/src/components/middle/RequirementToContactMessage.tsx b/src/components/middle/RequirementToContactMessage.tsx index efb476580..108d0dca5 100644 --- a/src/components/middle/RequirementToContactMessage.tsx +++ b/src/components/middle/RequirementToContactMessage.tsx @@ -100,7 +100,7 @@ function RequirementToContactMessage({ } export default memo( - withGlobal((global, { peerId: userId }): StateProps => { + withGlobal((global, { peerId: userId }): Complete => { const theme = selectTheme(global); const { patternColor } = selectThemeValues(global, theme) || {}; const peer = selectPeer(global, userId); diff --git a/src/components/middle/composer/AttachmentModal.tsx b/src/components/middle/composer/AttachmentModal.tsx index 9c432cde8..6d0ed23dd 100644 --- a/src/components/middle/composer/AttachmentModal.tsx +++ b/src/components/middle/composer/AttachmentModal.tsx @@ -100,7 +100,6 @@ type StateProps = { currentUserId?: string; groupChatMembers?: ApiChatMember[]; recentEmojis: string[]; - editingMessage?: ApiMessage; baseEmojiKeywords?: Record; emojiKeywords?: Record; shouldSuggestCustomEmoji?: boolean; @@ -777,7 +776,7 @@ const AttachmentModal: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { currentUserId, recentEmojis, diff --git a/src/components/middle/composer/BotKeyboardMenu.tsx b/src/components/middle/composer/BotKeyboardMenu.tsx index 852ca53a8..56e8b76d0 100644 --- a/src/components/middle/composer/BotKeyboardMenu.tsx +++ b/src/components/middle/composer/BotKeyboardMenu.tsx @@ -87,12 +87,12 @@ const BotKeyboardMenu: FC = ({ }; export default memo(withGlobal( - (global, { messageId }): StateProps => { + (global, { messageId }): Complete => { const { chatId } = selectCurrentMessageList(global) || {}; - if (!chatId) { - return {}; - } - return { message: selectChatMessage(global, chatId, messageId) }; + const message = chatId ? selectChatMessage(global, chatId, messageId) : undefined; + return { + message, + }; }, )(BotKeyboardMenu)); diff --git a/src/components/middle/composer/ComposerEmbeddedMessage.tsx b/src/components/middle/composer/ComposerEmbeddedMessage.tsx index ba752677e..a5d618883 100644 --- a/src/components/middle/composer/ComposerEmbeddedMessage.tsx +++ b/src/components/middle/composer/ComposerEmbeddedMessage.tsx @@ -429,7 +429,7 @@ const ComposerEmbeddedMessage: FC = ({ export default memo(withGlobal( (global, { shouldForceShowEditing, chatId, threadId, messageListType, - }): StateProps => { + }): Complete => { const { forwardMessages: { fromChatId, toChatId, messageIds: forwardMessageIds, noAuthors, noCaptions, diff --git a/src/components/middle/composer/CustomEmojiTooltip.tsx b/src/components/middle/composer/CustomEmojiTooltip.tsx index 04794108e..c5bf60224 100644 --- a/src/components/middle/composer/CustomEmojiTooltip.tsx +++ b/src/components/middle/composer/CustomEmojiTooltip.tsx @@ -108,7 +108,7 @@ const CustomEmojiTooltip: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { stickers: customEmoji } = global.customEmojis.forEmoji; const isSavedMessages = selectIsChatWithSelf(global, chatId); const isCurrentUserPremium = selectIsCurrentUserPremium(global); diff --git a/src/components/middle/composer/EmojiPicker.tsx b/src/components/middle/composer/EmojiPicker.tsx index 33c41583b..ea679e987 100644 --- a/src/components/middle/composer/EmojiPicker.tsx +++ b/src/components/middle/composer/EmojiPicker.tsx @@ -252,5 +252,5 @@ async function ensureEmojiData() { } export default memo(withGlobal( - (global): StateProps => pick(global, ['recentEmojis']), + (global): Complete => pick(global, ['recentEmojis']), )(EmojiPicker)); diff --git a/src/components/middle/composer/GifPicker.tsx b/src/components/middle/composer/GifPicker.tsx index 4edbc9fc7..13001e968 100644 --- a/src/components/middle/composer/GifPicker.tsx +++ b/src/components/middle/composer/GifPicker.tsx @@ -95,7 +95,7 @@ const GifPicker: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { chatId } = selectCurrentMessageList(global) || {}; const isSavedMessages = Boolean(chatId) && selectIsChatWithSelf(global, chatId); return { diff --git a/src/components/middle/composer/MessageInput.tsx b/src/components/middle/composer/MessageInput.tsx index dd988c1c7..cae60762a 100644 --- a/src/components/middle/composer/MessageInput.tsx +++ b/src/components/middle/composer/MessageInput.tsx @@ -649,7 +649,7 @@ const MessageInput: FC = ({ }; export default memo(withGlobal( - (global, { chatId, threadId }: OwnProps): StateProps => { + (global, { chatId, threadId }: OwnProps): Complete => { const { messageSendKeyCombo } = selectSharedSettings(global); return { diff --git a/src/components/middle/composer/StickerPicker.tsx b/src/components/middle/composer/StickerPicker.tsx index d33b7808a..2ba26447d 100644 --- a/src/components/middle/composer/StickerPicker.tsx +++ b/src/components/middle/composer/StickerPicker.tsx @@ -404,7 +404,7 @@ const StickerPicker: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { setsById, added, diff --git a/src/components/middle/composer/StickerTooltip.tsx b/src/components/middle/composer/StickerTooltip.tsx index ef77f94ea..645e29223 100644 --- a/src/components/middle/composer/StickerTooltip.tsx +++ b/src/components/middle/composer/StickerTooltip.tsx @@ -96,7 +96,7 @@ const StickerTooltip: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { stickers } = global.stickers.forEmoji; const isSavedMessages = selectIsChatWithSelf(global, chatId); const isCurrentUserPremium = selectIsCurrentUserPremium(global); diff --git a/src/components/middle/composer/SymbolMenu.tsx b/src/components/middle/composer/SymbolMenu.tsx index 835aa85a2..4daa20887 100644 --- a/src/components/middle/composer/SymbolMenu.tsx +++ b/src/components/middle/composer/SymbolMenu.tsx @@ -342,7 +342,7 @@ const SymbolMenu: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { isLeftColumnShown: selectTabState(global).isLeftColumnShown, isBackgroundTranslucent: selectIsContextMenuTranslucent(global), diff --git a/src/components/middle/composer/ToDoListModal.tsx b/src/components/middle/composer/ToDoListModal.tsx index 6006cc7a5..869b84b07 100644 --- a/src/components/middle/composer/ToDoListModal.tsx +++ b/src/components/middle/composer/ToDoListModal.tsx @@ -402,7 +402,7 @@ const ToDoListModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const { appConfig } = global; const editingMessage = modal?.messageId ? selectChatMessage(global, modal.chatId, modal.messageId) : undefined; return { diff --git a/src/components/middle/composer/WebPagePreview.tsx b/src/components/middle/composer/WebPagePreview.tsx index 8ee4e9853..567f6f9b1 100644 --- a/src/components/middle/composer/WebPagePreview.tsx +++ b/src/components/middle/composer/WebPagePreview.tsx @@ -255,7 +255,7 @@ function getMediaTypeKey(webPage: ApiWebPageFull) { } export default memo(withGlobal( - (global, { chatId, threadId }): StateProps => { + (global, { chatId, threadId }): Complete => { const tabState = selectTabState(global); const noWebPage = selectNoWebPage(global, chatId, threadId); const { diff --git a/src/components/middle/message/ActionMessage.tsx b/src/components/middle/message/ActionMessage.tsx index 3d7dba6ab..3cd8972c7 100644 --- a/src/components/middle/message/ActionMessage.tsx +++ b/src/components/middle/message/ActionMessage.tsx @@ -517,7 +517,7 @@ const ActionMessage = ({ }; export default memo(withGlobal( - (global, { message, threadId }): StateProps => { + (global, { message, threadId }): Complete => { const tabState = selectTabState(global); const { themes } = global.settings; diff --git a/src/components/middle/message/ActionMessageText.tsx b/src/components/middle/message/ActionMessageText.tsx index 83a8f36e4..395debe45 100644 --- a/src/components/middle/message/ActionMessageText.tsx +++ b/src/components/middle/message/ActionMessageText.tsx @@ -1012,7 +1012,7 @@ const ActionMessageText = ({ }; export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const chat = selectChat(global, message.chatId); const sender = selectSender(global, message); diff --git a/src/components/middle/message/Album.tsx b/src/components/middle/message/Album.tsx index 24f40ba3d..cff048b15 100644 --- a/src/components/middle/message/Album.tsx +++ b/src/components/middle/message/Album.tsx @@ -164,7 +164,7 @@ const Album: FC = ({ }; export default withGlobal( - (global): StateProps => { + (global): Complete => { const theme = selectTheme(global); const activeDownloads = selectActiveDownloads(global); diff --git a/src/components/middle/message/Contact.tsx b/src/components/middle/message/Contact.tsx index 01bcf6695..3e2ea8b12 100644 --- a/src/components/middle/message/Contact.tsx +++ b/src/components/middle/message/Contact.tsx @@ -125,7 +125,7 @@ function getContactName(contact: ApiContact) { return ''; } -export default withGlobal((global, { contact }): StateProps => { +export default withGlobal((global, { contact }): Complete => { const { countryList: { phoneCodes: phoneCodeList }, } = global; diff --git a/src/components/middle/message/ContextMenuContainer.tsx b/src/components/middle/message/ContextMenuContainer.tsx index e86c4b3f3..38aed0938 100644 --- a/src/components/middle/message/ContextMenuContainer.tsx +++ b/src/components/middle/message/ContextMenuContainer.tsx @@ -71,6 +71,7 @@ import { selectTopic, selectUser, selectUserStatus, + selectWebPageFromMessage, } from '../../../global/selectors'; import { selectMessageDownloadableMedia } from '../../../global/selectors/media'; import buildClassName from '../../../util/buildClassName'; @@ -785,7 +786,7 @@ const ContextMenuContainer: FC = ({ }; export default memo(withGlobal( - (global, { message, messageListType, detectedLanguage }): StateProps => { + (global, { message, messageListType, detectedLanguage }): Complete => { const { threadId } = selectCurrentMessageList(global) || {}; const { defaultTags, topReactions, availableReactions } = global.reactions; @@ -890,6 +891,7 @@ export default memo(withGlobal( const isInSavedMessages = selectIsChatWithSelf(global, message.chatId); const poll = selectPollFromMessage(global, message); + const webPage = selectWebPageFromMessage(global, message); const storyData = message.content.storyData; const story = storyData ? selectPeerStory(global, storyData.peerId, storyData.id) : undefined; @@ -957,6 +959,7 @@ export default memo(withGlobal( userFullName, canGift, savedDialogId, + webPage, }; }, )(ContextMenuContainer)); diff --git a/src/components/middle/message/Giveaway.tsx b/src/components/middle/message/Giveaway.tsx index 77c84b64b..38acf9be8 100644 --- a/src/components/middle/message/Giveaway.tsx +++ b/src/components/middle/message/Giveaway.tsx @@ -357,7 +357,7 @@ const Giveaway = ({ }; export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const { giveaway } = message.content; const chat = selectChat(global, message.chatId)!; const sender = (giveaway?.channelIds[0] ? selectChat(global, giveaway.channelIds[0]) : undefined) diff --git a/src/components/middle/message/MentionLink.tsx b/src/components/middle/message/MentionLink.tsx index 53f28cffb..c7d71a40d 100644 --- a/src/components/middle/message/MentionLink.tsx +++ b/src/components/middle/message/MentionLink.tsx @@ -61,7 +61,7 @@ const MentionLink = ({ }; export default withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { return { userOrChat: userId ? selectUser(global, userId) : undefined, }; diff --git a/src/components/middle/message/Message.tsx b/src/components/middle/message/Message.tsx index 4dbef3689..74a481925 100644 --- a/src/components/middle/message/Message.tsx +++ b/src/components/middle/message/Message.tsx @@ -297,7 +297,6 @@ type StateProps = { hasUnreadReaction?: boolean; isTranscribing?: boolean; transcribedText?: string; - isTranscriptionError?: boolean; isPremium: boolean; senderAdminMember?: ApiChatMember; messageTopic?: ApiTopic; @@ -1871,7 +1870,7 @@ const Message: FC = ({ }; export default memo(withGlobal( - (global, ownProps): StateProps => { + (global, ownProps): Complete => { const { focusedMessage, forwardMessages, activeReactions, activeEmojiInteractions, loadingThread, @@ -2088,16 +2087,14 @@ export default memo(withGlobal( && loadingThread?.loadingChatId === repliesThreadInfo?.originChannelId && loadingThread?.loadingMessageId === repliesThreadInfo?.originMessageId, shouldWarnAboutFiles, - ...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }), - ...(typeof uploadProgress === 'number' && { uploadProgress }), - ...(isFocused && { - focusDirection, - noFocusHighlight, - isResizingContainer, - focusedQuote, - focusedQuoteOffset, - scrollTargetPosition, - }), + outgoingStatus: isOutgoing ? selectOutgoingStatus(global, message, messageListType === 'scheduled') : undefined, + uploadProgress: typeof uploadProgress === 'number' ? uploadProgress : undefined, + focusDirection: isFocused ? focusDirection : undefined, + noFocusHighlight: isFocused ? noFocusHighlight : undefined, + isResizingContainer: isFocused ? isResizingContainer : undefined, + focusedQuote: isFocused ? focusedQuote : undefined, + focusedQuoteOffset: isFocused ? focusedQuoteOffset : undefined, + scrollTargetPosition: isFocused ? scrollTargetPosition : undefined, senderBoosts, tags: global.savedReactionTags?.byKey, canTranscribeVoice, diff --git a/src/components/middle/message/Photo.tsx b/src/components/middle/message/Photo.tsx index 53cde6ed9..6c5a56ba5 100644 --- a/src/components/middle/message/Photo.tsx +++ b/src/components/middle/message/Photo.tsx @@ -308,7 +308,7 @@ const Photo = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const appConfig = global.appConfig; const needsAgeVerification = appConfig.needAgeVideoVerification; diff --git a/src/components/middle/message/SenderGroupContainer.tsx b/src/components/middle/message/SenderGroupContainer.tsx index 6be9d939a..0d2066efe 100644 --- a/src/components/middle/message/SenderGroupContainer.tsx +++ b/src/components/middle/message/SenderGroupContainer.tsx @@ -215,7 +215,7 @@ const SenderGroupContainer: FC = ({ }; export default memo(withGlobal( - (global, ownProps): StateProps => { + (global, ownProps): Complete => { const { message, withAvatar, } = ownProps; diff --git a/src/components/middle/message/SimilarChannels.tsx b/src/components/middle/message/SimilarChannels.tsx index e942962bc..f9af8b9af 100644 --- a/src/components/middle/message/SimilarChannels.tsx +++ b/src/components/middle/message/SimilarChannels.tsx @@ -265,7 +265,7 @@ function MoreChannels({ } export default memo( - withGlobal((global, { chatId }): StateProps => { + withGlobal((global, { chatId }): Complete => { const { similarChannelIds, isExpanded, count } = selectSimilarChannelIds(global, chatId) || {}; const isCurrentUserPremium = selectIsCurrentUserPremium(global); const chatFullInfo = selectChatFullInfo(global, chatId); diff --git a/src/components/middle/message/SponsoredMessage.tsx b/src/components/middle/message/SponsoredMessage.tsx index f83b74a0f..d29c0449c 100644 --- a/src/components/middle/message/SponsoredMessage.tsx +++ b/src/components/middle/message/SponsoredMessage.tsx @@ -337,7 +337,7 @@ const SponsoredMessage: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const message = selectSponsoredMessage(global, chatId); const activeDownloads = selectActiveDownloads(global); diff --git a/src/components/middle/message/Sticker.tsx b/src/components/middle/message/Sticker.tsx index 3ff32b658..6d64da06e 100644 --- a/src/components/middle/message/Sticker.tsx +++ b/src/components/middle/message/Sticker.tsx @@ -230,7 +230,7 @@ const Sticker: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const appConfig = global.appConfig; const needsAgeVerification = appConfig.needAgeVideoVerification; diff --git a/src/components/middle/message/Story.tsx b/src/components/middle/message/Story.tsx index 748106e88..8ec1f707e 100644 --- a/src/components/middle/message/Story.tsx +++ b/src/components/middle/message/Story.tsx @@ -33,7 +33,7 @@ function Story({ ); } -export default memo(withGlobal((global, { message }): StateProps => { +export default memo(withGlobal((global, { message }): Complete => { const { id, peerId } = message.content.storyData!; return { diff --git a/src/components/middle/message/StoryMention.tsx b/src/components/middle/message/StoryMention.tsx index 6073f6e4d..f6ebc0701 100644 --- a/src/components/middle/message/StoryMention.tsx +++ b/src/components/middle/message/StoryMention.tsx @@ -93,7 +93,7 @@ function StoryMention({ ); } -export default memo(withGlobal((global, { message }): StateProps => { +export default memo(withGlobal((global, { message }): Complete => { const { id, peerId } = message.content.storyData!; const lastReadId = selectPeerStories(global, peerId)?.lastReadId; diff --git a/src/components/middle/message/TodoList.tsx b/src/components/middle/message/TodoList.tsx index 1a748a463..f3def0dff 100644 --- a/src/components/middle/message/TodoList.tsx +++ b/src/components/middle/message/TodoList.tsx @@ -190,7 +190,7 @@ const TodoList = ({ ); }; -export default memo(withGlobal((global, { message }): StateProps => { +export default memo(withGlobal((global, { message }): Complete => { const sender = selectSender(global, message); return { sender, diff --git a/src/components/middle/message/Video.tsx b/src/components/middle/message/Video.tsx index e4f6f52d5..975d586ce 100644 --- a/src/components/middle/message/Video.tsx +++ b/src/components/middle/message/Video.tsx @@ -351,7 +351,7 @@ const Video = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const appConfig = global.appConfig; const needsAgeVerification = appConfig.needAgeVideoVerification; diff --git a/src/components/middle/message/WebPage.tsx b/src/components/middle/message/WebPage.tsx index f95bf0ebb..aefb54803 100644 --- a/src/components/middle/message/WebPage.tsx +++ b/src/components/middle/message/WebPage.tsx @@ -329,7 +329,7 @@ function getIsSmallPhoto(webPage: ApiWebPageFull, mediaSize?: WebPageMediaSize) } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { return { canPlayAnimatedEmojis: selectCanPlayAnimatedEmojis(global), }; diff --git a/src/components/middle/message/actions/Gift.tsx b/src/components/middle/message/actions/Gift.tsx index d7092eda9..1623e130b 100644 --- a/src/components/middle/message/actions/Gift.tsx +++ b/src/components/middle/message/actions/Gift.tsx @@ -102,7 +102,7 @@ const GiftAction = ({ }; export default memo(withGlobal( - (global, { action }): StateProps => { + (global, { action }): Complete => { const sticker = action.type === 'giftPremium' ? selectGiftStickerForDuration(global, action.months) : action.type === 'giftStars' diff --git a/src/components/middle/message/actions/GiveawayPrize.tsx b/src/components/middle/message/actions/GiveawayPrize.tsx index c71beb538..7eeb4fb00 100644 --- a/src/components/middle/message/actions/GiveawayPrize.tsx +++ b/src/components/middle/message/actions/GiveawayPrize.tsx @@ -134,7 +134,7 @@ const GiveawayPrizeAction = ({ }; export default memo(withGlobal( - (global, { action }): StateProps => { + (global, { action }): Complete => { const currentUserId = global.currentUserId!; const sticker = action.type === 'giftCode' ? selectGiftStickerForDuration(global, action.months) diff --git a/src/components/middle/message/actions/StarGift.tsx b/src/components/middle/message/actions/StarGift.tsx index ad9faac69..31d04941f 100644 --- a/src/components/middle/message/actions/StarGift.tsx +++ b/src/components/middle/message/actions/StarGift.tsx @@ -182,7 +182,7 @@ const StarGiftAction = ({ }; export default memo(withGlobal( - (global, { message, action }): StateProps => { + (global, { message, action }): Complete => { const currentUser = selectUser(global, global.currentUserId!); const canPlayAnimatedEmojis = selectCanPlayAnimatedEmojis(global); const messageSender = selectSender(global, message); diff --git a/src/components/middle/message/actions/StarGiftUnique.tsx b/src/components/middle/message/actions/StarGiftUnique.tsx index aee0a352c..217ad932e 100644 --- a/src/components/middle/message/actions/StarGiftUnique.tsx +++ b/src/components/middle/message/actions/StarGiftUnique.tsx @@ -151,7 +151,7 @@ const StarGiftAction = ({ }; export default memo(withGlobal( - (global, { message, action }): StateProps => { + (global, { message, action }): Complete => { const currentUser = selectUser(global, global.currentUserId!); const canPlayAnimatedEmojis = selectCanPlayAnimatedEmojis(global); const messageSender = selectSender(global, message); diff --git a/src/components/middle/message/actions/SuggestedPhoto.tsx b/src/components/middle/message/actions/SuggestedPhoto.tsx index cbd8e9f04..a2fbe35f2 100644 --- a/src/components/middle/message/actions/SuggestedPhoto.tsx +++ b/src/components/middle/message/actions/SuggestedPhoto.tsx @@ -151,7 +151,7 @@ const SuggestedPhotoAction = ({ }; export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const peer = selectPeer(global, message.chatId); return { diff --git a/src/components/middle/message/actions/SuggestedPostApproval.tsx b/src/components/middle/message/actions/SuggestedPostApproval.tsx index dac5f191b..016e2724c 100644 --- a/src/components/middle/message/actions/SuggestedPostApproval.tsx +++ b/src/components/middle/message/actions/SuggestedPostApproval.tsx @@ -129,7 +129,7 @@ const SuggestedPostApproval = ({ }; export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const sender = selectSender(global, message); const chat = selectMonoforumChannel(global, message.chatId); diff --git a/src/components/middle/message/actions/SuggestedPostBalanceTooLow.tsx b/src/components/middle/message/actions/SuggestedPostBalanceTooLow.tsx index 6964cc553..74aaf7330 100644 --- a/src/components/middle/message/actions/SuggestedPostBalanceTooLow.tsx +++ b/src/components/middle/message/actions/SuggestedPostBalanceTooLow.tsx @@ -76,7 +76,7 @@ const SuggestedPostBalanceTooLow = ({ }; export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const sender = selectSender(global, message); const replyMessage = message.replyInfo?.type === 'message' && message.replyInfo.replyToMsgId diff --git a/src/components/middle/message/actions/SuggestedPostRejected.tsx b/src/components/middle/message/actions/SuggestedPostRejected.tsx index 6fe8cde9c..8936da5c9 100644 --- a/src/components/middle/message/actions/SuggestedPostRejected.tsx +++ b/src/components/middle/message/actions/SuggestedPostRejected.tsx @@ -64,7 +64,7 @@ const SuggestedPostRejected = ({ }; export default memo(withGlobal( - (global, { message }): StateProps => { + (global, { message }): Complete => { const sender = selectSender(global, message); return { diff --git a/src/components/middle/message/reactions/ReactionPicker.tsx b/src/components/middle/message/reactions/ReactionPicker.tsx index 9bff2d4a4..454e72300 100644 --- a/src/components/middle/message/reactions/ReactionPicker.tsx +++ b/src/components/middle/message/reactions/ReactionPicker.tsx @@ -290,7 +290,7 @@ const ReactionPicker: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const state = selectTabState(global); const availableEffectById = global.availableEffectById; const { diff --git a/src/components/middle/message/reactions/ReactionPickerLimited.tsx b/src/components/middle/message/reactions/ReactionPickerLimited.tsx index ea531012f..f85a9d6cd 100644 --- a/src/components/middle/message/reactions/ReactionPickerLimited.tsx +++ b/src/components/middle/message/reactions/ReactionPickerLimited.tsx @@ -39,10 +39,7 @@ type StateProps = { availableReactions?: ApiAvailableReaction[]; topReactions: ApiReaction[]; isWithPaidReaction?: boolean; - canAnimate?: boolean; - isSavedMessages?: boolean; reactionsLimit?: number; - isCurrentUserPremium?: boolean; }; const REACTION_SIZE = 36; @@ -150,7 +147,7 @@ const ReactionPickerLimited: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { availableReactions, topReactions } = global.reactions; const { maxUniqueReactions } = global.appConfig; diff --git a/src/components/middle/panes/AudioPlayer.tsx b/src/components/middle/panes/AudioPlayer.tsx index d68891f89..1e80fa8fc 100644 --- a/src/components/middle/panes/AudioPlayer.tsx +++ b/src/components/middle/panes/AudioPlayer.tsx @@ -420,7 +420,7 @@ function renderPlaybackRateMenuItem( } export default withGlobal( - (global, { isHidden }): StateProps => { + (global, { isHidden }): Complete => { const { audioPlayer } = selectTabState(global); const { chatId, messageId } = audioPlayer; const message = !isHidden && chatId && messageId ? selectChatMessage(global, chatId, messageId) : undefined; diff --git a/src/components/middle/panes/BotAdPane.tsx b/src/components/middle/panes/BotAdPane.tsx index e992e516d..9c01c844d 100644 --- a/src/components/middle/panes/BotAdPane.tsx +++ b/src/components/middle/panes/BotAdPane.tsx @@ -159,7 +159,7 @@ const BotAdPane = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const bot = selectBot(global, chatId); const sponsoredMessage = selectSponsoredMessage(global, chatId); return { diff --git a/src/components/middle/panes/BotVerificationPane.tsx b/src/components/middle/panes/BotVerificationPane.tsx index 869f45b7e..0a332fbfc 100644 --- a/src/components/middle/panes/BotVerificationPane.tsx +++ b/src/components/middle/panes/BotVerificationPane.tsx @@ -66,7 +66,7 @@ const BotVerificationPane: FC = ({ }; export default memo(withGlobal( - (global, { peerId }): StateProps => { + (global, { peerId }): Complete => { const peerFullInfo = selectPeerFullInfo(global, peerId); const botVerification = peerFullInfo?.botVerification; diff --git a/src/components/middle/panes/ChatReportPane.tsx b/src/components/middle/panes/ChatReportPane.tsx index 55761d3c6..b0ff7095b 100644 --- a/src/components/middle/panes/ChatReportPane.tsx +++ b/src/components/middle/panes/ChatReportPane.tsx @@ -211,7 +211,7 @@ const ChatReportPane: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => ({ + (global, { chatId }): Complete => ({ currentUserId: global.currentUserId, peer: selectPeer(global, chatId), }), diff --git a/src/components/middle/panes/HeaderPinnedMessage.tsx b/src/components/middle/panes/HeaderPinnedMessage.tsx index 2e3311a65..71abf251d 100644 --- a/src/components/middle/panes/HeaderPinnedMessage.tsx +++ b/src/components/middle/panes/HeaderPinnedMessage.tsx @@ -342,7 +342,7 @@ const HeaderPinnedMessage = ({ export default memo(withGlobal( (global, { chatId, threadId, messageListType, - }): StateProps => { + }): Complete => { const chat = selectChat(global, chatId); const isSynced = global.isSynced; @@ -356,7 +356,7 @@ export default memo(withGlobal( }; if (messageListType !== 'thread' || !messagesById) { - return state; + return state as Complete; } if (threadId !== MAIN_THREAD_ID && !isSavedDialog && !chat?.isForum) { @@ -389,9 +389,9 @@ export default memo(withGlobal( pinnedMessageIds, messagesById, canUnpin, - }; + } as Complete; } - return state; + return state as Complete; }, )(HeaderPinnedMessage)); diff --git a/src/components/middle/panes/PaidMessageChargePane.tsx b/src/components/middle/panes/PaidMessageChargePane.tsx index 08fcf8e39..20164c719 100644 --- a/src/components/middle/panes/PaidMessageChargePane.tsx +++ b/src/components/middle/panes/PaidMessageChargePane.tsx @@ -92,7 +92,7 @@ const PaidMessageChargePane: FC = ({ }; export default memo(withGlobal( - (global, { peerId }): StateProps => { + (global, { peerId }): Complete => { const chat = selectChat(global, peerId); const peerFullInfo = selectUserFullInfo(global, peerId); const chargedPaidMessageStars = peerFullInfo?.settings?.chargedPaidMessageStars; diff --git a/src/components/middle/search/MiddleSearch.tsx b/src/components/middle/search/MiddleSearch.tsx index 57c4f3ea4..ded50117f 100644 --- a/src/components/middle/search/MiddleSearch.tsx +++ b/src/components/middle/search/MiddleSearch.tsx @@ -66,7 +66,6 @@ export type OwnProps = { }; type StateProps = { - isActive?: boolean; chat?: ApiChat; monoforumChat?: ApiChat; threadId?: ThreadId; @@ -96,7 +95,7 @@ const RESULT_ITEM_CLASS_NAME = 'MiddleSearchResult'; const runDebouncedForSearch = debounce((cb) => cb(), 200, false); -const MiddleSearch: FC = ({ +const MiddleSearch: FC = ({ isActive, chat, monoforumChat, @@ -773,16 +772,16 @@ const MiddleSearch: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentMessageList = selectCurrentMessageList(global); if (!currentMessageList) { - return {}; + return {} as Complete; } const { chatId, threadId } = currentMessageList; const chat = selectChat(global, chatId); if (!chat) { - return {}; + return {} as Complete; } const { diff --git a/src/components/modals/ModalContainer.tsx b/src/components/modals/ModalContainer.tsx index 14af550fa..b48c9d92e 100644 --- a/src/components/modals/ModalContainer.tsx +++ b/src/components/modals/ModalContainer.tsx @@ -169,7 +169,7 @@ const ModalContainer = (modalProps: StateProps) => { }; export default memo(withGlobal( - (global): StateProps => ( - pick(selectTabState(global), MODAL_KEYS) + (global): Complete => ( + pick(selectTabState(global), MODAL_KEYS) as Complete ), )(ModalContainer)); diff --git a/src/components/modals/aboutAds/AboutAdsModal.tsx b/src/components/modals/aboutAds/AboutAdsModal.tsx index caab11ec4..15cf0078e 100644 --- a/src/components/modals/aboutAds/AboutAdsModal.tsx +++ b/src/components/modals/aboutAds/AboutAdsModal.tsx @@ -176,7 +176,7 @@ const AboutAdsModal = ({ modal, minLevelToRestrictAds }: OwnProps & StateProps) }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const minLevelToRestrictAds = global.appConfig.channelRestrictAdsLevelMin; return { diff --git a/src/components/modals/ageVerification/AgeVerificationModal.tsx b/src/components/modals/ageVerification/AgeVerificationModal.tsx index 0ce958873..606b22828 100644 --- a/src/components/modals/ageVerification/AgeVerificationModal.tsx +++ b/src/components/modals/ageVerification/AgeVerificationModal.tsx @@ -84,7 +84,7 @@ const AgeVerificationModal: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const appConfig = global.appConfig; const verifyAgeBotUsername = appConfig.verifyAgeBotUsername; const verifyAgeMin = appConfig.verifyAgeMin || VERIFY_AGE_MIN_DEFAULT; diff --git a/src/components/modals/boost/BoostModal.tsx b/src/components/modals/boost/BoostModal.tsx index c200b406e..244f93abe 100644 --- a/src/components/modals/boost/BoostModal.tsx +++ b/src/components/modals/boost/BoostModal.tsx @@ -346,7 +346,7 @@ function areAllBoostsInChannel(myBoosts: ApiMyBoost[], chatId: string) { } export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const chat = modal && selectChat(global, modal?.chatId); const chatFullInfo = chat && selectChatFullInfo(global, chat.id); const firstBoost = modal?.myBoosts && getFirstAvailableBoost(modal.myBoosts, modal.chatId); diff --git a/src/components/modals/chatlist/ChatlistModal.tsx b/src/components/modals/chatlist/ChatlistModal.tsx index aa42464e0..aa312aacc 100644 --- a/src/components/modals/chatlist/ChatlistModal.tsx +++ b/src/components/modals/chatlist/ChatlistModal.tsx @@ -130,7 +130,7 @@ const ChatlistInviteModal: FC = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const { invite, removal } = modal || {}; const folderId = removal?.folderId || (invite && 'folderId' in invite ? invite.folderId : undefined); const folder = folderId ? selectChatFolder(global, folderId) : undefined; diff --git a/src/components/modals/collectible/CollectibleInfoModal.tsx b/src/components/modals/collectible/CollectibleInfoModal.tsx index 5d3d55cc6..d67b840d0 100644 --- a/src/components/modals/collectible/CollectibleInfoModal.tsx +++ b/src/components/modals/collectible/CollectibleInfoModal.tsx @@ -145,7 +145,7 @@ const CollectibleInfoModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { countryList } = global; return { diff --git a/src/components/modals/deleteAccount/DeleteAccountModal.tsx b/src/components/modals/deleteAccount/DeleteAccountModal.tsx index 46eb8db58..397cfd3d9 100644 --- a/src/components/modals/deleteAccount/DeleteAccountModal.tsx +++ b/src/components/modals/deleteAccount/DeleteAccountModal.tsx @@ -107,7 +107,7 @@ const DeleteAccountModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const { selfDestructAccountDays } = modal || {}; return { diff --git a/src/components/modals/emojiStatusAccess/EmojiStatusAccessModal.tsx b/src/components/modals/emojiStatusAccess/EmojiStatusAccessModal.tsx index 58df0ae01..812104a84 100644 --- a/src/components/modals/emojiStatusAccess/EmojiStatusAccessModal.tsx +++ b/src/components/modals/emojiStatusAccess/EmojiStatusAccessModal.tsx @@ -194,7 +194,7 @@ const EmojiStatusAccessModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentUser = selectUser(global, global.currentUserId!); const isPremium = selectIsCurrentUserPremium(global); const stickerSet = global.defaultStatusIconsId ? selectStickerSet(global, global.defaultStatusIconsId) : undefined; diff --git a/src/components/modals/frozenAccount/FrozenAccountModal.tsx b/src/components/modals/frozenAccount/FrozenAccountModal.tsx index f7246c9d0..6c50e6532 100644 --- a/src/components/modals/frozenAccount/FrozenAccountModal.tsx +++ b/src/components/modals/frozenAccount/FrozenAccountModal.tsx @@ -126,7 +126,7 @@ const FrozenAccountModal = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const freezeUntilDate = global.appConfig.freezeUntilDate; const freezeAppealUrl = global.appConfig.freezeAppealUrl; const botFreezeAppeal = global.botFreezeAppealId ? selectUser(global, global.botFreezeAppealId) : undefined; diff --git a/src/components/modals/gift/GiftComposer.tsx b/src/components/modals/gift/GiftComposer.tsx index fddc5af6c..eb8a05541 100644 --- a/src/components/modals/gift/GiftComposer.tsx +++ b/src/components/modals/gift/GiftComposer.tsx @@ -397,7 +397,7 @@ function GiftComposer({ } export default memo(withGlobal( - (global, { peerId }): StateProps => { + (global, { peerId }): Complete => { const theme = selectTheme(global); const { stars, diff --git a/src/components/modals/gift/GiftItemPremium.tsx b/src/components/modals/gift/GiftItemPremium.tsx index 7a40a2c8c..e4550a8eb 100644 --- a/src/components/modals/gift/GiftItemPremium.tsx +++ b/src/components/modals/gift/GiftItemPremium.tsx @@ -101,7 +101,7 @@ function GiftItemPremium({ } export default memo(withGlobal( - (global, { option }): StateProps => { + (global, { option }): Complete => { const sticker = selectGiftStickerForDuration(global, option.months); const canPlayAnimatedEmojis = selectCanPlayAnimatedEmojis(global); diff --git a/src/components/modals/gift/GiftItemStar.tsx b/src/components/modals/gift/GiftItemStar.tsx index 159703af3..61ce9224a 100644 --- a/src/components/modals/gift/GiftItemStar.tsx +++ b/src/components/modals/gift/GiftItemStar.tsx @@ -219,7 +219,7 @@ function GiftItemStar({ } export default memo( - withGlobal((global): StateProps => { + withGlobal((global): Complete => { const isCurrentUserPremium = selectIsCurrentUserPremium(global); return { diff --git a/src/components/modals/gift/GiftModal.tsx b/src/components/modals/gift/GiftModal.tsx index d83d5a579..49994d56c 100644 --- a/src/components/modals/gift/GiftModal.tsx +++ b/src/components/modals/gift/GiftModal.tsx @@ -515,7 +515,7 @@ const GiftModal: FC = ({ ); }; -export default memo(withGlobal((global, { modal }): StateProps => { +export default memo(withGlobal((global, { modal }): Complete => { const { starGifts, stars, diff --git a/src/components/modals/gift/GiftModalResaleScreen.tsx b/src/components/modals/gift/GiftModalResaleScreen.tsx index 315291e13..8684597c2 100644 --- a/src/components/modals/gift/GiftModalResaleScreen.tsx +++ b/src/components/modals/gift/GiftModalResaleScreen.tsx @@ -151,7 +151,7 @@ const GiftModalResaleScreen: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { starGifts, } = global; diff --git a/src/components/modals/gift/GiftResaleFilters.tsx b/src/components/modals/gift/GiftResaleFilters.tsx index 3fdc34776..2fdd43c2c 100644 --- a/src/components/modals/gift/GiftResaleFilters.tsx +++ b/src/components/modals/gift/GiftResaleFilters.tsx @@ -641,7 +641,7 @@ const GiftResaleFilters: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { resaleGifts } = selectTabState(global); const attributes = resaleGifts.attributes; diff --git a/src/components/modals/gift/ResaleGiftMenuAttributeSticker.tsx b/src/components/modals/gift/ResaleGiftMenuAttributeSticker.tsx index 4dd6cf85e..ecaa99daa 100644 --- a/src/components/modals/gift/ResaleGiftMenuAttributeSticker.tsx +++ b/src/components/modals/gift/ResaleGiftMenuAttributeSticker.tsx @@ -62,7 +62,7 @@ const ResaleGiftMenuAttributeSticker: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { return { theme: selectTheme(global), }; diff --git a/src/components/modals/gift/StarGiftCategoryList.tsx b/src/components/modals/gift/StarGiftCategoryList.tsx index 45c8b2895..895c336a1 100644 --- a/src/components/modals/gift/StarGiftCategoryList.tsx +++ b/src/components/modals/gift/StarGiftCategoryList.tsx @@ -15,12 +15,12 @@ import StarIcon from '../../common/icons/StarIcon'; import styles from './StarGiftCategoryList.module.scss'; type OwnProps = { + areLimitedStarGiftsDisallowed?: boolean; onCategoryChanged: (category: StarGiftCategory) => void; }; type StateProps = { idsByCategory?: Record; - areLimitedStarGiftsDisallowed?: boolean; }; const StarGiftCategoryList = ({ @@ -91,7 +91,7 @@ const StarGiftCategoryList = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { starGifts } = global; return { diff --git a/src/components/modals/gift/UniqueGiftManageButtons.tsx b/src/components/modals/gift/UniqueGiftManageButtons.tsx index 878b91642..ca61072a9 100644 --- a/src/components/modals/gift/UniqueGiftManageButtons.tsx +++ b/src/components/modals/gift/UniqueGiftManageButtons.tsx @@ -198,7 +198,7 @@ const UniqueGiftManageButtons = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { currentUserId } = global; const currentUser = currentUserId ? selectUser(global, currentUserId) : undefined; const currentUserEmojiStatus = currentUser?.emojiStatus; diff --git a/src/components/modals/gift/info/GiftInfoModal.tsx b/src/components/modals/gift/info/GiftInfoModal.tsx index 90b40218f..8a792feae 100644 --- a/src/components/modals/gift/info/GiftInfoModal.tsx +++ b/src/components/modals/gift/info/GiftInfoModal.tsx @@ -994,7 +994,7 @@ const GiftInfoModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const typeGift = modal?.gift; const isSavedGift = typeGift && 'gift' in typeGift; const currentUserId = global.currentUserId; diff --git a/src/components/modals/gift/recipient/GiftRecipientPicker.tsx b/src/components/modals/gift/recipient/GiftRecipientPicker.tsx index 0974433a5..9f9a66291 100644 --- a/src/components/modals/gift/recipient/GiftRecipientPicker.tsx +++ b/src/components/modals/gift/recipient/GiftRecipientPicker.tsx @@ -78,7 +78,7 @@ const GiftRecipientPicker = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { currentUserId } = global; return { diff --git a/src/components/modals/gift/resale/GiftResalePriceComposerModal.tsx b/src/components/modals/gift/resale/GiftResalePriceComposerModal.tsx index 52eb46f4e..b38d9e897 100644 --- a/src/components/modals/gift/resale/GiftResalePriceComposerModal.tsx +++ b/src/components/modals/gift/resale/GiftResalePriceComposerModal.tsx @@ -175,7 +175,7 @@ const GiftResalePriceComposerModal = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const configPermille = global.appConfig.starsStargiftResaleCommissionPermille; const starsStargiftResaleCommissionPermille = configPermille ? (configPermille / 1000) : undefined; const starsStargiftResaleAmountMin = global.appConfig.starsStargiftResaleAmountMin || 0; diff --git a/src/components/modals/gift/status/GiftStatusInfoModal.tsx b/src/components/modals/gift/status/GiftStatusInfoModal.tsx index 3cc28ae33..5d3751fb5 100644 --- a/src/components/modals/gift/status/GiftStatusInfoModal.tsx +++ b/src/components/modals/gift/status/GiftStatusInfoModal.tsx @@ -160,7 +160,7 @@ const GiftStatusInfoModal = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentUser = selectUser(global, global.currentUserId!)!; const isCurrentUserPremium = selectIsCurrentUserPremium(global); diff --git a/src/components/modals/gift/transfer/GiftTransferModal.tsx b/src/components/modals/gift/transfer/GiftTransferModal.tsx index 574039030..de8cac85b 100644 --- a/src/components/modals/gift/transfer/GiftTransferModal.tsx +++ b/src/components/modals/gift/transfer/GiftTransferModal.tsx @@ -197,7 +197,7 @@ const GiftTransferModal = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { contactList, currentUserId } = global; return { diff --git a/src/components/modals/gift/upgrade/GiftUpgradeModal.tsx b/src/components/modals/gift/upgrade/GiftUpgradeModal.tsx index 9ef007833..e829ad7f7 100644 --- a/src/components/modals/gift/upgrade/GiftUpgradeModal.tsx +++ b/src/components/modals/gift/upgrade/GiftUpgradeModal.tsx @@ -175,7 +175,7 @@ const GiftUpgradeModal = ({ modal, recipient }: OwnProps & StateProps) => { }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const recipientId = modal?.recipientId; const recipient = recipientId ? selectPeer(global, recipientId) : undefined; diff --git a/src/components/modals/gift/withdraw/GiftWithdrawModal.tsx b/src/components/modals/gift/withdraw/GiftWithdrawModal.tsx index 429ac7df5..378f56061 100644 --- a/src/components/modals/gift/withdraw/GiftWithdrawModal.tsx +++ b/src/components/modals/gift/withdraw/GiftWithdrawModal.tsx @@ -157,7 +157,7 @@ const GiftWithdrawModal = ({ modal, hasPassword, passwordHint }: OwnProps & Stat }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { settings: { byKey: { diff --git a/src/components/modals/giftcode/GiftCodeModal.tsx b/src/components/modals/giftcode/GiftCodeModal.tsx index fc49ff83e..96e387f47 100644 --- a/src/components/modals/giftcode/GiftCodeModal.tsx +++ b/src/components/modals/giftcode/GiftCodeModal.tsx @@ -134,7 +134,7 @@ const GiftCodeModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const { message } = modal || {}; const chatMessage = message && selectChatMessage(global, message.chatId, message.messageId); const sender = chatMessage && selectSender(global, chatMessage); diff --git a/src/components/modals/inviteViaLink/InviteViaLinkModal.tsx b/src/components/modals/inviteViaLink/InviteViaLinkModal.tsx index b7a01d6f9..59e883a22 100644 --- a/src/components/modals/inviteViaLink/InviteViaLinkModal.tsx +++ b/src/components/modals/inviteViaLink/InviteViaLinkModal.tsx @@ -197,7 +197,7 @@ const InviteViaLinkModal: FC = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const chat = modal?.chatId ? selectChat(global, modal.chatId) : undefined; return { diff --git a/src/components/modals/locationAccess/LocationAccessModal.tsx b/src/components/modals/locationAccess/LocationAccessModal.tsx index d74543b31..50a56b947 100644 --- a/src/components/modals/locationAccess/LocationAccessModal.tsx +++ b/src/components/modals/locationAccess/LocationAccessModal.tsx @@ -157,7 +157,7 @@ const LocationAccessModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentUser = selectUser(global, global.currentUserId!); return { diff --git a/src/components/modals/paidReaction/PaidReactionModal.tsx b/src/components/modals/paidReaction/PaidReactionModal.tsx index dd29a0411..d000443bd 100644 --- a/src/components/modals/paidReaction/PaidReactionModal.tsx +++ b/src/components/modals/paidReaction/PaidReactionModal.tsx @@ -372,7 +372,7 @@ const PaidReactionModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const chat = modal && selectChat(global, modal.chatId); const message = modal && selectChatMessage(global, modal.chatId, modal.messageId); const starBalance = global.stars?.balance; diff --git a/src/components/modals/priceConfirm/PriceConfirmModal.tsx b/src/components/modals/priceConfirm/PriceConfirmModal.tsx index e6703ed86..90025c731 100644 --- a/src/components/modals/priceConfirm/PriceConfirmModal.tsx +++ b/src/components/modals/priceConfirm/PriceConfirmModal.tsx @@ -110,7 +110,7 @@ const PriceConfirmModal: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const starBalance = global.stars?.balance; const tonBalance = global.ton?.balance?.amount; diff --git a/src/components/modals/profileRating/ProfileRatingModal.tsx b/src/components/modals/profileRating/ProfileRatingModal.tsx index c9334b552..7d852a55c 100644 --- a/src/components/modals/profileRating/ProfileRatingModal.tsx +++ b/src/components/modals/profileRating/ProfileRatingModal.tsx @@ -239,7 +239,7 @@ const ProfileRatingModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const currentUserId = global.currentUserId; const user = modal?.userId ? selectUser(global, modal.userId) : undefined; const userFullInfo = modal?.userId diff --git a/src/components/modals/sharePreparedMessage/SharePreparedMessageModal.tsx b/src/components/modals/sharePreparedMessage/SharePreparedMessageModal.tsx index 56b4ecdf8..9b0822574 100644 --- a/src/components/modals/sharePreparedMessage/SharePreparedMessageModal.tsx +++ b/src/components/modals/sharePreparedMessage/SharePreparedMessageModal.tsx @@ -171,7 +171,7 @@ const SharePreparedMessageModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const { isPaymentMessageConfirmDialogOpen } = tabState; const starsBalance = global.stars?.balance.amount || 0; diff --git a/src/components/modals/stars/StarsBalanceModal.tsx b/src/components/modals/stars/StarsBalanceModal.tsx index 798321b6d..d2fb56e23 100644 --- a/src/components/modals/stars/StarsBalanceModal.tsx +++ b/src/components/modals/stars/StarsBalanceModal.tsx @@ -407,7 +407,7 @@ const StarsBalanceModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const shouldForceHeight = modal?.currency === TON_CURRENCY_CODE ? Boolean(global.ton?.history?.all?.transactions.length) : Boolean(global.stars?.history?.all?.transactions.length); diff --git a/src/components/modals/stars/StarsPaymentModal.tsx b/src/components/modals/stars/StarsPaymentModal.tsx index e05a74bf3..f8f8ded79 100644 --- a/src/components/modals/stars/StarsPaymentModal.tsx +++ b/src/components/modals/stars/StarsPaymentModal.tsx @@ -215,7 +215,7 @@ const StarPaymentModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const bot = modal?.form?.botId ? selectUser(global, modal.form.botId) : undefined; const messageInputInvoice = modal?.inputInvoice?.type === 'message' ? modal.inputInvoice : undefined; diff --git a/src/components/modals/stars/chatRefund/ChatRefundModal.tsx b/src/components/modals/stars/chatRefund/ChatRefundModal.tsx index f126084a1..77d987205 100644 --- a/src/components/modals/stars/chatRefund/ChatRefundModal.tsx +++ b/src/components/modals/stars/chatRefund/ChatRefundModal.tsx @@ -77,7 +77,7 @@ const ChatRefundModal = ({ modal, user }: OwnProps & StateProps) => { ); }; -export default memo(withGlobal((global, { modal }): StateProps => { +export default memo(withGlobal((global, { modal }): Complete => { const user = modal?.userId ? selectUser(global, modal.userId) : undefined; return { diff --git a/src/components/modals/stars/gift/StarsGiftModal.tsx b/src/components/modals/stars/gift/StarsGiftModal.tsx index 07dbf62c0..9aa063997 100644 --- a/src/components/modals/stars/gift/StarsGiftModal.tsx +++ b/src/components/modals/stars/gift/StarsGiftModal.tsx @@ -212,7 +212,7 @@ const StarsGiftModal: FC = ({ ); }; -export default memo(withGlobal((global, { modal }): StateProps => { +export default memo(withGlobal((global, { modal }): Complete => { const user = modal?.forUserId ? selectUser(global, modal.forUserId) : undefined; return { diff --git a/src/components/modals/stars/subscription/StarsSubscriptionModal.tsx b/src/components/modals/stars/subscription/StarsSubscriptionModal.tsx index fe47b2d4d..025a19521 100644 --- a/src/components/modals/stars/subscription/StarsSubscriptionModal.tsx +++ b/src/components/modals/stars/subscription/StarsSubscriptionModal.tsx @@ -255,7 +255,7 @@ const StarsSubscriptionModal: FC = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const peerId = modal?.subscription.peerId; const peer = peerId ? selectPeer(global, peerId) : undefined; diff --git a/src/components/modals/stars/transaction/StarsTransactionModal.tsx b/src/components/modals/stars/transaction/StarsTransactionModal.tsx index b4177dc0d..e4bd655b9 100644 --- a/src/components/modals/stars/transaction/StarsTransactionModal.tsx +++ b/src/components/modals/stars/transaction/StarsTransactionModal.tsx @@ -342,7 +342,7 @@ const StarsTransactionModal: FC = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const peerId = modal?.transaction?.peer?.type === 'peer' && modal.transaction.peer.id; const peer = peerId ? selectPeer(global, peerId) : undefined; const paidMessageCommission = global.appConfig.starsPaidMessageCommissionPermille; diff --git a/src/components/modals/suggestMessage/SuggestMessageModal.tsx b/src/components/modals/suggestMessage/SuggestMessageModal.tsx index 1ed18b825..e02e54e7a 100644 --- a/src/components/modals/suggestMessage/SuggestMessageModal.tsx +++ b/src/components/modals/suggestMessage/SuggestMessageModal.tsx @@ -300,7 +300,7 @@ const SuggestMessageModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const starBalance = global.stars?.balance; const peer = modal ? selectPeer(global, modal.chatId) : undefined; const currentDraft = modal ? selectDraft(global, modal.chatId, MAIN_THREAD_ID) : undefined; diff --git a/src/components/modals/suggestedPostApproval/SuggestedPostApprovalModal.tsx b/src/components/modals/suggestedPostApproval/SuggestedPostApprovalModal.tsx index a71a821cd..328ad6473 100644 --- a/src/components/modals/suggestedPostApproval/SuggestedPostApprovalModal.tsx +++ b/src/components/modals/suggestedPostApproval/SuggestedPostApprovalModal.tsx @@ -216,7 +216,7 @@ const SuggestedPostApprovalModal = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const message = modal && selectChatMessage(global, modal.chatId, modal.messageId); const sender = message ? selectSender(global, message) : undefined; const isAdmin = modal && selectIsMonoforumAdmin(global, modal.chatId); diff --git a/src/components/modals/suggestedStatus/SuggestedStatusModal.tsx b/src/components/modals/suggestedStatus/SuggestedStatusModal.tsx index 0d6c08ba3..fb89c5146 100644 --- a/src/components/modals/suggestedStatus/SuggestedStatusModal.tsx +++ b/src/components/modals/suggestedStatus/SuggestedStatusModal.tsx @@ -134,7 +134,7 @@ const SuggestedStatusModal = ({ modal, currentUser, bot }: OwnProps & StateProps }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const currentUser = selectUser(global, global.currentUserId!); const bot = modal?.botId ? selectUser(global, modal.botId) : undefined; diff --git a/src/components/modals/urlAuth/UrlAuthModal.tsx b/src/components/modals/urlAuth/UrlAuthModal.tsx index 7fb89a2ee..baa3b15a5 100644 --- a/src/components/modals/urlAuth/UrlAuthModal.tsx +++ b/src/components/modals/urlAuth/UrlAuthModal.tsx @@ -113,7 +113,7 @@ const UrlAuthModal: FC = ({ ); }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentUser = selectUser(global, global.currentUserId!); return { currentUser, diff --git a/src/components/modals/webApp/MinimizedWebAppModal.tsx b/src/components/modals/webApp/MinimizedWebAppModal.tsx index 5e7ebbb70..5ef531cac 100644 --- a/src/components/modals/webApp/MinimizedWebAppModal.tsx +++ b/src/components/modals/webApp/MinimizedWebAppModal.tsx @@ -121,7 +121,7 @@ const MinimizedWebAppModal = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const webApps = tabState.webApps; diff --git a/src/components/modals/webApp/MoreAppsTabContent.tsx b/src/components/modals/webApp/MoreAppsTabContent.tsx index 3409c5869..57067a160 100644 --- a/src/components/modals/webApp/MoreAppsTabContent.tsx +++ b/src/components/modals/webApp/MoreAppsTabContent.tsx @@ -127,7 +127,7 @@ const MoreAppsTabContent: FC = ({ ); }; -export default memo(withGlobal((global) => { +export default memo(withGlobal((global): Complete => { const globalSearch = selectTabState(global).globalSearch; const foundIds = globalSearch.popularBotApps?.peerIds; diff --git a/src/components/modals/webApp/WebAppGridItem.tsx b/src/components/modals/webApp/WebAppGridItem.tsx index eddaf61d8..d448f2dde 100644 --- a/src/components/modals/webApp/WebAppGridItem.tsx +++ b/src/components/modals/webApp/WebAppGridItem.tsx @@ -78,7 +78,7 @@ function WebAppGridItem({ user, isPopularApp }: OwnProps & StateProps) { } export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const user = selectUser(global, chatId); return { diff --git a/src/components/modals/webApp/WebAppModal.tsx b/src/components/modals/webApp/WebAppModal.tsx index 35fa97286..c907a8193 100644 --- a/src/components/modals/webApp/WebAppModal.tsx +++ b/src/components/modals/webApp/WebAppModal.tsx @@ -719,7 +719,7 @@ const WebAppModal: FC = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const activeWebApp = modal?.activeWebAppKey ? selectWebApp(global, modal.activeWebAppKey) : undefined; const { botId: activeBotId } = activeWebApp || {}; diff --git a/src/components/modals/webApp/WebAppModalTabContent.tsx b/src/components/modals/webApp/WebAppModalTabContent.tsx index 369176154..aad6c5630 100644 --- a/src/components/modals/webApp/WebAppModalTabContent.tsx +++ b/src/components/modals/webApp/WebAppModalTabContent.tsx @@ -82,7 +82,6 @@ type StateProps = { theme?: ThemeKey; isPaymentModalOpen?: boolean; paymentStatus?: TabState['payment']['status']; - isPremium?: boolean; modalState?: WebAppModalStateType; botAppPermissions?: BotAppPermissions; }; @@ -1189,7 +1188,7 @@ const WebAppModalTabContent: FC = ({ }; export default memo(withGlobal( - (global, { modal }): StateProps => { + (global, { modal }): Complete => { const activeWebApp = modal?.activeWebAppKey ? selectWebApp(global, modal.activeWebAppKey) : undefined; const { botId: activeBotId } = activeWebApp || {}; const modalState = modal?.modalState; diff --git a/src/components/payment/PasswordConfirm.tsx b/src/components/payment/PasswordConfirm.tsx index 804646db1..726939892 100644 --- a/src/components/payment/PasswordConfirm.tsx +++ b/src/components/payment/PasswordConfirm.tsx @@ -67,7 +67,7 @@ const PasswordConfirm: FC = ({ ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { payment } = selectTabState(global); return { errorKey: payment.error?.messageKey, diff --git a/src/components/payment/PaymentModal.tsx b/src/components/payment/PaymentModal.tsx index 8f20c23d8..da11353d8 100644 --- a/src/components/payment/PaymentModal.tsx +++ b/src/components/payment/PaymentModal.tsx @@ -5,7 +5,7 @@ import { import { getActions, withGlobal } from '../../global'; import type { - ApiChat, ApiCountry, ApiInvoice, ApiLabeledPrice, ApiPaymentCredentials, ApiPaymentFormRegular, + ApiChat, ApiCountry, ApiInvoice, ApiLabeledPrice, ApiPaymentFormRegular, } from '../../api/types'; import type { TabState } from '../../global/types'; import type { FormState } from '../../hooks/reducers/usePaymentReducer'; @@ -59,7 +59,6 @@ type StateProps = { invoice?: ApiInvoice; form?: ApiPaymentFormRegular; error?: TabState['payment']['error']; - prices?: ApiLabeledPrice[]; isProviderError?: boolean; needCardholderName?: boolean; needCountry?: boolean; @@ -71,7 +70,6 @@ type StateProps = { requestId?: string; smartGlocalToken?: string; stripeId?: string; - savedCredentials?: ApiPaymentCredentials[]; passwordValidUntil?: number; isExtendedMedia?: boolean; isPaymentFormUrl?: boolean; @@ -99,7 +97,6 @@ const PaymentModal: FC = ({ requestId, smartGlocalToken, stripeId, - savedCredentials, passwordValidUntil, isExtendedMedia, isPaymentFormUrl, @@ -205,13 +202,13 @@ const PaymentModal: FC = ({ }, [form, paymentDispatch, countryList]); useEffect(() => { - if (savedCredentials?.length) { + if (form?.savedCredentials?.length) { paymentDispatch({ type: 'changeSavedCredentialId', - payload: savedCredentials[0].id, + payload: form.savedCredentials[0].id, }); } - }, [paymentDispatch, savedCredentials]); + }, [paymentDispatch, form?.savedCredentials]); const handleErrorModalClose = useCallback(() => { clearPaymentError(); @@ -297,7 +294,7 @@ const PaymentModal: FC = ({ hasShippingOptions={hasShippingOptions} tipAmount={paymentState.tipAmount} needAddress={Boolean(invoice?.isShippingAddressRequested)} - savedCredentials={savedCredentials} + savedCredentials={form!.savedCredentials} isTosAccepted={isTosAccepted} onAcceptTos={setIsTosAccepted} botName={botName} @@ -307,7 +304,7 @@ const PaymentModal: FC = ({ return ( @@ -316,7 +313,7 @@ const PaymentModal: FC = ({ return ( @@ -611,7 +608,7 @@ const PaymentModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { form, step, diff --git a/src/components/payment/ReceiptModal.tsx b/src/components/payment/ReceiptModal.tsx index 690613a55..4cf31e06f 100644 --- a/src/components/payment/ReceiptModal.tsx +++ b/src/components/payment/ReceiptModal.tsx @@ -94,7 +94,7 @@ const ReceiptModal: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { receipt } = selectTabState(global).payment; return { diff --git a/src/components/right/AddChatMembers.tsx b/src/components/right/AddChatMembers.tsx index 51d6c359d..69581fbea 100644 --- a/src/components/right/AddChatMembers.tsx +++ b/src/components/right/AddChatMembers.tsx @@ -157,7 +157,7 @@ const AddChatMembers: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const { userIds: localContactIds } = global.contactList || {}; const { newChatMembersProgress } = selectTabState(global); diff --git a/src/components/right/CreateTopic.tsx b/src/components/right/CreateTopic.tsx index 430a8e7aa..b890e4bf2 100644 --- a/src/components/right/CreateTopic.tsx +++ b/src/components/right/CreateTopic.tsx @@ -170,7 +170,7 @@ const CreateTopic: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { createTopicPanel } = selectTabState(global); return { chat: createTopicPanel?.chatId ? selectChat(global, createTopicPanel.chatId) : undefined, diff --git a/src/components/right/DeleteMemberModal.tsx b/src/components/right/DeleteMemberModal.tsx index e57ecf34e..ccc639b62 100644 --- a/src/components/right/DeleteMemberModal.tsx +++ b/src/components/right/DeleteMemberModal.tsx @@ -57,7 +57,7 @@ const DeleteMemberModal: FC = ({ }; export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const chat = selectCurrentChat(global); const user = userId && selectUser(global, userId); const contactName = user ? getUserFirstOrLastName(user) : undefined; diff --git a/src/components/right/EditTopic.tsx b/src/components/right/EditTopic.tsx index 87f3afee9..f69adb954 100644 --- a/src/components/right/EditTopic.tsx +++ b/src/components/right/EditTopic.tsx @@ -186,7 +186,7 @@ const EditTopic: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { editTopicPanel } = selectTabState(global); const chat = editTopicPanel?.chatId ? selectChat(global, editTopicPanel.chatId) : undefined; const topic = editTopicPanel?.chatId && editTopicPanel?.topicId diff --git a/src/components/right/GifSearch.tsx b/src/components/right/GifSearch.tsx index 9b8a8e2a1..05e78bbc4 100644 --- a/src/components/right/GifSearch.tsx +++ b/src/components/right/GifSearch.tsx @@ -165,7 +165,7 @@ const GifSearch: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentSearch = selectCurrentGifSearch(global); const { query, results } = currentSearch || {}; const { chatId, threadId } = selectCurrentMessageList(global) || {}; @@ -183,6 +183,7 @@ export default memo(withGlobal( query, results, chat, + chatFullInfo, isChatWithBot, isSavedMessages, canPostInChat, diff --git a/src/components/right/PollAnswerResults.tsx b/src/components/right/PollAnswerResults.tsx index feea9019a..00647bd9f 100644 --- a/src/components/right/PollAnswerResults.tsx +++ b/src/components/right/PollAnswerResults.tsx @@ -154,7 +154,7 @@ function getPercentage(value: number, total: number) { } export default memo(withGlobal( - (global, { answer }: OwnProps): StateProps => { + (global, { answer }: OwnProps): Complete => { const { voters, offsets } = selectTabState(global).pollResults; return { diff --git a/src/components/right/PollResults.tsx b/src/components/right/PollResults.tsx index 3e3ba03e6..9bf3bcbc2 100644 --- a/src/components/right/PollResults.tsx +++ b/src/components/right/PollResults.tsx @@ -79,17 +79,13 @@ const PollResults: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { pollResults: { chatId, messageId }, } = selectTabState(global); - if (!chatId || !messageId) { - return {}; - } - - const chat = selectChat(global, chatId); - const message = selectChatMessage(global, chatId, messageId); + const chat = chatId ? selectChat(global, chatId) : undefined; + const message = chatId && messageId ? selectChatMessage(global, chatId, messageId) : undefined; const poll = message && selectPollFromMessage(global, message); return { diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index 348dc3b53..adbc48bfe 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -1132,7 +1132,7 @@ function renderProfileInfo(profileId: string, isReady: boolean, isSavedDialog?: export default memo(withGlobal( (global, { chatId, threadId, isMobile, - }): StateProps => { + }): Complete => { const user = selectUser(global, chatId); const chat = selectChat(global, chatId); const chatFullInfo = selectChatFullInfo(global, chatId); @@ -1247,8 +1247,9 @@ export default memo(withGlobal( isSavedDialog, isSynced: global.isSynced, limitSimilarPeers: selectPremiumLimit(global, 'recommendedChannels'), - ...(hasMembersTab && members && { members, adminMembersById }), - ...(hasCommonChatsTab && user && { commonChatIds: commonChats?.ids }), + members: hasMembersTab ? members : undefined, + adminMembersById: hasMembersTab ? adminMembersById : undefined, + commonChatIds: commonChats?.ids, monoforumChannel, }; }, diff --git a/src/components/right/RightColumn.tsx b/src/components/right/RightColumn.tsx index 1c74e1294..60808b0af 100644 --- a/src/components/right/RightColumn.tsx +++ b/src/components/right/RightColumn.tsx @@ -51,7 +51,6 @@ type StateProps = { contentKey?: RightColumnContent; chatId?: string; threadId?: ThreadId; - isInsideTopic?: boolean; isChatSelected: boolean; animationLevel: AnimationLevel; shouldSkipHistoryAnimations?: boolean; @@ -421,7 +420,7 @@ const RightColumn: FC = ({ }; export default memo(withGlobal( - (global, { isMobile }): StateProps => { + (global, { isMobile }): Complete => { const { chatId, threadId } = selectCurrentMessageList(global) || {}; const areActiveChatsLoaded = selectAreActiveChatsLoaded(global); diff --git a/src/components/right/RightHeader.tsx b/src/components/right/RightHeader.tsx index 8e2d37a6b..7bd1c01c6 100644 --- a/src/components/right/RightHeader.tsx +++ b/src/components/right/RightHeader.tsx @@ -721,7 +721,7 @@ const RightHeader: FC = ({ export default withGlobal( (global, { chatId, isProfile, isManagement, threadId, - }): StateProps => { + }): Complete => { const tabState = selectTabState(global); const { query: stickerSearchQuery } = selectCurrentStickerSearch(global) || {}; const { query: gifSearchQuery } = selectCurrentGifSearch(global) || {}; diff --git a/src/components/right/StickerSearch.tsx b/src/components/right/StickerSearch.tsx index 16d574538..bdc748350 100644 --- a/src/components/right/StickerSearch.tsx +++ b/src/components/right/StickerSearch.tsx @@ -105,7 +105,7 @@ const StickerSearch: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const currentSearch = selectCurrentStickerSearch(global); const { query, resultIds } = currentSearch || {}; const { featured } = global.stickers; diff --git a/src/components/right/StickerSetResult.tsx b/src/components/right/StickerSetResult.tsx index 86dcec146..b6f76e242 100644 --- a/src/components/right/StickerSetResult.tsx +++ b/src/components/right/StickerSetResult.tsx @@ -121,7 +121,7 @@ const StickerSetResult: FC = ({ }; export default memo(withGlobal( - (global, { stickerSetId }): StateProps => { + (global, { stickerSetId }): Complete => { return { set: selectStickerSet(global, stickerSetId), shouldPlay: selectShouldLoopStickers(global), diff --git a/src/components/right/gifts/StarGiftCollectionList.tsx b/src/components/right/gifts/StarGiftCollectionList.tsx index ba0a77807..d7abcb4ec 100644 --- a/src/components/right/gifts/StarGiftCollectionList.tsx +++ b/src/components/right/gifts/StarGiftCollectionList.tsx @@ -76,7 +76,7 @@ const StarGiftCollectionList = ({ }; export default memo(withGlobal( - (global, { peerId }): StateProps => { + (global, { peerId }): Complete => { const { starGiftCollections } = global; const collections = starGiftCollections?.byPeerId?.[peerId]; const activeCollectionId = selectActiveGiftsCollectionId(global, peerId); diff --git a/src/components/right/management/JoinRequest.tsx b/src/components/right/management/JoinRequest.tsx index b8c5e5bef..629cd492a 100644 --- a/src/components/right/management/JoinRequest.tsx +++ b/src/components/right/management/JoinRequest.tsx @@ -27,7 +27,6 @@ type OwnProps = { type StateProps = { user?: ApiUser; - isSavedMessages?: boolean; }; const JoinRequest: FC = ({ @@ -90,7 +89,7 @@ const JoinRequest: FC = ({ }; export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const user = selectUser(global, userId); return { diff --git a/src/components/right/management/ManageBot.tsx b/src/components/right/management/ManageBot.tsx index d12b07313..c4bfef20a 100644 --- a/src/components/right/management/ManageBot.tsx +++ b/src/components/right/management/ManageBot.tsx @@ -5,7 +5,7 @@ import { } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; -import type { ApiBotInfo, ApiUser } from '../../../api/types'; +import type { ApiUser } from '../../../api/types'; import { ApiMediaFormat } from '../../../api/types'; import { ManagementProgress } from '../../../types'; @@ -46,10 +46,8 @@ type OwnProps = { type StateProps = { userId?: string; user?: ApiUser; - chatBot?: ApiBotInfo; currentBio?: string; progress?: ManagementProgress; - isMuted?: boolean; maxBioLength: number; }; @@ -59,10 +57,10 @@ const ManageBot: FC = ({ userId, user, progress, - onClose, currentBio, isActive, maxBioLength, + onClose, }) => { const { setBotInfo, @@ -249,7 +247,7 @@ const ManageBot: FC = ({ }; export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const user = selectBot(global, userId); const userFullInfo = selectUserFullInfo(global, userId); const { progress } = selectTabState(global).management; diff --git a/src/components/right/management/ManageChannel.tsx b/src/components/right/management/ManageChannel.tsx index d25ba3790..07b34d9da 100644 --- a/src/components/right/management/ManageChannel.tsx +++ b/src/components/right/management/ManageChannel.tsx @@ -378,7 +378,7 @@ const ManageChannel: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId)!; const { management } = selectTabState(global); const { progress } = management; diff --git a/src/components/right/management/ManageChatAdministrators.tsx b/src/components/right/management/ManageChatAdministrators.tsx index 215d0b9f1..158b15233 100644 --- a/src/components/right/management/ManageChatAdministrators.tsx +++ b/src/components/right/management/ManageChatAdministrators.tsx @@ -185,7 +185,7 @@ const ManageChatAdministrators: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); return { chat, diff --git a/src/components/right/management/ManageChatPrivacyType.tsx b/src/components/right/management/ManageChatPrivacyType.tsx index 53da4e7f2..9a58f1124 100644 --- a/src/components/right/management/ManageChatPrivacyType.tsx +++ b/src/components/right/management/ManageChatPrivacyType.tsx @@ -300,7 +300,7 @@ const ManageChatPrivacyType: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId)!; const { isUsernameAvailable, checkedUsername, error } = selectManagement(global, chatId); diff --git a/src/components/right/management/ManageChatRemovedUsers.tsx b/src/components/right/management/ManageChatRemovedUsers.tsx index 085db260d..72d860ce7 100644 --- a/src/components/right/management/ManageChatRemovedUsers.tsx +++ b/src/components/right/management/ManageChatRemovedUsers.tsx @@ -124,7 +124,7 @@ const ManageChatRemovedUsers: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const { byId: usersById } = global.users; const canDeleteMembers = chat && (getHasAdminRight(chat, 'banUsers') || chat.isCreator); diff --git a/src/components/right/management/ManageDiscussion.tsx b/src/components/right/management/ManageDiscussion.tsx index 29f811b0a..dc8a22aca 100644 --- a/src/components/right/management/ManageDiscussion.tsx +++ b/src/components/right/management/ManageDiscussion.tsx @@ -294,7 +294,7 @@ const ManageDiscussion: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const { linkedChatId } = selectChatFullInfo(global, chatId) || {}; const { forDiscussionIds, byId: chatsByIds } = global.chats; diff --git a/src/components/right/management/ManageGroup.tsx b/src/components/right/management/ManageGroup.tsx index 61a8d8713..062b150c8 100644 --- a/src/components/right/management/ManageGroup.tsx +++ b/src/components/right/management/ManageGroup.tsx @@ -493,7 +493,7 @@ const ManageGroup: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId)!; const chatFullInfo = selectChatFullInfo(global, chatId); const { management, limitReachedModal } = selectTabState(global); diff --git a/src/components/right/management/ManageGroupAdminRights.tsx b/src/components/right/management/ManageGroupAdminRights.tsx index e5ddc74e0..999b73ad2 100644 --- a/src/components/right/management/ManageGroupAdminRights.tsx +++ b/src/components/right/management/ManageGroupAdminRights.tsx @@ -424,7 +424,7 @@ const ManageGroupAdminRights: FC = ({ }; export default memo(withGlobal( - (global, { chatId, isPromotedByCurrentUser }): StateProps => { + (global, { chatId, isPromotedByCurrentUser }): Complete => { const chat = selectChat(global, chatId)!; const fullInfo = selectChatFullInfo(global, chatId); const { byId: usersById } = global.users; diff --git a/src/components/right/management/ManageGroupMembers.tsx b/src/components/right/management/ManageGroupMembers.tsx index e472a151e..6ea43d470 100644 --- a/src/components/right/management/ManageGroupMembers.tsx +++ b/src/components/right/management/ManageGroupMembers.tsx @@ -274,7 +274,7 @@ const ManageGroupMembers: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const { statusesById: userStatusesById } = global.users; const { members, adminMembersById, areParticipantsHidden } = selectChatFullInfo(global, chatId) || {}; diff --git a/src/components/right/management/ManageGroupPermissions.tsx b/src/components/right/management/ManageGroupPermissions.tsx index 2a2e30fd9..98e75da93 100644 --- a/src/components/right/management/ManageGroupPermissions.tsx +++ b/src/components/right/management/ManageGroupPermissions.tsx @@ -352,7 +352,7 @@ const ManageGroupPermissions: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const fullInfo = selectChatFullInfo(global, chatId); const { progress } = selectTabState(global).management; diff --git a/src/components/right/management/ManageGroupUserPermissions.tsx b/src/components/right/management/ManageGroupUserPermissions.tsx index 8ce894804..4ee6ba45d 100644 --- a/src/components/right/management/ManageGroupUserPermissions.tsx +++ b/src/components/right/management/ManageGroupUserPermissions.tsx @@ -198,7 +198,7 @@ const ManageGroupUserPermissions: FC = ({ }; export default memo(withGlobal( - (global, { chatId, isPromotedByCurrentUser }): StateProps => { + (global, { chatId, isPromotedByCurrentUser }): Complete => { const chat = selectChat(global, chatId)!; const fullInfo = selectChatFullInfo(global, chatId); const isFormFullyDisabled = !(chat.isCreator || isPromotedByCurrentUser); diff --git a/src/components/right/management/ManageGroupUserPermissionsCreate.tsx b/src/components/right/management/ManageGroupUserPermissionsCreate.tsx index aabe42ef3..b3a6f90e4 100644 --- a/src/components/right/management/ManageGroupUserPermissionsCreate.tsx +++ b/src/components/right/management/ManageGroupUserPermissionsCreate.tsx @@ -91,7 +91,7 @@ const ManageGroupUserPermissionsCreate: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); const { byId: usersById, statusesById: userStatusesById } = global.users; const members = selectChatFullInfo(global, chatId)?.members; diff --git a/src/components/right/management/ManageInvite.tsx b/src/components/right/management/ManageInvite.tsx index 433e67d6e..96013654b 100644 --- a/src/components/right/management/ManageInvite.tsx +++ b/src/components/right/management/ManageInvite.tsx @@ -269,7 +269,7 @@ const ManageInvite: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { editingInvite } = selectTabState(global).management.byChatId[chatId] || {}; return { diff --git a/src/components/right/management/ManageInviteInfo.tsx b/src/components/right/management/ManageInviteInfo.tsx index 45390b258..c855533ce 100644 --- a/src/components/right/management/ManageInviteInfo.tsx +++ b/src/components/right/management/ManageInviteInfo.tsx @@ -2,7 +2,7 @@ import type { FC } from '../../../lib/teact/teact'; import { memo, useEffect } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; -import type { ApiChatInviteImporter, ApiExportedInvite, ApiUser } from '../../../api/types'; +import type { ApiChatInviteImporter, ApiExportedInvite } from '../../../api/types'; import { isChatChannel } from '../../../global/helpers'; import { selectChat, selectTabState } from '../../../global/selectors'; @@ -27,7 +27,6 @@ type StateProps = { invite?: ApiExportedInvite; importers?: ApiChatInviteImporter[]; requesters?: ApiChatInviteImporter[]; - admin?: ApiUser; isChannel?: boolean; }; @@ -169,7 +168,7 @@ const ManageInviteInfo: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { inviteInfo } = selectTabState(global).management.byChatId[chatId] || {}; const { invite, importers, requesters } = inviteInfo || {}; const chat = selectChat(global, chatId); diff --git a/src/components/right/management/ManageInvites.tsx b/src/components/right/management/ManageInvites.tsx index d8c98b85f..b9216cda5 100644 --- a/src/components/right/management/ManageInvites.tsx +++ b/src/components/right/management/ManageInvites.tsx @@ -378,7 +378,7 @@ const ManageInvites: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { invites, revokedInvites } = selectTabState(global).management.byChatId[chatId] || {}; const chat = selectChat(global, chatId); const isChannel = chat && isChatChannel(chat); diff --git a/src/components/right/management/ManageJoinRequests.tsx b/src/components/right/management/ManageJoinRequests.tsx index 16b5d765d..753723345 100644 --- a/src/components/right/management/ManageJoinRequests.tsx +++ b/src/components/right/management/ManageJoinRequests.tsx @@ -125,7 +125,7 @@ const ManageJoinRequests: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId); return { diff --git a/src/components/right/management/ManageReactions.tsx b/src/components/right/management/ManageReactions.tsx index caec239b0..c7c6c0f52 100644 --- a/src/components/right/management/ManageReactions.tsx +++ b/src/components/right/management/ManageReactions.tsx @@ -266,7 +266,7 @@ const ManageReactions: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const chat = selectChat(global, chatId)!; const { maxUniqueReactions } = global.appConfig; diff --git a/src/components/right/management/ManageUser.tsx b/src/components/right/management/ManageUser.tsx index c44c7a665..5e9bb2ea9 100644 --- a/src/components/right/management/ManageUser.tsx +++ b/src/components/right/management/ManageUser.tsx @@ -300,7 +300,7 @@ const ManageUser: FC = ({ }; export default memo(withGlobal( - (global, { userId }): StateProps => { + (global, { userId }): Complete => { const user = selectUser(global, userId); const chat = selectChat(global, userId); const userFullInfo = selectUserFullInfo(global, userId); diff --git a/src/components/right/management/Management.tsx b/src/components/right/management/Management.tsx index eeeb25214..aae536975 100644 --- a/src/components/right/management/Management.tsx +++ b/src/components/right/management/Management.tsx @@ -296,7 +296,7 @@ const Management: FC = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const managementType = selectCurrentManagementType(global); return { diff --git a/src/components/right/management/NewDiscussionGroup.tsx b/src/components/right/management/NewDiscussionGroup.tsx index 6b0339e9f..ab65db4f1 100644 --- a/src/components/right/management/NewDiscussionGroup.tsx +++ b/src/components/right/management/NewDiscussionGroup.tsx @@ -127,7 +127,7 @@ const NewDiscussionGroup: FC = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const { progress: creationProgress, error: creationError, diff --git a/src/components/right/management/RemoveGroupUserModal.tsx b/src/components/right/management/RemoveGroupUserModal.tsx index d6de20f77..b9a1d5540 100644 --- a/src/components/right/management/RemoveGroupUserModal.tsx +++ b/src/components/right/management/RemoveGroupUserModal.tsx @@ -76,7 +76,7 @@ const RemoveGroupUserModal: FC = ({ }; export default memo(withGlobal( - (global, { chat }): StateProps => { + (global, { chat }): Complete => { const { currentUserId } = global; return { diff --git a/src/components/right/statistics/BoostStatistics.tsx b/src/components/right/statistics/BoostStatistics.tsx index 66458b59c..0ae05bae1 100644 --- a/src/components/right/statistics/BoostStatistics.tsx +++ b/src/components/right/statistics/BoostStatistics.tsx @@ -422,7 +422,7 @@ const BoostStatistics = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const boostStatistics = tabState.boostStatistics; const isGiveawayAvailable = selectIsGiveawayGiftsPurchaseAvailable(global); diff --git a/src/components/right/statistics/MessageStatistics.tsx b/src/components/right/statistics/MessageStatistics.tsx index fa6d0459d..0042daf63 100644 --- a/src/components/right/statistics/MessageStatistics.tsx +++ b/src/components/right/statistics/MessageStatistics.tsx @@ -208,7 +208,7 @@ function MessageStatistics({ } export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const dcId = selectChatFullInfo(global, chatId)?.statisticsDcId; const tabState = selectTabState(global); const statistics = tabState.statistics.currentMessage; diff --git a/src/components/right/statistics/MonetizationStatistics.tsx b/src/components/right/statistics/MonetizationStatistics.tsx index a1eea8b46..22d8ee1b0 100644 --- a/src/components/right/statistics/MonetizationStatistics.tsx +++ b/src/components/right/statistics/MonetizationStatistics.tsx @@ -283,7 +283,7 @@ const MonetizationStatistics = ({ }; export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const tabState = selectTabState(global); const { settings: { diff --git a/src/components/right/statistics/Statistics.tsx b/src/components/right/statistics/Statistics.tsx index 1425d034f..ec46ff81c 100644 --- a/src/components/right/statistics/Statistics.tsx +++ b/src/components/right/statistics/Statistics.tsx @@ -258,7 +258,7 @@ const Statistics = ({ }; export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const statistics = selectStatistics(global, chatId); const chat = selectChat(global, chatId); const dcId = selectChatFullInfo(global, chatId)?.statisticsDcId; diff --git a/src/components/right/statistics/StoryStatistics.tsx b/src/components/right/statistics/StoryStatistics.tsx index 9c480ae3b..11da4cbad 100644 --- a/src/components/right/statistics/StoryStatistics.tsx +++ b/src/components/right/statistics/StoryStatistics.tsx @@ -226,7 +226,7 @@ function StoryStatistics({ } export default memo(withGlobal( - (global, { chatId }): StateProps => { + (global, { chatId }): Complete => { const dcId = selectChatFullInfo(global, chatId)?.statisticsDcId; const tabState = selectTabState(global); const statistics = tabState.statistics.currentStory; diff --git a/src/components/right/stories/StoryAlbumList.tsx b/src/components/right/stories/StoryAlbumList.tsx index 342db263f..7f871f8b0 100644 --- a/src/components/right/stories/StoryAlbumList.tsx +++ b/src/components/right/stories/StoryAlbumList.tsx @@ -76,7 +76,7 @@ const StoryAlbumList = ({ }; export default memo(withGlobal( - (global, { peerId }): StateProps => { + (global, { peerId }): Complete => { const { stories } = global; const albums = stories?.albumsByPeerId?.[peerId]; const selectedAlbumId = selectActiveStoriesCollectionId(global); diff --git a/src/components/story/MediaStory.tsx b/src/components/story/MediaStory.tsx index a8123e56c..023037c1a 100644 --- a/src/components/story/MediaStory.tsx +++ b/src/components/story/MediaStory.tsx @@ -186,7 +186,7 @@ function MediaStory({ ); } -export default memo(withGlobal((global, { story }): StateProps => { +export default memo(withGlobal((global, { story }): Complete => { const chat = selectChat(global, story.peerId); const isProtected = chat?.isProtected; diff --git a/src/components/story/StealthModeModal.tsx b/src/components/story/StealthModeModal.tsx index 29255b9c2..9fd3c4594 100644 --- a/src/components/story/StealthModeModal.tsx +++ b/src/components/story/StealthModeModal.tsx @@ -124,7 +124,7 @@ const StealthModeModal = ({ isOpen, stealthMode, isCurrentUserPremium }: StatePr ); }; -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const tabState = selectTabState(global); return { diff --git a/src/components/story/Story.tsx b/src/components/story/Story.tsx index c1c4da1c6..f739d1e81 100644 --- a/src/components/story/Story.tsx +++ b/src/components/story/Story.tsx @@ -930,7 +930,7 @@ export default memo(withGlobal((global, { peerId, storyId, isDeleteModalOpen, -}): StateProps => { +}): Complete => { const { appConfig } = global; const user = selectUser(global, peerId); const chat = selectChat(global, peerId); diff --git a/src/components/story/StoryPreview.tsx b/src/components/story/StoryPreview.tsx index 8e5194b40..ccc6f26e0 100644 --- a/src/components/story/StoryPreview.tsx +++ b/src/components/story/StoryPreview.tsx @@ -94,7 +94,7 @@ function StoryPreview({ ); } -export default memo(withGlobal((global, { peer }): StateProps => { +export default memo(withGlobal((global, { peer }): Complete => { const { storyViewer: { lastViewedByPeerId: lastViewedByPeerIds, diff --git a/src/components/story/StoryRibbon.tsx b/src/components/story/StoryRibbon.tsx index 2b5f56132..d06c5365a 100644 --- a/src/components/story/StoryRibbon.tsx +++ b/src/components/story/StoryRibbon.tsx @@ -73,7 +73,7 @@ function StoryRibbon({ } export default memo(withGlobal( - (global, { isArchived }): StateProps => { + (global, { isArchived }): Complete => { const { orderedPeerIds: { active, archived } } = global.stories; const usersById = global.users.byId; const chatsById = global.chats.byId; diff --git a/src/components/story/StorySettings.tsx b/src/components/story/StorySettings.tsx index 407da3ca6..9ff747fd7 100644 --- a/src/components/story/StorySettings.tsx +++ b/src/components/story/StorySettings.tsx @@ -400,7 +400,7 @@ function StorySettings({ ); } -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { storyViewer: { storyId, peerId, diff --git a/src/components/story/StorySlides.tsx b/src/components/story/StorySlides.tsx index 0dde4efcd..91c1d5f1d 100644 --- a/src/components/story/StorySlides.tsx +++ b/src/components/story/StorySlides.tsx @@ -467,7 +467,7 @@ function StorySlides({ ); } -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { storyViewer: { peerId: currentPeerId, storyId: currentStoryId, isSinglePeer, isSingleStory, isPrivate, isArchive, storyList, diff --git a/src/components/story/StoryToggler.tsx b/src/components/story/StoryToggler.tsx index 13c9ead99..c6815e812 100644 --- a/src/components/story/StoryToggler.tsx +++ b/src/components/story/StoryToggler.tsx @@ -135,7 +135,7 @@ function StoryToggler({ ); } -export default memo(withGlobal((global, { isArchived }): StateProps => { +export default memo(withGlobal((global, { isArchived }): Complete => { const { orderedPeerIds: { archived, active }, byPeerId } = global.stories; const { storyViewer: { isRibbonShown, isArchivedRibbonShown } } = selectTabState(global); const isForumPanelOpen = selectIsForumPanelOpen(global); diff --git a/src/components/story/StoryViewModal.tsx b/src/components/story/StoryViewModal.tsx index 8b14826bc..42c80cad0 100644 --- a/src/components/story/StoryViewModal.tsx +++ b/src/components/story/StoryViewModal.tsx @@ -268,7 +268,7 @@ function prepareComparator(areReactionsFirst?: boolean) { }; } -export default memo(withGlobal((global) => { +export default memo(withGlobal((global): Complete => { const { appConfig } = global; const { storyViewer: { viewModal } } = selectTabState(global); const { @@ -278,13 +278,11 @@ export default memo(withGlobal((global) => { const storyExpireDate = story?.['@type'] === 'story' ? story.expireDate : undefined; return { - storyId, views, viewersExpireDate: storyExpireDate ? (storyExpireDate + appConfig.storyViewersExpirePeriod) : undefined, story: story && 'content' in story ? story : undefined, nextOffset, isLoading, - availableReactions: global.reactions.availableReactions, isCurrentUserPremium: selectIsCurrentUserPremium(global), }; })(StoryViewModal)); diff --git a/src/components/story/StoryViewer.tsx b/src/components/story/StoryViewer.tsx index c2e79930b..7a71b6a2c 100644 --- a/src/components/story/StoryViewer.tsx +++ b/src/components/story/StoryViewer.tsx @@ -181,7 +181,7 @@ function StoryViewer({ ); } -export default memo(withGlobal((global): StateProps => { +export default memo(withGlobal((global): Complete => { const { shouldSkipHistoryAnimations, storyViewer: { storyId, peerId, isPrivacyModalOpen, origin, diff --git a/src/components/story/mediaArea/MediaAreaWeather.tsx b/src/components/story/mediaArea/MediaAreaWeather.tsx index c0c3038b2..005ae1a12 100644 --- a/src/components/story/mediaArea/MediaAreaWeather.tsx +++ b/src/components/story/mediaArea/MediaAreaWeather.tsx @@ -107,7 +107,7 @@ const MediaAreaWeather: FC = ({ ); }; -export default memo(withGlobal((global, ownProps): StateProps => { +export default memo(withGlobal((global, ownProps): Complete => { const { mediaArea } = ownProps; const restrictedEmoji = selectRestrictedEmoji(global, mediaArea.emoji); return { restrictedEmoji }; diff --git a/src/components/test/ErrorTest.tsx b/src/components/test/ErrorTest.tsx index 5f062cedd..72209a163 100644 --- a/src/components/test/ErrorTest.tsx +++ b/src/components/test/ErrorTest.tsx @@ -37,7 +37,7 @@ const ErrorTest: FC = ({ parentRand, globalRand }) => { }; let firstRender = true; -export default withGlobal((): StateProps => { +export default withGlobal((): Complete => { const globalRand = Math.random(); if (firstRender || globalRand > 0.8) { diff --git a/src/components/test/Test.tsx b/src/components/test/Test.tsx index 557b6543a..64c10f891 100644 --- a/src/components/test/Test.tsx +++ b/src/components/test/Test.tsx @@ -38,7 +38,7 @@ const Test: FC = ({ authState, globalRand }) => { }; export default withGlobal( - (global): StateProps => { + (global): Complete => { return { authState: global.authState, globalRand: Math.random(), diff --git a/src/components/ui/ModalStarBalanceBar.tsx b/src/components/ui/ModalStarBalanceBar.tsx index 6fc81fa2f..0de63bdf3 100644 --- a/src/components/ui/ModalStarBalanceBar.tsx +++ b/src/components/ui/ModalStarBalanceBar.tsx @@ -111,7 +111,7 @@ function ModalStarBalanceBar({ } export default memo(withGlobal( - (global): StateProps => { + (global): Complete => { const { stars, ton, diff --git a/src/lib/teact/teactn.tsx b/src/lib/teact/teactn.tsx index a40d004db..f992119d8 100644 --- a/src/lib/teact/teactn.tsx +++ b/src/lib/teact/teactn.tsx @@ -342,6 +342,11 @@ export function typify< ) => ProjectGlobalState | void | Promise; }; + type WithGlobalFn = ( + mapStateToProps: (global: ProjectGlobalState, ownProps: OwnProps) => AnyLiteral, + activationFn?: (global: ProjectGlobalState, ownProps: OwnProps, stickToFirst: StickToFirstFn) => boolean, + ) => (Component: FC) => FC; + return { getGlobal: getUntypedGlobal as () => T, setGlobal: setUntypedGlobal as (state: ProjectGlobalState, options?: ActionOptions) => void, @@ -351,10 +356,7 @@ export function typify< name: ActionName, handler: ActionHandlers[ActionName], ) => void, - withGlobal: withUntypedGlobal as ( - mapStateToProps: (global: ProjectGlobalState, ownProps: OwnProps) => AnyLiteral, - activationFn?: (global: ProjectGlobalState, ownProps: OwnProps, stickToFirst: StickToFirstFn) => boolean, - ) => (Component: FC) => FC, + withGlobal: withUntypedGlobal as WithGlobalFn, }; }