Gift Transfer: Add 2FA set up button (#5876)

This commit is contained in:
zubiden 2025-05-14 19:01:49 +03:00 committed by Alexander Zinchuk
parent dc722a9cc2
commit 842d2432a1
35 changed files with 342 additions and 329 deletions

View File

@ -1674,6 +1674,7 @@
"GiftFilterHidden" = "Hidden";
"GiftSearchEmpty" = "No matching gifts";
"GiftSearchReset" = "View All Gifts";
"SetUp2FA" = "Set up Two-Step Verification";
"CheckPasswordTitle" = "Enter Password";
"CheckPasswordPlaceholder" = "Password";
"CheckPasswordDescription" = "Please enter your password to continue.";

View File

@ -4,7 +4,6 @@ import { getActions } from '../../global';
import type { GlobalState } from '../../global/types';
import type { FolderEditDispatch } from '../../hooks/reducers/useFoldersReducer';
import type { LeftColumnContent, SettingsScreens } from '../../types';
import { ANIMATION_END_DELAY } from '../../config';
import buildClassName from '../../util/buildClassName';
@ -35,9 +34,7 @@ export type OwnProps = {
isStoryRibbonShown?: boolean;
onReset: () => void;
onTopicSearch: NoneToVoidFunction;
onSettingsScreenSelect: (screen: SettingsScreens) => void;
foldersDispatch: FolderEditDispatch;
onLeftColumnContentChange: (content: LeftColumnContent) => void;
};
const ArchivedChats: FC<OwnProps> = ({
@ -47,8 +44,6 @@ const ArchivedChats: FC<OwnProps> = ({
isStoryRibbonShown,
onReset,
onTopicSearch,
onSettingsScreenSelect,
onLeftColumnContentChange,
foldersDispatch,
}) => {
const { updateArchiveSettings } = getActions();
@ -136,8 +131,7 @@ const ArchivedChats: FC<OwnProps> = ({
folderType="archived"
isActive={isActive}
isForumPanelOpen={isForumPanelVisible}
onSettingsScreenSelect={onSettingsScreenSelect}
onLeftColumnContentChange={onLeftColumnContentChange}
isMainList
foldersDispatch={foldersDispatch}
archiveSettings={archiveSettings}
/>

View File

@ -38,13 +38,14 @@ interface OwnProps {
}
type StateProps = {
contentKey: LeftColumnContent;
settingsScreen: SettingsScreens;
searchQuery?: string;
searchDate?: number;
isFirstChatFolderActive: boolean;
shouldSkipHistoryAnimations?: boolean;
currentUserId?: string;
hasPasscode?: boolean;
nextSettingsScreen?: SettingsScreens;
nextFoldersAction?: ReducerAction<FoldersActions>;
isChatOpen: boolean;
isAppUpdateAvailable?: boolean;
@ -73,13 +74,14 @@ const RESET_TRANSITION_DELAY_MS = 250;
function LeftColumn({
ref,
contentKey,
settingsScreen,
searchQuery,
searchDate,
isFirstChatFolderActive,
shouldSkipHistoryAnimations,
currentUserId,
hasPasscode,
nextSettingsScreen,
nextFoldersAction,
isChatOpen,
isAppUpdateAvailable,
@ -100,11 +102,10 @@ function LeftColumn({
loadPasswordInfo,
clearTwoFaError,
openChat,
requestNextSettingsScreen,
openLeftColumnContent,
openSettingsScreen,
} = getActions();
const [content, setContent] = useState<LeftColumnContent>(LeftColumnContent.ChatList);
const [settingsScreen, setSettingsScreen] = useState(SettingsScreens.Main);
const [contactsFilter, setContactsFilter] = useState<string>('');
const [foldersState, foldersDispatch] = useFoldersReducer();
@ -112,7 +113,7 @@ function LeftColumn({
const [lastResetTime, setLastResetTime] = useState<number>(0);
let contentType: ContentType = ContentType.Main;
switch (content) {
switch (contentKey) {
case LeftColumnContent.Archived:
contentType = ContentType.Archived;
break;
@ -131,8 +132,8 @@ function LeftColumn({
const handleReset = useLastCallback((forceReturnToChatList?: true | Event) => {
function fullReset() {
setContent(LeftColumnContent.ChatList);
setSettingsScreen(SettingsScreens.Main);
openLeftColumnContent({ contentKey: undefined });
openSettingsScreen({ screen: undefined });
setContactsFilter('');
setGlobalSearchClosing({ isClosing: true });
resetChatCreation();
@ -150,24 +151,24 @@ function LeftColumn({
return;
}
if (content === LeftColumnContent.NewGroupStep2) {
setContent(LeftColumnContent.NewGroupStep1);
if (contentKey === LeftColumnContent.NewGroupStep2) {
openLeftColumnContent({ contentKey: LeftColumnContent.NewGroupStep1 });
return;
}
if (content === LeftColumnContent.NewChannelStep2) {
setContent(LeftColumnContent.NewChannelStep1);
if (contentKey === LeftColumnContent.NewChannelStep2) {
openLeftColumnContent({ contentKey: LeftColumnContent.NewChannelStep1 });
return;
}
if (content === LeftColumnContent.NewGroupStep1) {
if (contentKey === LeftColumnContent.NewGroupStep1) {
const pickerSearchInput = document.getElementById('new-group-picker-search');
if (pickerSearchInput) {
pickerSearchInput.blur();
}
}
if (content === LeftColumnContent.Settings) {
if (contentKey === LeftColumnContent.Settings) {
switch (settingsScreen) {
case SettingsScreens.EditProfile:
case SettingsScreens.Folders:
@ -180,14 +181,14 @@ function LeftColumn({
case SettingsScreens.Language:
case SettingsScreens.Stickers:
case SettingsScreens.Experimental:
setSettingsScreen(SettingsScreens.Main);
openSettingsScreen({ screen: SettingsScreens.Main });
return;
case SettingsScreens.GeneralChatBackground:
setSettingsScreen(SettingsScreens.General);
openSettingsScreen({ screen: SettingsScreens.General });
return;
case SettingsScreens.GeneralChatBackgroundColor:
setSettingsScreen(SettingsScreens.GeneralChatBackground);
openSettingsScreen({ screen: SettingsScreens.GeneralChatBackground });
return;
case SettingsScreens.PrivacyPhoneNumber:
@ -211,141 +212,143 @@ function LeftColumn({
case SettingsScreens.PasscodeDisabled:
case SettingsScreens.PasscodeEnabled:
case SettingsScreens.PasscodeCongratulations:
setSettingsScreen(SettingsScreens.Privacy);
openSettingsScreen({ screen: SettingsScreens.Privacy });
return;
case SettingsScreens.PasscodeNewPasscode:
setSettingsScreen(hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled);
openSettingsScreen({
screen: hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled,
});
return;
case SettingsScreens.PasscodeChangePasscodeCurrent:
case SettingsScreens.PasscodeTurnOff:
setSettingsScreen(SettingsScreens.PasscodeEnabled);
openSettingsScreen({ screen: SettingsScreens.PasscodeEnabled });
return;
case SettingsScreens.PasscodeNewPasscodeConfirm:
setSettingsScreen(SettingsScreens.PasscodeNewPasscode);
openSettingsScreen({ screen: SettingsScreens.PasscodeNewPasscode });
return;
case SettingsScreens.PasscodeChangePasscodeNew:
setSettingsScreen(SettingsScreens.PasscodeChangePasscodeCurrent);
openSettingsScreen({ screen: SettingsScreens.PasscodeChangePasscodeCurrent });
return;
case SettingsScreens.PasscodeChangePasscodeConfirm:
setSettingsScreen(SettingsScreens.PasscodeChangePasscodeNew);
openSettingsScreen({ screen: SettingsScreens.PasscodeChangePasscodeNew });
return;
case SettingsScreens.PrivacyPhoneNumberAllowedContacts:
case SettingsScreens.PrivacyPhoneNumberDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyPhoneNumber);
openSettingsScreen({ screen: SettingsScreens.PrivacyPhoneNumber });
return;
case SettingsScreens.PrivacyLastSeenAllowedContacts:
case SettingsScreens.PrivacyLastSeenDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyLastSeen);
openSettingsScreen({ screen: SettingsScreens.PrivacyLastSeen });
return;
case SettingsScreens.PrivacyProfilePhotoAllowedContacts:
case SettingsScreens.PrivacyProfilePhotoDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyProfilePhoto);
openSettingsScreen({ screen: SettingsScreens.PrivacyProfilePhoto });
return;
case SettingsScreens.PrivacyBioAllowedContacts:
case SettingsScreens.PrivacyBioDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyBio);
openSettingsScreen({ screen: SettingsScreens.PrivacyBio });
return;
case SettingsScreens.PrivacyBirthdayAllowedContacts:
case SettingsScreens.PrivacyBirthdayDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyBirthday);
openSettingsScreen({ screen: SettingsScreens.PrivacyBirthday });
return;
case SettingsScreens.PrivacyGiftsAllowedContacts:
case SettingsScreens.PrivacyGiftsDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyGifts);
openSettingsScreen({ screen: SettingsScreens.PrivacyGifts });
return;
case SettingsScreens.PrivacyPhoneCallAllowedContacts:
case SettingsScreens.PrivacyPhoneCallDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyPhoneCall);
openSettingsScreen({ screen: SettingsScreens.PrivacyPhoneCall });
return;
case SettingsScreens.PrivacyPhoneP2PAllowedContacts:
case SettingsScreens.PrivacyPhoneP2PDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyPhoneP2P);
openSettingsScreen({ screen: SettingsScreens.PrivacyPhoneP2P });
return;
case SettingsScreens.PrivacyForwardingAllowedContacts:
case SettingsScreens.PrivacyForwardingDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyForwarding);
openSettingsScreen({ screen: SettingsScreens.PrivacyForwarding });
return;
case SettingsScreens.PrivacyVoiceMessagesAllowedContacts:
case SettingsScreens.PrivacyVoiceMessagesDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyVoiceMessages);
openSettingsScreen({ screen: SettingsScreens.PrivacyVoiceMessages });
return;
case SettingsScreens.PrivacyGroupChatsAllowedContacts:
case SettingsScreens.PrivacyGroupChatsDeniedContacts:
setSettingsScreen(SettingsScreens.PrivacyGroupChats);
openSettingsScreen({ screen: SettingsScreens.PrivacyGroupChats });
return;
case SettingsScreens.TwoFaNewPassword:
setSettingsScreen(SettingsScreens.TwoFaDisabled);
openSettingsScreen({ screen: SettingsScreens.TwoFaDisabled });
return;
case SettingsScreens.TwoFaNewPasswordConfirm:
setSettingsScreen(SettingsScreens.TwoFaNewPassword);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPassword });
return;
case SettingsScreens.TwoFaNewPasswordHint:
setSettingsScreen(SettingsScreens.TwoFaNewPasswordConfirm);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordConfirm });
return;
case SettingsScreens.TwoFaNewPasswordEmail:
setSettingsScreen(SettingsScreens.TwoFaNewPasswordHint);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordHint });
return;
case SettingsScreens.TwoFaNewPasswordEmailCode:
setSettingsScreen(SettingsScreens.TwoFaNewPasswordEmail);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordEmail });
return;
case SettingsScreens.TwoFaChangePasswordCurrent:
case SettingsScreens.TwoFaTurnOff:
case SettingsScreens.TwoFaRecoveryEmailCurrentPassword:
setSettingsScreen(SettingsScreens.TwoFaEnabled);
openSettingsScreen({ screen: SettingsScreens.TwoFaEnabled });
return;
case SettingsScreens.TwoFaChangePasswordNew:
setSettingsScreen(SettingsScreens.TwoFaChangePasswordCurrent);
openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordCurrent });
return;
case SettingsScreens.TwoFaChangePasswordConfirm:
setSettingsScreen(SettingsScreens.TwoFaChangePasswordNew);
openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordNew });
return;
case SettingsScreens.TwoFaChangePasswordHint:
setSettingsScreen(SettingsScreens.TwoFaChangePasswordConfirm);
openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordConfirm });
return;
case SettingsScreens.TwoFaRecoveryEmail:
setSettingsScreen(SettingsScreens.TwoFaRecoveryEmailCurrentPassword);
openSettingsScreen({ screen: SettingsScreens.TwoFaRecoveryEmailCurrentPassword });
return;
case SettingsScreens.TwoFaRecoveryEmailCode:
setSettingsScreen(SettingsScreens.TwoFaRecoveryEmail);
openSettingsScreen({ screen: SettingsScreens.TwoFaRecoveryEmail });
return;
case SettingsScreens.FoldersCreateFolder:
case SettingsScreens.FoldersEditFolder:
setSettingsScreen(SettingsScreens.Folders);
openSettingsScreen({ screen: SettingsScreens.Folders });
return;
case SettingsScreens.FoldersShare:
setSettingsScreen(SettingsScreens.FoldersEditFolder);
openSettingsScreen({ screen: SettingsScreens.FoldersEditFolder });
return;
case SettingsScreens.FoldersIncludedChatsFromChatList:
case SettingsScreens.FoldersExcludedChatsFromChatList:
setSettingsScreen(SettingsScreens.FoldersEditFolderFromChatList);
openSettingsScreen({ screen: SettingsScreens.FoldersEditFolderFromChatList });
return;
case SettingsScreens.FoldersEditFolderFromChatList:
case SettingsScreens.FoldersEditFolderInvites:
setContent(LeftColumnContent.ChatList);
setSettingsScreen(SettingsScreens.Main);
openLeftColumnContent({ contentKey: LeftColumnContent.ChatList });
openSettingsScreen({ screen: SettingsScreens.Main });
return;
case SettingsScreens.QuickReaction:
case SettingsScreens.CustomEmoji:
setSettingsScreen(SettingsScreens.Stickers);
openSettingsScreen({ screen: SettingsScreens.Stickers });
return;
case SettingsScreens.DoNotTranslate:
setSettingsScreen(SettingsScreens.Language);
openSettingsScreen({ screen: SettingsScreens.Language });
return;
case SettingsScreens.PrivacyNoPaidMessages:
setSettingsScreen(SettingsScreens.PrivacyMessages);
openSettingsScreen({ screen: SettingsScreens.PrivacyMessages });
return;
default:
@ -353,8 +356,8 @@ function LeftColumn({
}
}
if (content === LeftColumnContent.ChatList && isFirstChatFolderActive) {
setContent(LeftColumnContent.GlobalSearch);
if (contentKey === LeftColumnContent.ChatList && isFirstChatFolderActive) {
openLeftColumnContent({ contentKey: LeftColumnContent.GlobalSearch });
return;
}
@ -363,12 +366,12 @@ function LeftColumn({
});
const handleSearchQuery = useLastCallback((query: string) => {
if (content === LeftColumnContent.Contacts) {
if (contentKey === LeftColumnContent.Contacts) {
setContactsFilter(query);
return;
}
setContent(LeftColumnContent.GlobalSearch);
openLeftColumnContent({ contentKey: LeftColumnContent.GlobalSearch });
if (query !== searchQuery) {
setGlobalSearchQuery({ query });
@ -376,15 +379,15 @@ function LeftColumn({
});
const handleTopicSearch = useLastCallback(() => {
setContent(LeftColumnContent.GlobalSearch);
openLeftColumnContent({ contentKey: LeftColumnContent.GlobalSearch });
setGlobalSearchQuery({ query: '' });
setGlobalSearchChatId({ id: forumPanelChatId });
});
useEffect(
() => {
const isArchived = content === LeftColumnContent.Archived;
const isChatList = content === LeftColumnContent.ChatList;
const isArchived = contentKey === LeftColumnContent.Archived;
const isChatList = contentKey === LeftColumnContent.ChatList;
const noChatOrForumOpen = !isChatOpen && !isForumPanelOpen;
// We listen for escape key only in these cases:
// 1. When we are in archived chats and no chat or forum is open.
@ -399,16 +402,16 @@ function LeftColumn({
return undefined;
}
},
[isFirstChatFolderActive, content, handleReset, isChatOpen, isForumPanelOpen],
[isFirstChatFolderActive, contentKey, handleReset, isChatOpen, isForumPanelOpen],
);
const handleHotkeySearch = useLastCallback((e: KeyboardEvent) => {
if (content === LeftColumnContent.GlobalSearch) {
if (contentKey === LeftColumnContent.GlobalSearch) {
return;
}
e.preventDefault();
setContent(LeftColumnContent.GlobalSearch);
openLeftColumnContent({ contentKey: LeftColumnContent.GlobalSearch });
});
const handleHotkeySavedMessages = useLastCallback((e: KeyboardEvent) => {
@ -418,12 +421,12 @@ function LeftColumn({
const handleArchivedChats = useLastCallback((e: KeyboardEvent) => {
e.preventDefault();
setContent(LeftColumnContent.Archived);
openLeftColumnContent({ contentKey: LeftColumnContent.Archived });
});
const handleHotkeySettings = useLastCallback((e: KeyboardEvent) => {
e.preventDefault();
setContent(LeftColumnContent.Settings);
openLeftColumnContent({ contentKey: LeftColumnContent.Settings });
});
useHotkeys(useMemo(() => ({
@ -448,21 +451,10 @@ function LeftColumn({
}, [clearTwoFaError, loadPasswordInfo, settingsScreen]);
useSyncEffect(() => {
if (nextSettingsScreen !== undefined) {
setContent(LeftColumnContent.Settings);
setSettingsScreen(nextSettingsScreen);
requestNextSettingsScreen({ screen: undefined });
}
if (nextFoldersAction) {
foldersDispatch(nextFoldersAction);
}
}, [foldersDispatch, nextFoldersAction, nextSettingsScreen, requestNextSettingsScreen]);
const handleSettingsScreenSelect = useLastCallback((screen: SettingsScreens) => {
setContent(LeftColumnContent.Settings);
setSettingsScreen(screen);
});
}, [foldersDispatch, nextFoldersAction]);
const prevSettingsScreenRef = useStateRef(usePrevious(contentType === ContentType.Settings ? settingsScreen : -1));
@ -476,8 +468,8 @@ function LeftColumn({
selectorToPreventScroll: '#Settings .custom-scroll',
onSwipeRightStart: handleReset,
onCancel: () => {
setContent(LeftColumnContent.Settings);
handleSettingsScreenSelect(prevSettingsScreenRef.current!);
openLeftColumnContent({ contentKey: LeftColumnContent.Settings });
openSettingsScreen({ screen: prevSettingsScreenRef.current! });
},
});
}, [prevSettingsScreenRef, ref]);
@ -491,8 +483,6 @@ function LeftColumn({
onReset={handleReset}
onTopicSearch={handleTopicSearch}
foldersDispatch={foldersDispatch}
onSettingsScreenSelect={handleSettingsScreenSelect}
onLeftColumnContentChange={setContent}
isForumPanelOpen={isForumPanelOpen}
archiveSettings={archiveSettings}
isStoryRibbonShown={isArchivedStoryRibbonShown}
@ -506,7 +496,6 @@ function LeftColumn({
foldersState={foldersState}
foldersDispatch={foldersDispatch}
shouldSkipTransition={shouldSkipHistoryAnimations}
onScreenSelect={handleSettingsScreenSelect}
onReset={handleReset}
/>
);
@ -516,8 +505,7 @@ function LeftColumn({
key={lastResetTime}
isActive={isActive}
isChannel
content={content}
onContentChange={setContent}
content={contentKey}
onReset={handleReset}
/>
);
@ -526,23 +514,20 @@ function LeftColumn({
<NewChat
key={lastResetTime}
isActive={isActive}
content={content}
onContentChange={setContent}
content={contentKey}
onReset={handleReset}
/>
);
default:
return (
<LeftMain
content={content}
content={contentKey}
isClosingSearch={isClosingSearch}
searchQuery={searchQuery}
searchDate={searchDate}
contactsFilter={contactsFilter}
foldersDispatch={foldersDispatch}
onContentChange={setContent}
onSearchQuery={handleSearchQuery}
onSettingsScreenSelect={handleSettingsScreenSelect}
onReset={handleReset}
shouldSkipTransition={shouldSkipHistoryAnimations}
isAppUpdateAvailable={isAppUpdateAvailable}
@ -583,7 +568,7 @@ export default memo(withGlobal<OwnProps>(
},
shouldSkipHistoryAnimations,
activeChatFolder,
nextSettingsScreen,
leftColumn,
nextFoldersAction,
storyViewer: {
isArchivedRibbonShown,
@ -612,7 +597,6 @@ export default memo(withGlobal<OwnProps>(
shouldSkipHistoryAnimations,
currentUserId,
hasPasscode,
nextSettingsScreen,
nextFoldersAction,
isChatOpen,
isAppUpdateAvailable,
@ -623,6 +607,8 @@ export default memo(withGlobal<OwnProps>(
archiveSettings,
isArchivedStoryRibbonShown: isArchivedRibbonShown,
isAccountFrozen,
contentKey: leftColumn.contentKey,
settingsScreen: leftColumn.settingsScreen,
};
},
)(LeftColumn));

View File

@ -7,7 +7,6 @@ import { getActions, getGlobal, withGlobal } from '../../../global';
import type { ApiChatFolder, ApiChatlistExportedInvite, ApiSession } from '../../../api/types';
import type { GlobalState } from '../../../global/types';
import type { FolderEditDispatch } from '../../../hooks/reducers/useFoldersReducer';
import type { LeftColumnContent } from '../../../types';
import type { MenuItemContextAction } from '../../ui/ListItem';
import type { TabWithProperties } from '../../ui/TabList';
import { SettingsScreens } from '../../../types';
@ -38,9 +37,7 @@ import Transition from '../../ui/Transition';
import ChatList from './ChatList';
type OwnProps = {
onSettingsScreenSelect: (screen: SettingsScreens) => void;
foldersDispatch: FolderEditDispatch;
onLeftColumnContentChange: (content: LeftColumnContent) => void;
shouldHideFolderTabs?: boolean;
isForumPanelOpen?: boolean;
};
@ -68,8 +65,6 @@ const FIRST_FOLDER_INDEX = 0;
const ChatFolders: FC<OwnProps & StateProps> = ({
foldersDispatch,
onSettingsScreenSelect,
onLeftColumnContentChange,
chatFoldersById,
orderedFolderIds,
activeChatFolder,
@ -97,6 +92,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
openEditChatFolder,
openLimitReachedModal,
markChatMessagesRead,
openSettingsScreen,
} = getActions();
// eslint-disable-next-line no-null/no-null
@ -207,7 +203,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
title: lang('FilterEditFolders'),
icon: 'edit',
handler: () => {
onSettingsScreenSelect(SettingsScreens.Folders);
openSettingsScreen({ screen: SettingsScreens.Folders });
},
});
@ -260,7 +256,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
});
}, [
displayedFolders, maxFolders, folderCountersById, lang, chatFoldersById, maxChatLists, folderInvitesById,
maxFolderInvites, folderUnreadChatsCountersById, onSettingsScreenSelect,
maxFolderInvites, folderUnreadChatsCountersById, openSettingsScreen,
]);
const handleSwitchTab = useLastCallback((index: number) => {
@ -365,8 +361,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
isActive={isActive}
isForumPanelOpen={isForumPanelOpen}
foldersDispatch={foldersDispatch}
onSettingsScreenSelect={onSettingsScreenSelect}
onLeftColumnContentChange={onLeftColumnContentChange}
isMainList
canDisplayArchive={(hasArchivedChats || hasArchivedStories) && !archiveSettings.isHidden}
archiveSettings={archiveSettings}
sessions={sessions}

View File

@ -7,7 +7,6 @@ import { getActions } from '../../../global';
import type { ApiSession } from '../../../api/types';
import type { GlobalState } from '../../../global/types';
import type { FolderEditDispatch } from '../../../hooks/reducers/useFoldersReducer';
import type { SettingsScreens } from '../../../types';
import { LeftColumnContent } from '../../../types';
import {
@ -51,10 +50,9 @@ type OwnProps = {
archiveSettings?: GlobalState['archiveSettings'];
isForumPanelOpen?: boolean;
sessions?: Record<string, ApiSession>;
foldersDispatch?: FolderEditDispatch;
onSettingsScreenSelect?: (screen: SettingsScreens) => void;
onLeftColumnContentChange?: (content: LeftColumnContent) => void;
isAccountFrozen?: boolean;
isMainList?: boolean;
foldersDispatch?: FolderEditDispatch;
};
const INTERSECTION_THROTTLE = 200;
@ -70,10 +68,9 @@ const ChatList: FC<OwnProps> = ({
canDisplayArchive,
archiveSettings,
sessions,
foldersDispatch,
onSettingsScreenSelect,
onLeftColumnContentChange,
isAccountFrozen,
isMainList,
foldersDispatch,
}) => {
const {
openChat,
@ -81,6 +78,7 @@ const ChatList: FC<OwnProps> = ({
closeForumPanel,
toggleStoryRibbon,
openFrozenAccountModal,
openLeftColumnContent,
} = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);
@ -150,7 +148,7 @@ const ChatList: FC<OwnProps> = ({
const position = Number(digit) + shift - 1;
if (isArchiveInList && position === -1) {
onLeftColumnContentChange?.(LeftColumnContent.Archived);
if (isMainList) openLeftColumnContent({ contentKey: LeftColumnContent.Archived });
return;
}
@ -166,8 +164,7 @@ const ChatList: FC<OwnProps> = ({
document.removeEventListener('keydown', handleKeyDown);
};
}, [
archiveSettings, isSaved, isActive, onLeftColumnContentChange, openChat, openNextChat, orderedIds,
shouldDisplayArchive,
archiveSettings, isSaved, isActive, openChat, openNextChat, orderedIds, shouldDisplayArchive, isMainList,
]);
const { observe } = useIntersectionObserver({
@ -176,7 +173,7 @@ const ChatList: FC<OwnProps> = ({
});
const handleArchivedClick = useLastCallback(() => {
onLeftColumnContentChange!(LeftColumnContent.Archived);
openLeftColumnContent({ contentKey: LeftColumnContent.Archived });
closeForumPanel();
});
@ -288,7 +285,6 @@ const ChatList: FC<OwnProps> = ({
folderId={folderId}
folderType={folderType}
foldersDispatch={foldersDispatch!}
onSettingsScreenSelect={onSettingsScreenSelect!}
/>
)
) : (

View File

@ -1,6 +1,6 @@
import type { FC } from '../../../lib/teact/teact';
import React, { memo, useCallback } from '../../../lib/teact/teact';
import { withGlobal } from '../../../global';
import { getActions, withGlobal } from '../../../global';
import type { ApiChatFolder, ApiSticker } from '../../../api/types';
import type { FolderEditDispatch } from '../../../hooks/reducers/useFoldersReducer';
@ -21,7 +21,6 @@ type OwnProps = {
folderId?: number;
folderType: 'all' | 'archived' | 'saved' | 'folder';
foldersDispatch: FolderEditDispatch;
onSettingsScreenSelect: (screen: SettingsScreens) => void;
};
type StateProps = {
@ -32,15 +31,16 @@ type StateProps = {
const ICON_SIZE = 96;
const EmptyFolder: FC<OwnProps & StateProps> = ({
chatFolder, animatedEmoji, foldersDispatch, onSettingsScreenSelect,
chatFolder, animatedEmoji, foldersDispatch,
}) => {
const { openSettingsScreen } = getActions();
const lang = useOldLang();
const { isMobile } = useAppLayout();
const handleEditFolder = useCallback(() => {
foldersDispatch({ type: 'editFolder', payload: chatFolder });
onSettingsScreenSelect(SettingsScreens.FoldersEditFolderFromChatList);
}, [chatFolder, foldersDispatch, onSettingsScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.FoldersEditFolderFromChatList });
}, [chatFolder, foldersDispatch]);
return (
<div className={styles.root}>

View File

@ -5,7 +5,6 @@ import React, {
import { getActions } from '../../../global';
import type { FolderEditDispatch } from '../../../hooks/reducers/useFoldersReducer';
import type { SettingsScreens } from '../../../types';
import { LeftColumnContent } from '../../../types';
import { PRODUCTION_URL } from '../../../config';
@ -40,8 +39,6 @@ type OwnProps = {
isForumPanelOpen?: boolean;
isClosingSearch?: boolean;
onSearchQuery: (query: string) => void;
onContentChange: (content: LeftColumnContent) => void;
onSettingsScreenSelect: (screen: SettingsScreens) => void;
onTopicSearch: NoneToVoidFunction;
isAccountFrozen?: boolean;
onReset: () => void;
@ -64,13 +61,11 @@ const LeftMain: FC<OwnProps> = ({
isElectronUpdateAvailable,
isForumPanelOpen,
onSearchQuery,
onContentChange,
onSettingsScreenSelect,
onReset,
onTopicSearch,
isAccountFrozen,
}) => {
const { closeForumPanel } = getActions();
const { closeForumPanel, openLeftColumnContent } = getActions();
const [isNewChatButtonShown, setIsNewChatButtonShown] = useState(IS_TOUCH_ENV);
const [isElectronAutoUpdateEnabled, setIsElectronAutoUpdateEnabled] = useState(false);
@ -116,15 +111,15 @@ const LeftMain: FC<OwnProps> = ({
});
const handleSelectSettings = useLastCallback(() => {
onContentChange(LeftColumnContent.Settings);
openLeftColumnContent({ contentKey: LeftColumnContent.Settings });
});
const handleSelectContacts = useLastCallback(() => {
onContentChange(LeftColumnContent.Contacts);
openLeftColumnContent({ contentKey: LeftColumnContent.Contacts });
});
const handleSelectArchived = useLastCallback(() => {
onContentChange(LeftColumnContent.Archived);
openLeftColumnContent({ contentKey: LeftColumnContent.Archived });
closeForumPanel();
});
@ -139,11 +134,11 @@ const LeftMain: FC<OwnProps> = ({
});
const handleSelectNewChannel = useLastCallback(() => {
onContentChange(LeftColumnContent.NewChannelStep1);
openLeftColumnContent({ contentKey: LeftColumnContent.NewChannelStep1 });
});
const handleSelectNewGroup = useLastCallback(() => {
onContentChange(LeftColumnContent.NewGroupStep1);
openLeftColumnContent({ contentKey: LeftColumnContent.NewGroupStep1 });
});
useEffect(() => {
@ -199,8 +194,6 @@ const LeftMain: FC<OwnProps> = ({
return (
<ChatFolders
shouldHideFolderTabs={isForumPanelVisible}
onSettingsScreenSelect={onSettingsScreenSelect}
onLeftColumnContentChange={onContentChange}
foldersDispatch={foldersDispatch}
isForumPanelOpen={isForumPanelVisible}
/>

View File

@ -113,7 +113,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
setSharedSettingOption,
setGlobalSearchChatId,
lockScreen,
requestNextSettingsScreen,
openSettingsScreen,
} = getActions();
const oldLang = useOldLang();
@ -146,7 +146,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
if (hasPasscode) {
lockScreen();
} else {
requestNextSettingsScreen({ screen: SettingsScreens.PasscodeDisabled });
openSettingsScreen({ screen: SettingsScreens.PasscodeDisabled });
}
});

View File

@ -1,5 +1,6 @@
import type { FC } from '../../../lib/teact/teact';
import React, { memo, useCallback, useState } from '../../../lib/teact/teact';
import { getActions } from '../../../global';
import { LeftColumnContent } from '../../../types';
@ -15,7 +16,6 @@ export type OwnProps = {
isActive: boolean;
isChannel?: boolean;
content: LeftColumnContent;
onContentChange: (content: LeftColumnContent) => void;
onReset: () => void;
};
@ -25,14 +25,16 @@ const NewChat: FC<OwnProps> = ({
isActive,
isChannel = false,
content,
onContentChange,
onReset,
}) => {
const { openLeftColumnContent } = getActions();
const [newChatMemberIds, setNewChatMemberIds] = useState<string[]>([]);
const handleNextStep = useCallback(() => {
onContentChange(isChannel ? LeftColumnContent.NewChannelStep2 : LeftColumnContent.NewGroupStep2);
}, [isChannel, onContentChange]);
openLeftColumnContent({
contentKey: isChannel ? LeftColumnContent.NewChannelStep2 : LeftColumnContent.NewGroupStep2,
});
}, [isChannel]);
return (
<Transition

View File

@ -29,7 +29,6 @@ import PrivacyLockedOption from './PrivacyLockedOption';
type OwnProps = {
isActive?: boolean;
onReset: VoidFunction;
onScreenSelect: (screen: SettingsScreens) => void;
};
type StateProps = {
@ -52,9 +51,8 @@ function PrivacyMessages({
isCurrentUserPremium,
noPaidReactionsForUsersCount,
onReset,
onScreenSelect,
}: OwnProps & StateProps) {
const { updateGlobalPrivacySettings } = getActions();
const { updateGlobalPrivacySettings, openSettingsScreen } = getActions();
const oldLang = useOldLang();
const lang = useLang();
@ -133,7 +131,7 @@ function PrivacyMessages({
icon="delete-user"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => {
onScreenSelect(SettingsScreens.PrivacyNoPaidMessages);
openSettingsScreen({ screen: SettingsScreens.PrivacyNoPaidMessages });
}}
>
<div className="multiline-item full-size">

View File

@ -150,7 +150,6 @@ export type OwnProps = {
currentScreen: SettingsScreens;
foldersState: FoldersState;
foldersDispatch: FolderEditDispatch;
onScreenSelect: (screen: SettingsScreens) => void;
shouldSkipTransition?: boolean;
onReset: (forceReturnToChatList?: true | Event) => void;
};
@ -160,11 +159,10 @@ const Settings: FC<OwnProps> = ({
currentScreen,
foldersState,
foldersDispatch,
onScreenSelect,
onReset,
shouldSkipTransition,
}) => {
const { closeShareChatFolderModal } = getActions();
const { closeShareChatFolderModal, openSettingsScreen } = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);
@ -205,9 +203,9 @@ const Settings: FC<OwnProps> = ({
|| currentScreen === SettingsScreens.FoldersExcludedChats
) {
if (foldersState.mode === 'create') {
onScreenSelect(SettingsScreens.FoldersCreateFolder);
openSettingsScreen({ screen: SettingsScreens.FoldersCreateFolder });
} else {
onScreenSelect(SettingsScreens.FoldersEditFolder);
openSettingsScreen({ screen: SettingsScreens.FoldersEditFolder });
}
return;
}
@ -243,7 +241,7 @@ const Settings: FC<OwnProps> = ({
switch (currentScreen) {
case SettingsScreens.Main:
return (
<SettingsMain onScreenSelect={onScreenSelect} isActive={isActive} onReset={handleReset} />
<SettingsMain isActive={isActive} onReset={handleReset} />
);
case SettingsScreens.EditProfile:
return (
@ -255,7 +253,6 @@ const Settings: FC<OwnProps> = ({
case SettingsScreens.General:
return (
<SettingsGeneral
onScreenSelect={onScreenSelect}
isActive={isScreenActive
|| activeScreen === SettingsScreens.GeneralChatBackgroundColor
|| activeScreen === SettingsScreens.GeneralChatBackground
@ -284,7 +281,6 @@ const Settings: FC<OwnProps> = ({
case SettingsScreens.Privacy:
return (
<SettingsPrivacy
onScreenSelect={onScreenSelect}
isActive={isScreenActive || isPrivacyScreen}
onReset={handleReset}
/>
@ -294,7 +290,6 @@ const Settings: FC<OwnProps> = ({
<SettingsLanguage
isActive={isScreenActive || activeScreen === SettingsScreens.DoNotTranslate}
onReset={handleReset}
onScreenSelect={onScreenSelect}
/>
);
case SettingsScreens.DoNotTranslate:
@ -303,7 +298,7 @@ const Settings: FC<OwnProps> = ({
);
case SettingsScreens.Stickers:
return (
<SettingsStickers isActive={isScreenActive} onReset={handleReset} onScreenSelect={onScreenSelect} />
<SettingsStickers isActive={isScreenActive} onReset={handleReset} />
);
case SettingsScreens.Experimental:
return (
@ -312,7 +307,6 @@ const Settings: FC<OwnProps> = ({
case SettingsScreens.GeneralChatBackground:
return (
<SettingsGeneralBackground
onScreenSelect={onScreenSelect}
isActive={isScreenActive || activeScreen === SettingsScreens.GeneralChatBackgroundColor}
onReset={handleReset}
/>
@ -358,7 +352,6 @@ const Settings: FC<OwnProps> = ({
return (
<SettingsPrivacyVisibility
screen={currentScreen}
onScreenSelect={onScreenSelect}
isActive={isScreenActive || privacyAllowScreens[currentScreen]}
onReset={handleReset}
/>
@ -412,7 +405,6 @@ const Settings: FC<OwnProps> = ({
<PrivacyMessages
isActive={isScreenActive}
onReset={handleReset}
onScreenSelect={onScreenSelect}
/>
);
@ -433,7 +425,6 @@ const Settings: FC<OwnProps> = ({
state={foldersState}
dispatch={foldersDispatch}
isActive={isScreenActive}
onScreenSelect={onScreenSelect}
onReset={handleReset}
/>
);
@ -461,7 +452,6 @@ const Settings: FC<OwnProps> = ({
dispatch={twoFaDispatch}
shownScreen={activeScreen}
isActive={isScreenActive}
onScreenSelect={onScreenSelect}
onReset={handleReset}
/>
);
@ -482,7 +472,6 @@ const Settings: FC<OwnProps> = ({
onSetPasscode={setPrivacyPasscode}
shownScreen={activeScreen}
isActive={isScreenActive}
onScreenSelect={onScreenSelect}
onReset={handleReset}
/>
);
@ -511,7 +500,6 @@ const Settings: FC<OwnProps> = ({
<SettingsHeader
currentScreen={currentScreen}
onReset={handleReset}
onScreenSelect={onScreenSelect}
editedFolderId={foldersState.folderId}
/>
{renderCurrentSectionContent(isScreenActive, activeKey)}

View File

@ -26,7 +26,6 @@ import RangeSlider from '../../ui/RangeSlider';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -46,11 +45,10 @@ const SettingsGeneral: FC<OwnProps & StateProps> = ({
timeFormat,
theme,
shouldUseSystemTheme,
onScreenSelect,
onReset,
}) => {
const {
setSharedSettingOption,
setSharedSettingOption, openSettingsScreen,
} = getActions();
const lang = useLang();
@ -146,7 +144,7 @@ const SettingsGeneral: FC<OwnProps & StateProps> = ({
icon="photo"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.GeneralChatBackground)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.GeneralChatBackground })}
>
{lang('ChatBackground')}
</ListItem>

View File

@ -27,7 +27,6 @@ import './SettingsGeneralBackground.scss';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -44,7 +43,6 @@ const runThrottled = throttle((cb) => cb(), 60000, true);
const SettingsGeneralBackground: FC<OwnProps & StateProps> = ({
isActive,
onScreenSelect,
onReset,
background,
isBlurred,
@ -55,6 +53,7 @@ const SettingsGeneralBackground: FC<OwnProps & StateProps> = ({
loadWallpapers,
uploadWallpaper,
setThemeSettings,
openSettingsScreen,
} = getActions();
const themeRef = useRef<ThemeKey>();
@ -81,8 +80,8 @@ const SettingsGeneralBackground: FC<OwnProps & StateProps> = ({
}, [handleFileSelect]);
const handleSetColor = useCallback(() => {
onScreenSelect(SettingsScreens.GeneralChatBackgroundColor);
}, [onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.GeneralChatBackgroundColor });
}, []);
const handleResetToDefault = useCallback(() => {
setThemeSettings({

View File

@ -21,25 +21,24 @@ type OwnProps = {
currentScreen: SettingsScreens;
editedFolderId?: number;
onReset: () => void;
onScreenSelect: (screen: SettingsScreens) => void;
};
const SettingsHeader: FC<OwnProps> = ({
currentScreen,
editedFolderId,
onReset,
onScreenSelect,
}) => {
const {
signOut,
openDeleteChatFolderModal,
openSettingsScreen,
} = getActions();
const { isMobile } = useAppLayout();
const [isSignOutDialogOpen, setIsSignOutDialogOpen] = useState(false);
const handleMultiClick = useMultiClick(5, () => {
onScreenSelect(SettingsScreens.Experimental);
openSettingsScreen({ screen: SettingsScreens.Experimental });
});
const openSignOutConfirmation = useCallback(() => {
@ -270,7 +269,7 @@ const SettingsHeader: FC<OwnProps> = ({
size="smaller"
color="translucent"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.EditProfile)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.EditProfile })}
ariaLabel={oldLang('lng_settings_information')}
>
<Icon name="edit" />

View File

@ -25,7 +25,6 @@ import Loading from '../../ui/Loading';
type OwnProps = {
isActive?: boolean;
onReset: () => void;
onScreenSelect: (screen: SettingsScreens) => void;
};
type StateProps = {
@ -41,7 +40,6 @@ const SettingsLanguage: FC<OwnProps & StateProps> = ({
canTranslate,
canTranslateChats,
doNotTranslate,
onScreenSelect,
onReset,
}) => {
const {
@ -49,6 +47,7 @@ const SettingsLanguage: FC<OwnProps & StateProps> = ({
setSettingOption,
setSharedSettingOption,
openPremiumModal,
openSettingsScreen,
} = getActions();
const [selectedLanguage, setSelectedLanguage] = useState<string>(language);
@ -120,7 +119,7 @@ const SettingsLanguage: FC<OwnProps & StateProps> = ({
}, [doNotTranslate, lang, language]);
const handleDoNotSelectOpen = useLastCallback(() => {
onScreenSelect(SettingsScreens.DoNotTranslate);
openSettingsScreen({ screen: SettingsScreens.DoNotTranslate });
});
useHistoryBack({

View File

@ -25,7 +25,6 @@ import ListItem from '../../ui/ListItem';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -44,7 +43,6 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
canBuyPremium,
isGiveawayAvailable,
starsBalance,
onScreenSelect,
onReset,
}) => {
const {
@ -54,6 +52,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
openUrl,
openGiftRecipientPicker,
openStarsBalanceModal,
openSettingsScreen,
} = getActions();
const [isSupportDialogOpen, openSupportDialog, closeSupportDialog] = useFlag(false);
@ -98,7 +97,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="settings"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.General)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.General })}
>
{lang('TelegramGeneralSettingsViewController')}
</ListItem>
@ -106,7 +105,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="animations"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.Performance)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.Performance })}
>
{lang('MenuAnimations')}
</ListItem>
@ -114,7 +113,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="unmute"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.Notifications)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.Notifications })}
>
{lang('Notifications')}
</ListItem>
@ -122,7 +121,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="data"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.DataStorage)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.DataStorage })}
>
{lang('DataSettings')}
</ListItem>
@ -130,7 +129,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="lock"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.Privacy)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.Privacy })}
>
{lang('PrivacySettings')}
</ListItem>
@ -138,7 +137,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="folder"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.Folders)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.Folders })}
>
{lang('Filters')}
</ListItem>
@ -146,7 +145,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="active-sessions"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.ActiveSessions)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.ActiveSessions })}
>
{lang('SessionsTitle')}
{sessionCount > 0 && (<span className="settings-item__current-value">{sessionCount}</span>)}
@ -155,7 +154,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="language"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.Language)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.Language })}
>
{lang('Language')}
<span className="settings-item__current-value">{lang.languageInfo.nativeName}</span>
@ -164,7 +163,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
icon="stickers"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.Stickers)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.Stickers })}
>
{lang('MenuStickers')}
</ListItem>

View File

@ -22,7 +22,6 @@ import ListItem from '../../ui/ListItem';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -60,7 +59,6 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
canDisplayChatInTitle,
canSetPasscode,
privacy,
onScreenSelect,
onReset,
isCurrentUserFrozen,
}) => {
@ -73,6 +71,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
updateGlobalPrivacySettings,
loadWebAuthorizations,
setSharedSettingOption,
openSettingsScreen,
} = getActions();
useEffect(() => {
@ -160,7 +159,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
icon="delete-user"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyBlockedUsers)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyBlockedUsers })}
>
{oldLang('BlockedUsers')}
<span className="settings-item__current-value">{blockedCount || ''}</span>
@ -170,9 +169,9 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
icon="key"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(
hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled,
)}
onClick={() => openSettingsScreen({
screen: hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled,
})}
>
<div className="multiline-item">
<span className="title">{oldLang('Passcode')}</span>
@ -186,9 +185,9 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
icon="lock"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(
hasPassword ? SettingsScreens.TwoFaEnabled : SettingsScreens.TwoFaDisabled,
)}
onClick={() => openSettingsScreen({
screen: hasPassword ? SettingsScreens.TwoFaEnabled : SettingsScreens.TwoFaDisabled,
})}
>
<div className="multiline-item">
<span className="title">{oldLang('TwoStepVerification')}</span>
@ -202,7 +201,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
icon="web"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.ActiveWebsites)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.ActiveWebsites })}
>
{oldLang('PrivacySettings.WebSessions')}
<span className="settings-item__current-value">{webAuthCount}</span>
@ -217,7 +216,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyPhoneNumber)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyPhoneNumber })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyPhoneTitle')}</span>
@ -230,7 +229,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyLastSeen)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyLastSeen })}
>
<div className="multiline-item">
<span className="title">{oldLang('LastSeenTitle')}</span>
@ -243,7 +242,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyProfilePhoto)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyProfilePhoto })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyProfilePhotoTitle')}</span>
@ -256,7 +255,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyBio)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyBio })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyBio')}</span>
@ -269,7 +268,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyBirthday)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyBirthday })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyBirthday')}</span>
@ -282,7 +281,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyGifts)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyGifts })}
>
<div className="multiline-item">
<span className="title">{lang('PrivacyGifts')}</span>
@ -295,7 +294,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyForwarding)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyForwarding })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyForwardsTitle')}</span>
@ -308,7 +307,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyPhoneCall)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyPhoneCall })}
>
<div className="multiline-item">
<span className="title">{oldLang('WhoCanCallMe')}</span>
@ -323,7 +322,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
rightElement={isCurrentUserPremium && <StarIcon size="big" type="premium" />}
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyVoiceMessages)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyVoiceMessages })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyVoiceMessagesTitle')}</span>
@ -337,7 +336,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
rightElement={isCurrentUserPremium && <StarIcon size="big" type="premium" />}
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyMessages)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyMessages })}
>
<div className="multiline-item">
<span className="title">{oldLang('PrivacyMessagesTitle')}</span>
@ -353,7 +352,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
narrow
className="no-icon"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PrivacyGroupChats)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PrivacyGroupChats })}
>
<div className="multiline-item">
<span className="title">{oldLang('WhoCanAddMe')}</span>

