From 76d10d721262b17dd34b5e36cc100147ca6d2382 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 14 Sep 2022 00:30:17 +0200 Subject: [PATCH] Avatar: Loop video 3 times and only with max animation level, refactoring (#2026) --- .../calls/group/GroupCallParticipant.tsx | 2 +- .../calls/group/GroupCallParticipantVideo.tsx | 2 +- .../calls/group/GroupCallTopPane.tsx | 8 +++-- src/components/calls/phone/PhoneCall.tsx | 6 ++++ src/components/common/Avatar.tsx | 33 ++++++++++++------- src/components/common/DeleteChatModal.tsx | 6 ++++ src/components/common/GroupChatInfo.tsx | 12 +++++-- src/components/common/PickerSelectedItem.tsx | 1 - src/components/common/PrivateChatInfo.tsx | 14 ++++++-- src/components/common/ProfileInfo.tsx | 3 +- src/components/left/main/Chat.tsx | 5 ++- src/components/left/main/LeftMainHeader.tsx | 4 +-- src/components/left/search/ChatMessage.tsx | 6 ++++ src/components/left/search/RecentContacts.tsx | 11 +++++-- .../left/settings/SettingsActiveWebsite.tsx | 11 +++++-- .../left/settings/SettingsActiveWebsites.tsx | 6 +++- .../settings/SettingsPrivacyBlockedUsers.tsx | 2 +- src/components/main/Dialogs.tsx | 13 ++++++-- src/components/main/Main.tsx | 4 +-- .../main/premium/GiftPremiumModal.tsx | 12 +++++-- src/components/mediaViewer/MediaViewer.tsx | 3 +- .../mediaViewer/MediaViewerContent.tsx | 3 +- .../mediaViewer/MediaViewerSlides.tsx | 4 +-- src/components/mediaViewer/SenderInfo.tsx | 12 +++++-- src/components/middle/MessageList.tsx | 3 +- src/components/middle/MiddleColumn.tsx | 4 +-- src/components/middle/ReactorListModal.tsx | 6 +++- src/components/middle/composer/BotCommand.tsx | 2 +- src/components/middle/composer/Composer.tsx | 1 - .../middle/composer/StickerPicker.tsx | 2 +- .../middle/message/CommentButton.tsx | 1 - src/components/middle/message/Contact.tsx | 7 ++-- src/components/middle/message/Message.tsx | 9 ++++- .../middle/message/MessageContextMenu.tsx | 1 - src/components/middle/message/Poll.tsx | 1 - .../middle/message/ReactionButton.tsx | 2 +- src/components/right/RightSearch.tsx | 10 ++++-- .../right/management/JoinRequest.tsx | 8 ++++- src/types/index.ts | 3 +- 39 files changed, 180 insertions(+), 63 deletions(-) diff --git a/src/components/calls/group/GroupCallParticipant.tsx b/src/components/calls/group/GroupCallParticipant.tsx index e5023ba7..d1b10c89 100644 --- a/src/components/calls/group/GroupCallParticipant.tsx +++ b/src/components/calls/group/GroupCallParticipant.tsx @@ -79,7 +79,7 @@ const GroupCallParticipant: FC = ({ onClick={handleOnClick} ref={anchorRef} > - +
{name} {aboutText} diff --git a/src/components/calls/group/GroupCallParticipantVideo.tsx b/src/components/calls/group/GroupCallParticipantVideo.tsx index 9443518c..8314c619 100644 --- a/src/components/calls/group/GroupCallParticipantVideo.tsx +++ b/src/components/calls/group/GroupCallParticipantVideo.tsx @@ -60,7 +60,7 @@ const GroupCallParticipantVideo: FC = ({ {lang('Back')} )} - + {ENABLE_THUMBNAIL_VIDEO && (
@@ -130,6 +133,7 @@ export default memo(withGlobal( isActive: ((!groupCall ? (chat && chat.isCallNotEmpty && chat.isCallActive) : (groupCall.participantsCount > 0 && groupCall.isLoaded))) && (global.groupCalls.activeGroupCallId !== groupCall?.id), + animationLevel: global.settings.byKey.animationLevel, }; }, )(GroupCallTopPane)); diff --git a/src/components/calls/phone/PhoneCall.tsx b/src/components/calls/phone/PhoneCall.tsx index b359e353..ee3f8e41 100644 --- a/src/components/calls/phone/PhoneCall.tsx +++ b/src/components/calls/phone/PhoneCall.tsx @@ -6,6 +6,7 @@ import { getActions, withGlobal } from '../../../global'; import '../../../global/actions/calls'; import type { ApiPhoneCall, ApiUser } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { IS_ANDROID, @@ -39,6 +40,7 @@ type StateProps = { phoneCall?: ApiPhoneCall; isOutgoing: boolean; isCallPanelVisible?: boolean; + animationLevel: AnimationLevel; }; const PhoneCall: FC = ({ @@ -46,6 +48,7 @@ const PhoneCall: FC = ({ isOutgoing, phoneCall, isCallPanelVisible, + animationLevel, }) => { const lang = useLang(); const { @@ -235,7 +238,9 @@ const PhoneCall: FC = ({ user={user} size="jumbo" className={hasVideo || hasPresentation ? styles.blurred : ''} + withVideo noLoop={phoneCall?.state !== 'requesting'} + animationLevel={animationLevel} /> {phoneCall?.screencastState === 'active' && streams?.presentation &&
@@ -236,6 +241,7 @@ export default memo(withGlobal( currentUserId: global.currentUserId, canDeleteForAll, contactName, + animationLevel: global.settings.byKey.animationLevel, }; }, )(DeleteChatModal)); diff --git a/src/components/common/GroupChatInfo.tsx b/src/components/common/GroupChatInfo.tsx index a32698f0..f64f4331 100644 --- a/src/components/common/GroupChatInfo.tsx +++ b/src/components/common/GroupChatInfo.tsx @@ -5,6 +5,7 @@ import { getActions, withGlobal } from '../../global'; import type { ApiChat, ApiTypingStatus } from '../../api/types'; import type { GlobalState } from '../../global/types'; +import type { AnimationLevel } from '../../types'; import { MediaViewerOrigin } from '../../types'; import { @@ -43,6 +44,7 @@ type StateProps = chat?: ApiChat; onlineCount?: number; areMessagesLoaded: boolean; + animationLevel: AnimationLevel; } & Pick; @@ -61,6 +63,7 @@ const GroupChatInfo: FC = ({ chat, onlineCount, areMessagesLoaded, + animationLevel, lastSyncTime, }) => { const { @@ -145,7 +148,8 @@ const GroupChatInfo: FC = ({ size={avatarSize} chat={chat} onClick={withMediaViewer ? handleAvatarViewerOpen : undefined} - noVideo={!withVideoAvatar} + withVideo={withVideoAvatar} + animationLevel={animationLevel} />
@@ -184,7 +188,11 @@ export default memo(withGlobal( const areMessagesLoaded = Boolean(selectChatMessages(global, chatId)); return { - lastSyncTime, chat, onlineCount, areMessagesLoaded, + lastSyncTime, + chat, + onlineCount, + areMessagesLoaded, + animationLevel: global.settings.byKey.animationLevel, }; }, )(GroupChatInfo)); diff --git a/src/components/common/PickerSelectedItem.tsx b/src/components/common/PickerSelectedItem.tsx index afc1932b..1ec4cb5e 100644 --- a/src/components/common/PickerSelectedItem.tsx +++ b/src/components/common/PickerSelectedItem.tsx @@ -61,7 +61,6 @@ const PickerSelectedItem: FC = ({ user={user} size="small" isSavedMessages={user?.isSelf} - noVideo /> ); diff --git a/src/components/common/PrivateChatInfo.tsx b/src/components/common/PrivateChatInfo.tsx index 03ffdd09..ad4ba7c5 100644 --- a/src/components/common/PrivateChatInfo.tsx +++ b/src/components/common/PrivateChatInfo.tsx @@ -5,6 +5,7 @@ import { getActions, withGlobal } from '../../global'; import type { ApiUser, ApiTypingStatus, ApiUserStatus } from '../../api/types'; import type { GlobalState } from '../../global/types'; +import type { AnimationLevel } from '../../types'; import { MediaViewerOrigin } from '../../types'; import { selectChatMessages, selectUser, selectUserStatus } from '../../global/selectors'; @@ -40,6 +41,7 @@ type StateProps = user?: ApiUser; userStatus?: ApiUserStatus; isSavedMessages?: boolean; + animationLevel: AnimationLevel; areMessagesLoaded: boolean; serverTimeOffset: number; } @@ -61,6 +63,7 @@ const PrivateChatInfo: FC = ({ userStatus, isSavedMessages, areMessagesLoaded, + animationLevel, lastSyncTime, serverTimeOffset, }) => { @@ -136,7 +139,8 @@ const PrivateChatInfo: FC = ({ user={user} isSavedMessages={isSavedMessages} onClick={withMediaViewer ? handleAvatarViewerOpen : undefined} - noVideo={!withVideoAvatar} + withVideo={withVideoAvatar} + animationLevel={animationLevel} />
{isSavedMessages ? ( @@ -166,7 +170,13 @@ export default memo(withGlobal( const areMessagesLoaded = Boolean(selectChatMessages(global, userId)); return { - lastSyncTime, user, userStatus, isSavedMessages, areMessagesLoaded, serverTimeOffset, + lastSyncTime, + user, + userStatus, + isSavedMessages, + areMessagesLoaded, + serverTimeOffset, + animationLevel: global.settings.byKey.animationLevel, }; }, )(PrivateChatInfo)); diff --git a/src/components/common/ProfileInfo.tsx b/src/components/common/ProfileInfo.tsx index 9a11e682..45967bbd 100644 --- a/src/components/common/ProfileInfo.tsx +++ b/src/components/common/ProfileInfo.tsx @@ -6,6 +6,7 @@ import { getActions, withGlobal } from '../../global'; import type { ApiUser, ApiChat, ApiUserStatus } from '../../api/types'; import type { GlobalState } from '../../global/types'; +import type { AnimationLevel } from '../../types'; import { MediaViewerOrigin } from '../../types'; import { IS_TOUCH_ENV } from '../../util/environment'; @@ -40,7 +41,7 @@ type StateProps = userStatus?: ApiUserStatus; chat?: ApiChat; isSavedMessages?: boolean; - animationLevel: 0 | 1 | 2; + animationLevel: AnimationLevel; serverTimeOffset: number; mediaId?: number; avatarOwnerId?: string; diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index db328cae..0e662005 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -9,6 +9,7 @@ import type { ObserveFn } from '../../../hooks/useIntersectionObserver'; import type { ApiChat, ApiUser, ApiMessage, ApiMessageOutgoingStatus, ApiFormattedText, ApiUserStatus, } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { MAIN_THREAD_ID } from '../../../api/types'; import { ANIMATION_END_DELAY } from '../../../config'; @@ -82,7 +83,7 @@ type StateProps = { lastMessageSender?: ApiUser; lastMessageOutgoingStatus?: ApiMessageOutgoingStatus; draft?: ApiFormattedText; - animationLevel?: number; + animationLevel?: AnimationLevel; isSelected?: boolean; canScrollDown?: boolean; canChangeFolder?: boolean; @@ -315,6 +316,8 @@ const Chat: FC = ({ userStatus={userStatus} isSavedMessages={user?.isSelf} lastSyncTime={lastSyncTime} + animationLevel={animationLevel} + withVideo observeIntersection={observeIntersection} /> {chat.isCallActive && chat.isCallNotEmpty && ( diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index 951157ab..95d6ff4d 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -4,7 +4,7 @@ import React, { } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; -import type { ISettings } from '../../../types'; +import type { AnimationLevel, ISettings } from '../../../types'; import { LeftColumnContent, SettingsScreens } from '../../../types'; import type { ApiChat } from '../../../api/types'; import type { GlobalState } from '../../../global/types'; @@ -63,7 +63,7 @@ type StateProps = globalSearchChatId?: string; searchDate?: number; theme: ISettings['theme']; - animationLevel: 0 | 1 | 2; + animationLevel: AnimationLevel; chatsById?: Record; isMessageListOpen: boolean; isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized']; diff --git a/src/components/left/search/ChatMessage.tsx b/src/components/left/search/ChatMessage.tsx index ede8dd56..7243df81 100644 --- a/src/components/left/search/ChatMessage.tsx +++ b/src/components/left/search/ChatMessage.tsx @@ -5,6 +5,7 @@ import { getActions, withGlobal } from '../../../global'; import type { ApiChat, ApiUser, ApiMessage, ApiMessageOutgoingStatus, } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { IS_SINGLE_COLUMN_LAYOUT } from '../../../util/environment'; import { @@ -47,6 +48,7 @@ type StateProps = { privateChatUser?: ApiUser; lastMessageOutgoingStatus?: ApiMessageOutgoingStatus; lastSyncTime?: number; + animationLevel?: AnimationLevel; }; const ChatMessage: FC = ({ @@ -55,6 +57,7 @@ const ChatMessage: FC = ({ chatId, chat, privateChatUser, + animationLevel, lastSyncTime, }) => { const { focusMessage } = getActions(); @@ -87,6 +90,8 @@ const ChatMessage: FC = ({ user={privateChatUser} isSavedMessages={privateChatUser?.isSelf} lastSyncTime={lastSyncTime} + withVideo + animationLevel={animationLevel} />
@@ -141,6 +146,7 @@ export default memo(withGlobal( return { chat, lastSyncTime: global.lastSyncTime, + animationLevel: global.settings.byKey.animationLevel, ...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }), }; }, diff --git a/src/components/left/search/RecentContacts.tsx b/src/components/left/search/RecentContacts.tsx index 4f035b17..7e781f58 100644 --- a/src/components/left/search/RecentContacts.tsx +++ b/src/components/left/search/RecentContacts.tsx @@ -5,6 +5,7 @@ import React, { import { getActions, withGlobal } from '../../../global'; import type { ApiUser } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { getUserFirstOrLastName } from '../../../global/helpers'; import renderText from '../../common/helpers/renderText'; @@ -26,6 +27,7 @@ type StateProps = { topUserIds?: string[]; usersById: Record; recentlyFoundChatIds?: string[]; + animationLevel: AnimationLevel; }; const SEARCH_CLOSE_TIMEOUT_MS = 250; @@ -34,7 +36,10 @@ const NBSP = '\u00A0'; const runThrottled = throttle((cb) => cb(), 60000, true); const RecentContacts: FC = ({ - topUserIds, usersById, recentlyFoundChatIds, + topUserIds, + usersById, + recentlyFoundChatIds, + animationLevel, onReset, }) => { const { @@ -72,7 +77,7 @@ const RecentContacts: FC = ({
{topUserIds.map((userId) => (
handleClick(userId)} dir={lang.isRtl ? 'rtl' : undefined}> - +
{renderText(getUserFirstOrLastName(usersById[userId]) || NBSP)}
))} @@ -112,11 +117,13 @@ export default memo(withGlobal( const { userIds: topUserIds } = global.topPeers; const usersById = global.users.byId; const { recentlyFoundChatIds } = global.globalSearch; + const { animationLevel } = global.settings.byKey; return { topUserIds, usersById, recentlyFoundChatIds, + animationLevel, }; }, )(RecentContacts)); diff --git a/src/components/left/settings/SettingsActiveWebsite.tsx b/src/components/left/settings/SettingsActiveWebsite.tsx index 1cd74c88..779e25b6 100644 --- a/src/components/left/settings/SettingsActiveWebsite.tsx +++ b/src/components/left/settings/SettingsActiveWebsite.tsx @@ -3,6 +3,7 @@ import { getActions, withGlobal } from '../../../global'; import type { FC } from '../../../lib/teact/teact'; import type { ApiUser, ApiWebSession } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { getUserFullName } from '../../../global/helpers'; import buildClassName from '../../../util/buildClassName'; @@ -25,10 +26,15 @@ type OwnProps = { type StateProps = { session?: ApiWebSession; bot?: ApiUser; + animationLevel: AnimationLevel; }; const SettingsActiveWebsite: FC = ({ - isOpen, session, bot, onClose, + isOpen, + session, + bot, + animationLevel, + onClose, }) => { const { terminateWebAuthorization } = getActions(); const lang = useLang(); @@ -70,7 +76,7 @@ const SettingsActiveWebsite: FC = ({ onClose={onClose} className={styles.root} > - +

{getUserFullName(renderingBot)}

{renderingSession?.domain} @@ -99,5 +105,6 @@ export default memo(withGlobal((global, { hash }) => { return { session, bot, + animationLevel: global.settings.byKey.animationLevel, }; })(SettingsActiveWebsite)); diff --git a/src/components/left/settings/SettingsActiveWebsites.tsx b/src/components/left/settings/SettingsActiveWebsites.tsx index 6356a9d1..adc2b3f1 100644 --- a/src/components/left/settings/SettingsActiveWebsites.tsx +++ b/src/components/left/settings/SettingsActiveWebsites.tsx @@ -5,6 +5,7 @@ import { getActions, getGlobal, withGlobal } from '../../../global'; import type { FC } from '../../../lib/teact/teact'; import type { ApiWebSession } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { formatPastTimeShort } from '../../../util/dateFormat'; import { getUserFullName } from '../../../global/helpers'; @@ -29,12 +30,14 @@ type OwnProps = { type StateProps = { byHash: Record; orderedHashes: string[]; + animationLevel: AnimationLevel; }; const SettingsActiveWebsites: FC = ({ isActive, byHash, orderedHashes, + animationLevel, onReset, }) => { const { @@ -110,7 +113,7 @@ const SettingsActiveWebsites: FC = ({ // eslint-disable-next-line react/jsx-no-bind onClick={() => handleOpenSessionModal(session.hash)} > - +
{formatPastTimeShort(lang, session.dateActive * 1000)} {getUserFullName(bot)} @@ -161,6 +164,7 @@ export default memo(withGlobal( return { byHash, orderedHashes, + animationLevel: global.settings.byKey.animationLevel, }; }, )(SettingsActiveWebsites)); diff --git a/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx b/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx index d8ba8297..49f2730b 100644 --- a/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx +++ b/src/components/left/settings/SettingsPrivacyBlockedUsers.tsx @@ -79,7 +79,7 @@ const SettingsPrivacyBlockedUsers: FC = ({ }]} style={`top: ${(viewportOffset + i) * CHAT_HEIGHT_PX}px;`} > - +

{renderText((isPrivate ? getUserFullName(user) : getChatTitle(lang, chat!)) || '')}

{user?.phoneNumber && ( diff --git a/src/components/main/Dialogs.tsx b/src/components/main/Dialogs.tsx index db395454..22e789f7 100644 --- a/src/components/main/Dialogs.tsx +++ b/src/components/main/Dialogs.tsx @@ -5,6 +5,7 @@ import { getActions, withGlobal } from '../../global'; import type { ApiContact, ApiError, ApiInviteInfo, ApiPhoto, } from '../../api/types'; +import type { AnimationLevel } from '../../types'; import getReadableErrorText from '../../util/getReadableErrorText'; import { pick } from '../../util/iteratees'; @@ -20,9 +21,10 @@ import './Dialogs.scss'; type StateProps = { dialogs: (ApiError | ApiInviteInfo)[]; + animationLevel: AnimationLevel; }; -const Dialogs: FC = ({ dialogs }) => { +const Dialogs: FC = ({ dialogs, animationLevel }) => { const { dismissDialog, acceptInviteConfirmation, @@ -46,7 +48,7 @@ const Dialogs: FC = ({ dialogs }) => { function renderInviteHeader(title: string, photo?: ApiPhoto) { return (
- {photo && } + {photo && }
{renderText(title)}
@@ -194,5 +196,10 @@ function getErrorHeader(error: ApiError) { } export default memo(withGlobal( - (global): StateProps => pick(global, ['dialogs']), + (global): StateProps => { + return { + dialogs: global.dialogs, + animationLevel: global.settings.byKey.animationLevel, + }; + }, )(Dialogs)); diff --git a/src/components/main/Main.tsx b/src/components/main/Main.tsx index 5c20fddc..16e1d02c 100644 --- a/src/components/main/Main.tsx +++ b/src/components/main/Main.tsx @@ -4,7 +4,7 @@ import React, { } from '../../lib/teact/teact'; import { getActions, getGlobal, withGlobal } from '../../global'; -import type { LangCode } from '../../types'; +import type { AnimationLevel, LangCode } from '../../types'; import type { ApiChat, ApiMessage, ApiUpdateAuthorizationStateType, ApiUpdateConnectionStateType, ApiUser, } from '../../api/types'; @@ -94,7 +94,7 @@ type StateProps = { openedCustomEmojiSetIds?: string[]; activeGroupCallId?: string; isServiceChatReady?: boolean; - animationLevel: number; + animationLevel: AnimationLevel; language?: LangCode; wasTimeFormatSetManually?: boolean; isPhoneCallActive?: boolean; diff --git a/src/components/main/premium/GiftPremiumModal.tsx b/src/components/main/premium/GiftPremiumModal.tsx index d4f96c77..779d36d9 100644 --- a/src/components/main/premium/GiftPremiumModal.tsx +++ b/src/components/main/premium/GiftPremiumModal.tsx @@ -5,6 +5,7 @@ import { getActions, withGlobal } from '../../../global'; import type { FC } from '../../../lib/teact/teact'; import type { ApiPremiumGiftOption, ApiUser } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { formatCurrency } from '../../../util/formatCurrency'; import renderText from '../../common/helpers/renderText'; @@ -31,10 +32,16 @@ type StateProps = { gifts?: ApiPremiumGiftOption[]; monthlyCurrency?: string; monthlyAmount?: number; + animationLevel: AnimationLevel; }; const GiftPremiumModal: FC = ({ - isOpen, user, gifts, monthlyCurrency, monthlyAmount, + isOpen, + user, + gifts, + monthlyCurrency, + monthlyAmount, + animationLevel, }) => { const { openPremiumModal, closeGiftPremiumModal, openUrl } = getActions(); @@ -116,7 +123,7 @@ const GiftPremiumModal: FC = ({ > - +

{lang('GiftTelegramPremiumTitle')}

@@ -162,5 +169,6 @@ export default memo(withGlobal((global): StateProps => { gifts, monthlyCurrency, monthlyAmount: monthlyAmount ? Number(monthlyAmount) : undefined, + animationLevel: global.settings.byKey.animationLevel, }; })(GiftPremiumModal)); diff --git a/src/components/mediaViewer/MediaViewer.tsx b/src/components/mediaViewer/MediaViewer.tsx index 0c369c87..55c82436 100644 --- a/src/components/mediaViewer/MediaViewer.tsx +++ b/src/components/mediaViewer/MediaViewer.tsx @@ -6,6 +6,7 @@ import React, { import type { ApiChat, ApiMessage, ApiUser, } from '../../api/types'; +import type { AnimationLevel } from '../../types'; import { MediaViewerOrigin } from '../../types'; import { getActions, withGlobal } from '../../global'; @@ -62,7 +63,7 @@ type StateProps = { message?: ApiMessage; chatMessages?: Record; collectionIds?: number[]; - animationLevel: 0 | 1 | 2; + animationLevel: AnimationLevel; }; const ANIMATION_DURATION = 350; diff --git a/src/components/mediaViewer/MediaViewerContent.tsx b/src/components/mediaViewer/MediaViewerContent.tsx index 2c33db1b..da0cb220 100644 --- a/src/components/mediaViewer/MediaViewerContent.tsx +++ b/src/components/mediaViewer/MediaViewerContent.tsx @@ -5,6 +5,7 @@ import { withGlobal } from '../../global'; import type { ApiChat, ApiDimensions, ApiMessage, ApiUser, } from '../../api/types'; +import type { AnimationLevel } from '../../types'; import { MediaViewerOrigin } from '../../types'; import { IS_SINGLE_COLUMN_LAYOUT, IS_TOUCH_ENV } from '../../util/environment'; @@ -30,7 +31,7 @@ type OwnProps = { avatarOwnerId?: string; origin?: MediaViewerOrigin; isActive?: boolean; - animationLevel: 0 | 1 | 2; + animationLevel: AnimationLevel; onClose: () => void; onFooterClick: () => void; setControlsVisible?: (isVisible: boolean) => void; diff --git a/src/components/mediaViewer/MediaViewerSlides.tsx b/src/components/mediaViewer/MediaViewerSlides.tsx index cc875d74..934bd09e 100644 --- a/src/components/mediaViewer/MediaViewerSlides.tsx +++ b/src/components/mediaViewer/MediaViewerSlides.tsx @@ -3,7 +3,7 @@ import React, { memo, useCallback, useEffect, useRef, useState, } from '../../lib/teact/teact'; -import type { MediaViewerOrigin } from '../../types'; +import type { AnimationLevel, MediaViewerOrigin } from '../../types'; import type { RealTouchEvent } from '../../util/captureEvents'; import { animateNumber, timingFunctions } from '../../util/animation'; @@ -38,7 +38,7 @@ type OwnProps = { threadId?: number; avatarOwnerId?: string; origin?: MediaViewerOrigin; - animationLevel: 0 | 1 | 2; + animationLevel: AnimationLevel; onClose: () => void; hasFooter?: boolean; onFooterClick: () => void; diff --git a/src/components/mediaViewer/SenderInfo.tsx b/src/components/mediaViewer/SenderInfo.tsx index aa955ed1..ccdb01b8 100644 --- a/src/components/mediaViewer/SenderInfo.tsx +++ b/src/components/mediaViewer/SenderInfo.tsx @@ -3,6 +3,7 @@ import React, { useCallback } from '../../lib/teact/teact'; import { getActions, withGlobal } from '../../global'; import type { ApiChat, ApiMessage, ApiUser } from '../../api/types'; +import type { AnimationLevel } from '../../types'; import { IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment'; import { getSenderTitle, isUserId } from '../../global/helpers'; @@ -29,6 +30,7 @@ type OwnProps = { type StateProps = { sender?: ApiUser | ApiChat; message?: ApiMessage; + animationLevel: AnimationLevel; }; const ANIMATION_DURATION = 350; @@ -39,6 +41,7 @@ const SenderInfo: FC = ({ sender, isAvatar, message, + animationLevel, }) => { const { closeMediaViewer, @@ -70,9 +73,9 @@ const SenderInfo: FC = ({ return (
{isUserId(sender.id) ? ( - + ) : ( - + )}
@@ -90,14 +93,16 @@ const SenderInfo: FC = ({ export default withGlobal( (global, { chatId, messageId, isAvatar }): StateProps => { + const { animationLevel } = global.settings.byKey; if (isAvatar && chatId) { return { sender: isUserId(chatId) ? selectUser(global, chatId) : selectChat(global, chatId), + animationLevel, }; } if (!messageId || !chatId) { - return {}; + return { animationLevel }; } const message = selectChatMessage(global, chatId, messageId); @@ -105,6 +110,7 @@ export default withGlobal( return { message, sender: message && selectSender(global, message), + animationLevel, }; }, )(SenderInfo); diff --git a/src/components/middle/MessageList.tsx b/src/components/middle/MessageList.tsx index abc2b6f1..c328093f 100644 --- a/src/components/middle/MessageList.tsx +++ b/src/components/middle/MessageList.tsx @@ -7,6 +7,7 @@ import { getActions, getGlobal, withGlobal } from '../../global'; import type { ApiBotInfo, ApiMessage, ApiRestrictionReason } from '../../api/types'; import { MAIN_THREAD_ID } from '../../api/types'; import type { MessageListType } from '../../global/types'; +import type { AnimationLevel } from '../../types'; import { LoadMoreDirection } from '../../types'; import { ANIMATION_END_DELAY, LOCAL_MESSAGE_MIN_ID, MESSAGE_LIST_SLICE } from '../../config'; @@ -95,7 +96,7 @@ type StateProps = { restrictionReason?: ApiRestrictionReason; focusingId?: number; isSelectModeActive?: boolean; - animationLevel?: number; + animationLevel?: AnimationLevel; lastMessage?: ApiMessage; isLoadingBotInfo?: boolean; botInfo?: ApiBotInfo; diff --git a/src/components/middle/MiddleColumn.tsx b/src/components/middle/MiddleColumn.tsx index bb8002e3..3d0ec394 100644 --- a/src/components/middle/MiddleColumn.tsx +++ b/src/components/middle/MiddleColumn.tsx @@ -10,7 +10,7 @@ import type { MessageListType, ActiveEmojiInteraction, } from '../../global/types'; -import type { ThemeKey } from '../../types'; +import type { AnimationLevel, ThemeKey } from '../../types'; import { MIN_SCREEN_WIDTH_FOR_STATIC_LEFT_COLUMN, @@ -100,7 +100,7 @@ type StateProps = { isSeenByModalOpen: boolean; isReactorListModalOpen: boolean; isGiftPremiumModalOpen?: boolean; - animationLevel?: number; + animationLevel: AnimationLevel; shouldSkipHistoryAnimations?: boolean; currentTransitionKey: number; isChannel?: boolean; diff --git a/src/components/middle/ReactorListModal.tsx b/src/components/middle/ReactorListModal.tsx index faab0356..2a8fd246 100644 --- a/src/components/middle/ReactorListModal.tsx +++ b/src/components/middle/ReactorListModal.tsx @@ -5,6 +5,7 @@ import React, { import { getActions, getGlobal, withGlobal } from '../../global'; import type { ApiMessage } from '../../api/types'; +import type { AnimationLevel } from '../../types'; import { LoadMoreDirection } from '../../types'; import useLang from '../../hooks/useLang'; @@ -37,6 +38,7 @@ export type OwnProps = { export type StateProps = Pick & { chatId?: string; messageId?: number; + animationLevel: AnimationLevel; }; const ReactorListModal: FC = ({ @@ -46,6 +48,7 @@ const ReactorListModal: FC = ({ chatId, messageId, seenByUserIds, + animationLevel, }) => { const { loadReactors, @@ -169,7 +172,7 @@ const ReactorListModal: FC = ({ // eslint-disable-next-line react/jsx-no-bind onClick={() => handleClick(userId)} > - +

{fullName && renderText(fullName)}

{user.isPremium && } @@ -204,6 +207,7 @@ export default memo(withGlobal( reactions: message?.reactions, reactors: message?.reactors, seenByUserIds: message?.seenByUserIds, + animationLevel: global.settings.byKey.animationLevel, }; }, )(ReactorListModal)); diff --git a/src/components/middle/composer/BotCommand.tsx b/src/components/middle/composer/BotCommand.tsx index 53a73018..7d9ba2dd 100644 --- a/src/components/middle/composer/BotCommand.tsx +++ b/src/components/middle/composer/BotCommand.tsx @@ -36,7 +36,7 @@ const BotCommand: FC = ({ focus={focus} > {withAvatar && ( - + )}
/{botCommand.command} diff --git a/src/components/middle/composer/Composer.tsx b/src/components/middle/composer/Composer.tsx index 4753c096..2d8b59d7 100644 --- a/src/components/middle/composer/Composer.tsx +++ b/src/components/middle/composer/Composer.tsx @@ -1128,7 +1128,6 @@ const Composer: FC = ({ user={sendAsUser} chat={sendAsChat} size="tiny" - noVideo /> )} diff --git a/src/components/middle/composer/StickerPicker.tsx b/src/components/middle/composer/StickerPicker.tsx index 44c01b6e..a3e0edf4 100644 --- a/src/components/middle/composer/StickerPicker.tsx +++ b/src/components/middle/composer/StickerPicker.tsx @@ -285,7 +285,7 @@ const StickerPicker: FC = ({ ) : stickerSet.id === FAVORITE_SYMBOL_SET_ID ? ( ) : stickerSet.id === CHAT_STICKER_SET_ID ? ( - + ) : stickerSet.isLottie ? ( = ({ size="small" user={isUserId(user.id) ? user as ApiUser : undefined} chat={!isUserId(user.id) ? user as ApiChat : undefined} - noVideo /> ))}
diff --git a/src/components/middle/message/Contact.tsx b/src/components/middle/message/Contact.tsx index 5503a6fe..513f08d7 100644 --- a/src/components/middle/message/Contact.tsx +++ b/src/components/middle/message/Contact.tsx @@ -3,6 +3,7 @@ import React, { useCallback } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import type { ApiUser, ApiContact, ApiCountryCode } from '../../../api/types'; +import type { AnimationLevel } from '../../../types'; import { selectUser } from '../../../global/selectors'; import { formatPhoneNumberWithCode } from '../../../util/phoneNumber'; @@ -19,12 +20,13 @@ type OwnProps = { type StateProps = { user?: ApiUser; phoneCodeList: ApiCountryCode[]; + animationLevel: AnimationLevel; }; const UNREGISTERED_CONTACT_ID = '0'; const Contact: FC = ({ - contact, user, phoneCodeList, + contact, user, phoneCodeList, animationLevel, }) => { const { openChat } = getActions(); @@ -45,7 +47,7 @@ const Contact: FC = ({ className={buildClassName('Contact', isRegistered && 'interactive')} onClick={isRegistered ? handleClick : undefined} > - +
{firstName} {lastName}
{formatPhoneNumberWithCode(phoneCodeList, phoneNumber)}
@@ -60,6 +62,7 @@ export default withGlobal( return { user: selectUser(global, contact.userId), phoneCodeList, + animationLevel: global.settings.byKey.animationLevel, }; }, )(Contact); diff --git a/src/components/middle/message/Message.tsx b/src/components/middle/message/Message.tsx index 781d4e35..d01ded50 100644 --- a/src/components/middle/message/Message.tsx +++ b/src/components/middle/message/Message.tsx @@ -18,7 +18,9 @@ import type { ApiThreadInfo, ApiAvailableReaction, } from '../../../api/types'; -import type { FocusDirection, IAlbum, ISettings } from '../../../types'; +import type { + AnimationLevel, FocusDirection, IAlbum, ISettings, +} from '../../../types'; import { AudioOrigin, } from '../../../types'; @@ -198,6 +200,7 @@ type StateProps = { transcribedText?: string; isTranscriptionError?: boolean; isPremium: boolean; + animationLevel: AnimationLevel; }; type MetaPosition = @@ -285,6 +288,7 @@ const Message: FC = ({ threadInfo, hasUnreadReaction, memoFirstUnreadIdRef, + animationLevel, }) => { const { toggleMessageSelection, @@ -617,6 +621,8 @@ const Message: FC = ({ lastSyncTime={lastSyncTime} onClick={(avatarUser || avatarChat) ? handleAvatarClick : undefined} observeIntersection={observeIntersectionForMedia} + animationLevel={animationLevel} + withVideo /> {isAvatarPremium && } @@ -1176,6 +1182,7 @@ export default memo(withGlobal( isTranscribing: transcriptionId !== undefined && global.transcriptions[transcriptionId]?.isPending, transcribedText: transcriptionId !== undefined ? global.transcriptions[transcriptionId]?.text : undefined, isPremium: selectIsCurrentUserPremium(global), + animationLevel: global.settings.byKey.animationLevel, }; }, )(Message)); diff --git a/src/components/middle/message/MessageContextMenu.tsx b/src/components/middle/message/MessageContextMenu.tsx index 1cbead89..8cfce7d7 100644 --- a/src/components/middle/message/MessageContextMenu.tsx +++ b/src/components/middle/message/MessageContextMenu.tsx @@ -348,7 +348,6 @@ const MessageContextMenu: FC = ({ ))}
diff --git a/src/components/middle/message/Poll.tsx b/src/components/middle/message/Poll.tsx index 83fc8892..70375a6a 100644 --- a/src/components/middle/message/Poll.tsx +++ b/src/components/middle/message/Poll.tsx @@ -234,7 +234,6 @@ const Poll: FC = ({ ))}
diff --git a/src/components/middle/message/ReactionButton.tsx b/src/components/middle/message/ReactionButton.tsx index e3fe38cc..977fc838 100644 --- a/src/components/middle/message/ReactionButton.tsx +++ b/src/components/middle/message/ReactionButton.tsx @@ -68,7 +68,7 @@ const ReactionButton: FC<{ /> {recentReactors?.length ? (
- {recentReactors.map((user) => )} + {recentReactors.map((user) => )}
) : formatIntegerCompact(reaction.count)} diff --git a/src/components/right/RightSearch.tsx b/src/components/right/RightSearch.tsx index 6fae8f6c..ad6e92e4 100644 --- a/src/components/right/RightSearch.tsx +++ b/src/components/right/RightSearch.tsx @@ -1,8 +1,9 @@ -import type { FC } from '../../lib/teact/teact'; import React, { useMemo, memo, useRef } from '../../lib/teact/teact'; import { getActions, getGlobal, withGlobal } from '../../global'; +import type { FC } from '../../lib/teact/teact'; import type { ApiMessage, ApiUser, ApiChat } from '../../api/types'; +import type { AnimationLevel } from '../../types'; import { MEMO_EMPTY_ARRAY } from '../../util/memo'; import { @@ -43,18 +44,20 @@ type StateProps = { query?: string; totalCount?: number; foundIds?: number[]; + animationLevel?: AnimationLevel; }; const RightSearch: FC = ({ chatId, threadId, - onClose, isActive, chat, messagesById, query, totalCount, foundIds, + animationLevel, + onClose, }) => { const { searchTextMessagesLocal, @@ -129,7 +132,7 @@ const RightSearch: FC = ({ className="chat-item-clickable search-result-message m-0" onClick={onClick} > - +

{title && renderText(title)}

@@ -189,6 +192,7 @@ export default memo(withGlobal( query, totalCount, foundIds, + animationLevel: global.settings.byKey.animationLevel, }; }, )(RightSearch)); diff --git a/src/components/right/management/JoinRequest.tsx b/src/components/right/management/JoinRequest.tsx index ba5be616..1ddd064d 100644 --- a/src/components/right/management/JoinRequest.tsx +++ b/src/components/right/management/JoinRequest.tsx @@ -2,6 +2,7 @@ import type { FC } from '../../../lib/teact/teact'; import React, { memo, useCallback } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; +import type { AnimationLevel } from '../../../types'; import type { ApiUser } from '../../../api/types'; import useLang from '../../../hooks/useLang'; @@ -27,17 +28,19 @@ type OwnProps = { type StateProps = { user?: ApiUser; isSavedMessages?: boolean; + animationLevel: AnimationLevel; serverTimeOffset: number; }; const JoinRequest: FC = ({ userId, + chatId, about, date, isChannel, user, + animationLevel, serverTimeOffset, - chatId, }) => { const { openChat, hideChatJoinRequest } = getActions(); @@ -70,6 +73,8 @@ const JoinRequest: FC = ({ key={userId} size="medium" user={user} + animationLevel={animationLevel} + withVideo />
{fullName}
@@ -96,6 +101,7 @@ export default memo(withGlobal( return { user, + animationLevel: global.settings.byKey.animationLevel, serverTimeOffset: global.serverTimeOffset, }; }, diff --git a/src/types/index.ts b/src/types/index.ts index e052df21..e48bc8bb 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -27,6 +27,7 @@ export interface IAlbum { } export type ThemeKey = 'light' | 'dark'; +export type AnimationLevel = 0 | 1 | 2; export interface IThemeSettings { background?: string; @@ -59,7 +60,7 @@ export interface ISettings extends NotifySettings, Record { theme: ThemeKey; shouldUseSystemTheme: boolean; messageTextSize: number; - animationLevel: 0 | 1 | 2; + animationLevel: AnimationLevel; messageSendKeyCombo: 'enter' | 'ctrl-enter'; canAutoLoadPhotoFromContacts: boolean; canAutoLoadPhotoInPrivateChats: boolean;