View File

@ -26,7 +26,6 @@ import SettingsPrivacyPublicProfilePhoto from './SettingsPrivacyPublicProfilePho
type OwnProps = {
screen: SettingsScreens;
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -50,15 +49,14 @@ const SettingsPrivacyVisibility: FC<OwnProps & StateProps> = ({
hasCurrentUserFullInfo,
currentUserFallbackPhoto,
isPremiumRequired,
onScreenSelect,
onReset,
shouldDisplayGiftsButton,
isCurrentUserPremium,
}) => {
const lang = useLang();
const { updateGlobalPrivacySettings, showNotification } = getActions();
const lang = useLang();
useHistoryBack({
isActive,
onBack: onReset,
@ -120,7 +118,6 @@ const SettingsPrivacyVisibility: FC<OwnProps & StateProps> = ({
<PrivacySubsection
screen={screen}
privacy={primaryPrivacy}
onScreenSelect={onScreenSelect}
isPremiumRequired={isPremiumRequired}
/>
{screen === SettingsScreens.PrivacyProfilePhoto && primaryPrivacy?.visibility !== 'everybody' && (
@ -140,7 +137,6 @@ const SettingsPrivacyVisibility: FC<OwnProps & StateProps> = ({
<PrivacySubsection
screen={secondaryScreen}
privacy={secondaryPrivacy}
onScreenSelect={onScreenSelect}
/>
)}
</div>
@ -150,15 +146,13 @@ const SettingsPrivacyVisibility: FC<OwnProps & StateProps> = ({
function PrivacySubsection({
screen,
privacy,
onScreenSelect,
isPremiumRequired,
}: {
screen: SettingsScreens;
privacy?: ApiPrivacySettings;
isPremiumRequired?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
}) {
const { setPrivacyVisibility } = getActions();
const { setPrivacyVisibility, openSettingsScreen } = getActions();
const oldLang = useOldLang();
const lang = useLang();
@ -376,7 +370,7 @@ function PrivacySubsection({
icon="add-user"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => {
onScreenSelect(allowedContactsScreen);
openSettingsScreen({ screen: allowedContactsScreen });
}}
>
<div className="multiline-item full-size">
@ -391,7 +385,7 @@ function PrivacySubsection({
icon="delete-user"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => {
onScreenSelect(deniedContactsScreen);
openSettingsScreen({ screen: deniedContactsScreen });
}}
>
<div className="multiline-item full-size">

View File

@ -31,7 +31,6 @@ const DEFAULT_REACTION_SIZE = 1.5 * REM;
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -58,11 +57,11 @@ const SettingsStickers: FC<OwnProps & StateProps> = ({
availableReactions,
canPlayAnimatedEmojis,
onReset,
onScreenSelect,
}) => {
const {
setSettingOption,
openStickerSet,
openSettingsScreen,
} = getActions();
const lang = useOldLang();
@ -104,7 +103,7 @@ const SettingsStickers: FC<OwnProps & StateProps> = ({
<ListItem
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.CustomEmoji)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.CustomEmoji })}
icon="smile"
>
{lang('StickersList.EmojiItem')}
@ -115,7 +114,7 @@ const SettingsStickers: FC<OwnProps & StateProps> = ({
className="SettingsDefaultReaction"
narrow
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.QuickReaction)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.QuickReaction })}
>
<ReactionStaticEmoji
reaction={defaultReaction}

View File

@ -23,7 +23,6 @@ export type OwnProps = {
state: FoldersState;
dispatch: FolderEditDispatch;
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -33,13 +32,13 @@ const SettingsFolders: FC<OwnProps> = ({
state,
dispatch,
isActive,
onScreenSelect,
onReset,
}) => {
const {
openShareChatFolderModal,
editChatFolder,
addChatFolder,
openSettingsScreen,
} = getActions();
const handleReset = useCallback(() => {
@ -59,18 +58,15 @@ const SettingsFolders: FC<OwnProps> = ({
|| currentScreen === SettingsScreens.FoldersExcludedChats
) {
if (state.mode === 'create') {
onScreenSelect(SettingsScreens.FoldersCreateFolder);
openSettingsScreen({ screen: SettingsScreens.FoldersCreateFolder });
} else {
onScreenSelect(SettingsScreens.FoldersEditFolder);
openSettingsScreen({ screen: SettingsScreens.FoldersEditFolder });
}
return;
}
onReset();
}, [
state.mode, dispatch,
currentScreen, onReset, onScreenSelect,
]);
}, [state.mode, dispatch, currentScreen, onReset]);
const isCreating = state.mode === 'create';
@ -119,38 +115,42 @@ const SettingsFolders: FC<OwnProps> = ({
const handleCreateFolder = useCallback(() => {
dispatch({ type: 'reset' });
onScreenSelect(SettingsScreens.FoldersCreateFolder);
}, [onScreenSelect, dispatch]);
openSettingsScreen({ screen: SettingsScreens.FoldersCreateFolder });
}, [dispatch]);
const handleEditFolder = useCallback((folder: ApiChatFolder) => {
dispatch({ type: 'editFolder', payload: folder });
onScreenSelect(SettingsScreens.FoldersEditFolder);
}, [dispatch, onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.FoldersEditFolder });
}, [dispatch]);
const handleAddIncludedChats = useCallback(() => {
dispatch({ type: 'editIncludeFilters' });
onScreenSelect(currentScreen === SettingsScreens.FoldersEditFolderFromChatList
? SettingsScreens.FoldersIncludedChatsFromChatList
: SettingsScreens.FoldersIncludedChats);
}, [currentScreen, dispatch, onScreenSelect]);
openSettingsScreen({
screen: currentScreen === SettingsScreens.FoldersEditFolderFromChatList
? SettingsScreens.FoldersIncludedChatsFromChatList
: SettingsScreens.FoldersIncludedChats,
});
}, [currentScreen, dispatch]);
const handleAddExcludedChats = useCallback(() => {
dispatch({ type: 'editExcludeFilters' });
onScreenSelect(currentScreen === SettingsScreens.FoldersEditFolderFromChatList
? SettingsScreens.FoldersExcludedChatsFromChatList
: SettingsScreens.FoldersExcludedChats);
}, [currentScreen, dispatch, onScreenSelect]);
openSettingsScreen({
screen: currentScreen === SettingsScreens.FoldersEditFolderFromChatList
? SettingsScreens.FoldersExcludedChatsFromChatList
: SettingsScreens.FoldersExcludedChats,
});
}, [currentScreen, dispatch]);
const handleShareFolder = useCallback(() => {
openShareChatFolderModal({ folderId: state.folderId!, noRequestNextScreen: true });
dispatch({ type: 'setIsChatlist', payload: true });
onScreenSelect(SettingsScreens.FoldersShare);
}, [dispatch, onScreenSelect, state.folderId]);
openSettingsScreen({ screen: SettingsScreens.FoldersShare });
}, [dispatch, state.folderId]);
const handleOpenInvite = useCallback((url: string) => {
openShareChatFolderModal({ folderId: state.folderId!, url, noRequestNextScreen: true });
onScreenSelect(SettingsScreens.FoldersShare);
}, [onScreenSelect, state.folderId]);
openSettingsScreen({ screen: SettingsScreens.FoldersShare });
}, [state.folderId]);
switch (currentScreen) {
case SettingsScreens.Folders:

View File

@ -20,7 +20,6 @@ export type OwnProps = {
shownScreen: SettingsScreens;
isActive?: boolean;
onSetPasscode: (passcode: string) => void;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -33,7 +32,6 @@ const SettingsPasscode: FC<OwnProps & StateProps> = ({
error,
isActive,
isLoading,
onScreenSelect,
onSetPasscode,
onReset,
}) => {
@ -42,52 +40,53 @@ const SettingsPasscode: FC<OwnProps & StateProps> = ({
clearPasscode,
setPasscodeError,
clearPasscodeError,
openSettingsScreen,
} = getActions();
const lang = useOldLang();
const handleStartWizard = useCallback(() => {
onSetPasscode('');
onScreenSelect(SettingsScreens.PasscodeNewPasscode);
}, [onScreenSelect, onSetPasscode]);
openSettingsScreen({ screen: SettingsScreens.PasscodeNewPasscode });
}, [onSetPasscode]);
const handleNewPassword = useCallback((value: string) => {
onSetPasscode(value);
onScreenSelect(SettingsScreens.PasscodeNewPasscodeConfirm);
}, [onScreenSelect, onSetPasscode]);
openSettingsScreen({ screen: SettingsScreens.PasscodeNewPasscodeConfirm });
}, [onSetPasscode]);
const handleNewPasswordConfirm = useCallback(() => {
setPasscode({ passcode });
onSetPasscode('');
onScreenSelect(SettingsScreens.PasscodeCongratulations);
}, [onScreenSelect, onSetPasscode, passcode, setPasscode]);
openSettingsScreen({ screen: SettingsScreens.PasscodeCongratulations });
}, [onSetPasscode, passcode]);
const handleChangePasswordCurrent = useCallback((currentPasscode: string) => {
onSetPasscode('');
decryptSession(currentPasscode).then(() => {
onScreenSelect(SettingsScreens.PasscodeChangePasscodeNew);
openSettingsScreen({ screen: SettingsScreens.PasscodeChangePasscodeNew });
}, () => {
setPasscodeError({
error: lang('PasscodeController.Error.Current'),
});
});
}, [lang, onScreenSelect, onSetPasscode, setPasscodeError]);
}, [lang, onSetPasscode]);
const handleChangePasswordNew = useCallback((value: string) => {
onSetPasscode(value);
onScreenSelect(SettingsScreens.PasscodeChangePasscodeConfirm);
}, [onScreenSelect, onSetPasscode]);
openSettingsScreen({ screen: SettingsScreens.PasscodeChangePasscodeConfirm });
}, [onSetPasscode]);
const handleTurnOff = useCallback((currentPasscode: string) => {
decryptSession(currentPasscode).then(() => {
clearPasscode();
onScreenSelect(SettingsScreens.Privacy);
openSettingsScreen({ screen: SettingsScreens.Privacy });
}, () => {
setPasscodeError({
error: lang('PasscodeController.Error.Current'),
});
});
}, [clearPasscode, lang, onScreenSelect, setPasscodeError]);
}, [lang]);
switch (currentScreen) {
case SettingsScreens.PasscodeDisabled:
@ -145,7 +144,6 @@ const SettingsPasscode: FC<OwnProps & StateProps> = ({
case SettingsScreens.PasscodeEnabled:
return (
<SettingsPasscodeEnabled
onScreenSelect={onScreenSelect}
isActive={isActive || [
SettingsScreens.PasscodeChangePasscodeCurrent,
SettingsScreens.PasscodeChangePasscodeNew,

View File

@ -1,5 +1,6 @@
import type { FC } from '../../../../lib/teact/teact';
import React, { memo } from '../../../../lib/teact/teact';
import { getActions } from '../../../../global';
import { SettingsScreens } from '../../../../types';
@ -15,13 +16,13 @@ import lockPreviewUrl from '../../../../assets/lock.png';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
const SettingsPasscodeEnabled: FC<OwnProps> = ({
isActive, onReset, onScreenSelect,
isActive, onReset,
}) => {
const { openSettingsScreen } = getActions();
const lang = useOldLang();
useHistoryBack({ isActive, onBack: onReset });
@ -45,14 +46,14 @@ const SettingsPasscodeEnabled: FC<OwnProps> = ({
<ListItem
icon="edit"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PasscodeChangePasscodeCurrent)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PasscodeChangePasscodeCurrent })}
>
{lang('Passcode.Change')}
</ListItem>
<ListItem
icon="password-off"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.PasscodeTurnOff)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.PasscodeTurnOff })}
>
{lang('Passcode.TurnOff')}
</ListItem>

View File

@ -22,7 +22,6 @@ export type OwnProps = {
shownScreen: SettingsScreens;
dispatch: TwoFaDispatch;
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
@ -38,7 +37,6 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
waitingEmailCodeLength,
dispatch,
isActive,
onScreenSelect,
onReset,
}) => {
const {
@ -48,6 +46,7 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
updateRecoveryEmail,
provideTwoFaEmailCode,
clearPassword,
openSettingsScreen,
} = getActions();
const lang = useLang();
@ -56,31 +55,31 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
useEffect(() => {
if (waitingEmailCodeLength) {
if (currentScreen === SettingsScreens.TwoFaNewPasswordEmail) {
onScreenSelect(SettingsScreens.TwoFaNewPasswordEmailCode);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordEmailCode });
} else if (currentScreen === SettingsScreens.TwoFaRecoveryEmail) {
onScreenSelect(SettingsScreens.TwoFaRecoveryEmailCode);
openSettingsScreen({ screen: SettingsScreens.TwoFaRecoveryEmailCode });
}
}
}, [currentScreen, onScreenSelect, waitingEmailCodeLength]);
}, [currentScreen, waitingEmailCodeLength, openSettingsScreen]);
const handleStartWizard = useCallback(() => {
dispatch({ type: 'reset' });
onScreenSelect(SettingsScreens.TwoFaNewPassword);
}, [dispatch, onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPassword });
}, [dispatch, openSettingsScreen]);
const handleNewPassword = useCallback((value: string) => {
dispatch({ type: 'setPassword', payload: value });
onScreenSelect(SettingsScreens.TwoFaNewPasswordConfirm);
}, [dispatch, onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordConfirm });
}, [dispatch, openSettingsScreen]);
const handleNewPasswordConfirm = useCallback(() => {
onScreenSelect(SettingsScreens.TwoFaNewPasswordHint);
}, [onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordHint });
}, [openSettingsScreen]);
const handleNewPasswordHint = useCallback((value?: string) => {
dispatch({ type: 'setHint', payload: value });
onScreenSelect(SettingsScreens.TwoFaNewPasswordEmail);
}, [dispatch, onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.TwoFaNewPasswordEmail });
}, [dispatch, openSettingsScreen]);
const handleNewPasswordEmail = useCallback((value?: string) => {
dispatch({ type: 'setEmail', payload: value });
@ -88,29 +87,29 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
...state,
email: value,
onSuccess: () => {
onScreenSelect(SettingsScreens.TwoFaCongratulations);
openSettingsScreen({ screen: SettingsScreens.TwoFaCongratulations });
},
});
}, [dispatch, onScreenSelect, state, updatePassword]);
}, [dispatch, state, updatePassword, openSettingsScreen]);
const handleChangePasswordCurrent = useCallback((value: string) => {
dispatch({ type: 'setCurrentPassword', payload: value });
checkPassword({
currentPassword: value,
onSuccess: () => {
onScreenSelect(SettingsScreens.TwoFaChangePasswordNew);
openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordNew });
},
});
}, [checkPassword, dispatch, onScreenSelect]);
}, [checkPassword, dispatch, openSettingsScreen]);
const handleChangePasswordNew = useCallback((value: string) => {
dispatch({ type: 'setPassword', payload: value });
onScreenSelect(SettingsScreens.TwoFaChangePasswordConfirm);
}, [dispatch, onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordConfirm });
}, [dispatch, openSettingsScreen]);
const handleChangePasswordConfirm = useCallback(() => {
onScreenSelect(SettingsScreens.TwoFaChangePasswordHint);
}, [onScreenSelect]);
openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordHint });
}, [openSettingsScreen]);
const handleChangePasswordHint = useCallback((value?: string) => {
dispatch({ type: 'setHint', payload: value });
@ -118,29 +117,29 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
...state,
hint: value,
onSuccess: () => {
onScreenSelect(SettingsScreens.TwoFaCongratulations);
openSettingsScreen({ screen: SettingsScreens.TwoFaCongratulations });
},
});
}, [dispatch, onScreenSelect, state, updatePassword]);
}, [dispatch, state, updatePassword, openSettingsScreen]);
const handleTurnOff = useCallback((value: string) => {
clearPassword({
currentPassword: value,
onSuccess: () => {
onScreenSelect(SettingsScreens.Privacy);
openSettingsScreen({ screen: SettingsScreens.Privacy });
},
});
}, [clearPassword, onScreenSelect]);
}, [clearPassword, openSettingsScreen]);
const handleRecoveryEmailCurrentPassword = useCallback((value: string) => {
dispatch({ type: 'setCurrentPassword', payload: value });
checkPassword({
currentPassword: value,
onSuccess: () => {
onScreenSelect(SettingsScreens.TwoFaRecoveryEmail);
openSettingsScreen({ screen: SettingsScreens.TwoFaRecoveryEmail });
},
});
}, [checkPassword, dispatch, onScreenSelect]);
}, [checkPassword, dispatch, openSettingsScreen]);
const handleRecoveryEmail = useCallback((value?: string) => {
dispatch({ type: 'setEmail', payload: value });
@ -148,10 +147,10 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
...state,
email: value!,
onSuccess: () => {
onScreenSelect(SettingsScreens.TwoFaCongratulations);
openSettingsScreen({ screen: SettingsScreens.TwoFaCongratulations });
},
});
}, [dispatch, onScreenSelect, state, updateRecoveryEmail]);
}, [dispatch, state, updateRecoveryEmail, openSettingsScreen]);
const handleEmailCode = useCallback((code: string) => {
provideTwoFaEmailCode({ code });
@ -257,7 +256,6 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
case SettingsScreens.TwoFaCongratulations:
return (
<SettingsTwoFaCongratulations
onScreenSelect={onScreenSelect}
isActive={isActive}
onReset={onReset}
/>
@ -266,7 +264,6 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
case SettingsScreens.TwoFaEnabled:
return (
<SettingsTwoFaEnabled
onScreenSelect={onScreenSelect}
isActive={isActive || [
SettingsScreens.TwoFaChangePasswordCurrent,
SettingsScreens.TwoFaChangePasswordNew,

View File

@ -1,5 +1,6 @@
import type { FC } from '../../../../lib/teact/teact';
import React, { memo, useCallback } from '../../../../lib/teact/teact';
import React, { memo } from '../../../../lib/teact/teact';
import { getActions } from '../../../../global';
import { SettingsScreens } from '../../../../types';
@ -7,6 +8,7 @@ import { STICKER_SIZE_TWO_FA } from '../../../../config';
import { LOCAL_TGS_URLS } from '../../../common/helpers/animatedAssets';
import useHistoryBack from '../../../../hooks/useHistoryBack';
import useLastCallback from '../../../../hooks/useLastCallback';
import useOldLang from '../../../../hooks/useOldLang';
import AnimatedIcon from '../../../common/AnimatedIcon';
@ -14,18 +16,18 @@ import Button from '../../../ui/Button';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
const SettingsTwoFaCongratulations: FC<OwnProps> = ({
isActive, onReset, onScreenSelect,
isActive, onReset,
}) => {
const { openSettingsScreen } = getActions();
const lang = useOldLang();
const handleClick = useCallback(() => {
onScreenSelect(SettingsScreens.Privacy);
}, [onScreenSelect]);
const handleClick = useLastCallback(() => {
openSettingsScreen({ screen: SettingsScreens.Privacy });
});
useHistoryBack({
isActive,

View File

@ -1,5 +1,6 @@
import type { FC } from '../../../../lib/teact/teact';
import React, { memo } from '../../../../lib/teact/teact';
import { getActions } from '../../../../global';
import { SettingsScreens } from '../../../../types';
@ -16,13 +17,13 @@ import lockPreviewUrl from '../../../../assets/lock.png';
type OwnProps = {
isActive?: boolean;
onScreenSelect: (screen: SettingsScreens) => void;
onReset: () => void;
};
const SettingsTwoFaEnabled: FC<OwnProps> = ({
isActive, onReset, onScreenSelect,
isActive, onReset,
}) => {
const { openSettingsScreen } = getActions();
const lang = useOldLang();
useHistoryBack({
@ -49,21 +50,21 @@ const SettingsTwoFaEnabled: FC<OwnProps> = ({
<ListItem
icon="edit"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.TwoFaChangePasswordCurrent)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.TwoFaChangePasswordCurrent })}
>
{lang('ChangePassword')}
</ListItem>
<ListItem
icon="password-off"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.TwoFaTurnOff)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.TwoFaTurnOff })}
>
{lang('TurnPasswordOff')}
</ListItem>
<ListItem
icon="email"
// eslint-disable-next-line react/jsx-no-bind
onClick={() => onScreenSelect(SettingsScreens.TwoFaRecoveryEmailCurrentPassword)}
onClick={() => openSettingsScreen({ screen: SettingsScreens.TwoFaRecoveryEmailCurrentPassword })}
>
{lang('SetRecoveryEmail')}
</ListItem>

View File

@ -67,7 +67,7 @@ const SuggestedPhotoAction = ({
title: lang('ActionSuggestedPhotoUpdatedTitle'),
message: lang('ActionSuggestedPhotoUpdatedDescription'),
action: {
action: 'requestNextSettingsScreen',
action: 'openSettingsScreen',
payload: {
screen: SettingsScreens.Main,
},

View File

@ -6,7 +6,7 @@ import { getActions, withGlobal } from '../../../../global';
import type { ApiStarGiftUnique } from '../../../../api/types';
import type { TabState } from '../../../../global/types';
import type { CustomPeer } from '../../../../types';
import { type CustomPeer, SettingsScreens } from '../../../../types';
import { getDays } from '../../../../util/dates/units';
import { getServerTime } from '../../../../util/serverTime';
@ -22,6 +22,7 @@ import Avatar from '../../../common/Avatar';
import Icon from '../../../common/icons/Icon';
import PasswordForm from '../../../common/PasswordForm';
import RadialPatternBackground from '../../../common/profile/RadialPatternBackground';
import Button from '../../../ui/Button';
import Modal from '../../../ui/Modal';
import styles from './GiftWithdrawModal.module.scss';
@ -44,7 +45,13 @@ const FRAGMENT_PEER: CustomPeer = {
const GIFT_STICKER_SIZE = 4.5 * REM;
const GiftWithdrawModal = ({ modal, hasPassword, passwordHint }: OwnProps & StateProps) => {
const { closeGiftWithdrawModal, clearGiftWithdrawError, processStarGiftWithdrawal } = getActions();
const {
closeGiftWithdrawModal,
clearGiftWithdrawError,
closeGiftInfoModal,
processStarGiftWithdrawal,
openSettingsScreen,
} = getActions();
const isOpen = Boolean(modal);
const [shouldShowPassword, setShouldShowPassword] = useState(false);
@ -68,6 +75,14 @@ const GiftWithdrawModal = ({ modal, hasPassword, passwordHint }: OwnProps & Stat
});
});
const handleSetUpPassword = useLastCallback(() => {
openSettingsScreen({
screen: SettingsScreens.TwoFaDisabled,
});
closeGiftWithdrawModal();
closeGiftInfoModal();
});
return (
<Modal
isOpen={isOpen}
@ -115,7 +130,12 @@ const GiftWithdrawModal = ({ modal, hasPassword, passwordHint }: OwnProps & Stat
{lang('GiftWithdrawWait', { days: getDays(exportDelay) }, { pluralValue: getDays(exportDelay) })}
</p>
)}
{!hasPassword && <span className={styles.noPassword}>{lang('ErrorPasswordMissing')}</span>}
{!hasPassword && (
<>
<span className={styles.noPassword}>{lang('ErrorPasswordMissing')}</span>
<Button size="smaller" onClick={handleSetUpPassword}>{lang('SetUp2FA')}</Button>
</>
)}
{hasPassword && !exportDelay && (
<PasswordForm
shouldShowSubmit

View File

@ -1140,7 +1140,7 @@ addActionHandler('addChatFolder', async (global, actions, payload): Promise<void
folder: folderUpdate,
});
actions.requestNextSettingsScreen({
actions.requestNextFoldersAction({
foldersAction: {
type: 'setFolderId',
payload: maxId + 1,
@ -2629,7 +2629,7 @@ addActionHandler('createChatlistInvite', async (global, actions, payload): Promi
} catch (error) {
if (CHATLIST_LIMIT_ERROR_LIST.has((error as ApiError).message)) {
actions.openLimitReachedModal({ limit: 'chatlistInvites', tabId });
actions.requestNextSettingsScreen({ screen: SettingsScreens.Folders, tabId });
actions.openSettingsScreen({ screen: SettingsScreens.Folders, tabId });
} else {
actions.showDialog({ data: { ...(error as ApiError), hasErrorKey: true }, tabId });
}

View File

@ -66,7 +66,7 @@ addActionHandler('setPasscode', async (global, actions, payload): Promise<void>
message: 'Failed to set passcode',
tabId,
});
actions.requestNextSettingsScreen({ screen: SettingsScreens.PasscodeDisabled, tabId });
actions.openSettingsScreen({ screen: SettingsScreens.PasscodeDisabled, tabId });
}
});

View File

@ -1,7 +1,7 @@
import { addCallback } from '../../../lib/teact/teactn';
import type { ActionReturnType, GlobalState } from '../../types';
import { type LangCode, SettingsScreens } from '../../../types';
import { type LangCode, LeftColumnContent, SettingsScreens } from '../../../types';
import { requestMutation } from '../../../lib/fasterdom/fasterdom';
import { IS_IOS } from '../../../util/browser/windowEnvironment';
@ -17,7 +17,7 @@ import {
} from '../../index';
import { replaceSettings, updateSharedSettings, updateThemeSettings } from '../../reducers';
import { updateTabState } from '../../reducers/tabs';
import { selectCanAnimateInterface, selectChatFolder } from '../../selectors';
import { selectCanAnimateInterface, selectChatFolder, selectTabState } from '../../selectors';
import { selectSharedSettings } from '../../selectors/sharedState';
let prevGlobal: GlobalState | undefined;
@ -142,22 +142,48 @@ addActionHandler('setThemeSettings', (global, actions, payload): ActionReturnTyp
return updateThemeSettings(global, theme, settings);
});
addActionHandler('requestNextSettingsScreen', (global, actions, payload): ActionReturnType => {
const { screen, foldersAction, tabId = getCurrentTabId() } = payload;
addActionHandler('requestNextFoldersAction', (global, actions, payload): ActionReturnType => {
const { foldersAction, tabId = getCurrentTabId() } = payload;
return updateTabState(global, {
nextSettingsScreen: screen,
nextFoldersAction: foldersAction,
}, tabId);
});
addActionHandler('openLeftColumnContent', (global, actions, payload): ActionReturnType => {
const { contentKey = LeftColumnContent.ChatList, tabId = getCurrentTabId() } = payload;
const tabState = selectTabState(global, tabId);
return updateTabState(global, {
leftColumn: {
...tabState.leftColumn,
contentKey,
},
}, tabId);
});
addActionHandler('openSettingsScreen', (global, actions, payload): ActionReturnType => {
const { screen = SettingsScreens.Main, tabId = getCurrentTabId() } = payload;
const tabState = selectTabState(global, tabId);
// Force settings only if new screen is passed, do not on resets
if (payload.screen) actions.openLeftColumnContent({ contentKey: LeftColumnContent.Settings, tabId });
return updateTabState(global, {
leftColumn: {
...tabState.leftColumn,
settingsScreen: screen,
},
}, tabId);
});
addActionHandler('openEditChatFolder', (global, actions, payload): ActionReturnType => {
const { folderId, isOnlyInvites, tabId = getCurrentTabId() } = payload;
const chatFolder = selectChatFolder(global, folderId);
if (!chatFolder) return;
actions.requestNextSettingsScreen({
actions.openSettingsScreen({
screen: isOnlyInvites ? SettingsScreens.FoldersEditFolderInvites : SettingsScreens.FoldersEditFolderFromChatList,
tabId,
});
actions.requestNextFoldersAction({
foldersAction: {
type: 'editFolder',
payload: chatFolder,
@ -178,7 +204,7 @@ addActionHandler('openShareChatFolderModal', (global, actions, payload): ActionR
return undefined;
}
if (!noRequestNextScreen) actions.requestNextSettingsScreen({ screen: SettingsScreens.FoldersShare, tabId });
if (!noRequestNextScreen) actions.openSettingsScreen({ screen: SettingsScreens.FoldersShare, tabId });
return updateTabState(global, {
shareFolderScreen: {
@ -192,7 +218,7 @@ addActionHandler('openShareChatFolderModal', (global, actions, payload): ActionR
addActionHandler('closeShareChatFolderModal', (global, actions, payload): ActionReturnType => {
const { tabId = getCurrentTabId() } = payload || {};
actions.requestNextSettingsScreen({ screen: undefined, tabId });
actions.openSettingsScreen({ screen: undefined, tabId });
return updateTabState(global, {
shareFolderScreen: undefined,

View File

@ -1,6 +1,6 @@
import type { PerformanceType } from '../types';
import type { GlobalState, SharedState, TabState } from './types';
import { NewChatMembersProgress } from '../types';
import { LeftColumnContent, NewChatMembersProgress, SettingsScreens } from '../types';
import {
ANIMATION_LEVEL_DEFAULT,
@ -361,6 +361,11 @@ export const INITIAL_TAB_STATE: TabState = {
userSearch: {},
leftColumn: {
contentKey: LeftColumnContent.ChatList,
settingsScreen: SettingsScreens.Main,
},
middleSearch: {
byChatThreadKey: {},
},

View File

@ -168,3 +168,15 @@ export function selectActiveWebApp<T extends GlobalState>(
return selectWebApp(global, activeWebAppKey, tabId);
}
export function selectLeftColumnContentKey<T extends GlobalState>(
global: T, ...[tabId = getCurrentTabId()]: TabArgs<T>
) {
return selectTabState(global, tabId).leftColumn.contentKey;
}
export function selectSettingsScreen<T extends GlobalState>(
global: T, ...[tabId = getCurrentTabId()]: TabArgs<T>
) {
return selectTabState(global, tabId).leftColumn.settingsScreen;
}

View File

@ -67,6 +67,7 @@ import type {
GlobalSearchContent,
IAnchorPosition,
IThemeSettings,
LeftColumnContent,
LoadMoreDirection,
ManagementScreens,
MediaViewerMedia,
@ -2308,8 +2309,13 @@ export interface ActionPayloads {
} | undefined;
loadPeerColors: undefined;
loadTimezones: undefined;
requestNextSettingsScreen: {
openLeftColumnContent: {
contentKey?: LeftColumnContent;
} & WithTabId;
openSettingsScreen: {
screen?: SettingsScreens;
} & WithTabId;
requestNextFoldersAction: {
foldersAction?: ReducerAction<FoldersActions>;
} & WithTabId;
sortChatFolders: { folderIds: number[] };

View File

@ -65,6 +65,7 @@ import type {
GlobalSearchContent,
IAnchorPosition,
InlineBotSettings,
LeftColumnContent,
ManagementProgress,
ManagementState,
MediaViewerMedia,
@ -120,7 +121,6 @@ export type TabState = {
shouldCloseRightColumn?: boolean;
nextProfileTab?: ProfileTabType;
forceScrollProfileTab?: boolean;
nextSettingsScreen?: SettingsScreens;
nextFoldersAction?: ReducerAction<FoldersActions>;
shareFolderScreen?: {
folderId: number;
@ -217,6 +217,11 @@ export type TabState = {
filter: GiftProfileFilterOptions;
};
leftColumn: {
contentKey: LeftColumnContent;
settingsScreen: SettingsScreens;
};
globalSearch: {
query?: string;
minDate?: number;

View File

@ -1368,6 +1368,7 @@ export interface LangPair {
'GiftFilterHidden': undefined;
'GiftSearchEmpty': undefined;
'GiftSearchReset': undefined;
'SetUp2FA': undefined;
'CheckPasswordTitle': undefined;
'CheckPasswordPlaceholder': undefined;
'CheckPasswordDescription': undefined;