Settings Folders: Save state only from main screen (#6218)

This commit is contained in:
Alexander Zinchuk 2025-09-19 14:34:45 +02:00
parent 7cfaadefb1
commit 174c97e1ae
3 changed files with 6 additions and 5 deletions

View File

@ -71,7 +71,7 @@ const SettingsFolders: FC<OwnProps> = ({
const isCreating = state.mode === 'create'; const isCreating = state.mode === 'create';
const saveState = useCallback((newState: FoldersState) => { const saveState = useCallback((newState: FoldersState) => {
const { title } = newState.folder; const { title: { text: title } } = newState.folder;
if (!title) { if (!title) {
dispatch({ type: 'setError', payload: ERROR_NO_TITLE }); dispatch({ type: 'setError', payload: ERROR_NO_TITLE });
@ -108,10 +108,9 @@ const SettingsFolders: FC<OwnProps> = ({
}, [saveState, state]); }, [saveState, state]);
const handleSaveFilter = useCallback(() => { const handleSaveFilter = useCallback(() => {
const newState = dispatch({ type: 'saveFilters' }); dispatch({ type: 'saveFilters' });
handleReset(); handleReset();
saveState(newState); }, [dispatch, handleReset]);
}, [dispatch, handleReset, saveState]);
const handleCreateFolder = useCallback(() => { const handleCreateFolder = useCallback(() => {
dispatch({ type: 'reset' }); dispatch({ type: 'reset' });

View File

@ -11,7 +11,7 @@ import type {
FoldersState, FoldersState,
} from '../../../../hooks/reducers/useFoldersReducer'; } from '../../../../hooks/reducers/useFoldersReducer';
import { STICKER_SIZE_FOLDER_SETTINGS } from '../../../../config'; import { FOLDER_TITLE_MAX_LENGTH, STICKER_SIZE_FOLDER_SETTINGS } from '../../../../config';
import { selectCanShareFolder, selectIsCurrentUserPremium } from '../../../../global/selectors'; import { selectCanShareFolder, selectIsCurrentUserPremium } from '../../../../global/selectors';
import { selectCurrentLimit } from '../../../../global/selectors/limits'; import { selectCurrentLimit } from '../../../../global/selectors/limits';
import buildClassName from '../../../../util/buildClassName'; import buildClassName from '../../../../util/buildClassName';
@ -309,6 +309,7 @@ const SettingsFoldersEdit: FC<OwnProps & StateProps> = ({
className="mb-0" className="mb-0"
label={lang('FilterNameHint')} label={lang('FilterNameHint')}
value={state.folder.title.text} value={state.folder.title.text}
maxLength={FOLDER_TITLE_MAX_LENGTH}
onChange={handleChange} onChange={handleChange}
error={state.error && state.error === ERROR_NO_TITLE ? ERROR_NO_TITLE : undefined} error={state.error && state.error === ERROR_NO_TITLE ? ERROR_NO_TITLE : undefined}
/> />

View File

@ -339,6 +339,7 @@ export const DEFAULT_GIF_SEARCH_BOT_USERNAME = 'gif';
export const ALL_FOLDER_ID = 0; export const ALL_FOLDER_ID = 0;
export const ARCHIVED_FOLDER_ID = 1; export const ARCHIVED_FOLDER_ID = 1;
export const SAVED_FOLDER_ID = -1; export const SAVED_FOLDER_ID = -1;
export const FOLDER_TITLE_MAX_LENGTH = 12;
export const DELETED_COMMENTS_CHANNEL_ID = '-1000000000777'; export const DELETED_COMMENTS_CHANNEL_ID = '-1000000000777';
export const MAX_MEDIA_FILES_FOR_ALBUM = 10; export const MAX_MEDIA_FILES_FOR_ALBUM = 10;
export const MAX_ACTIVE_PINNED_CHATS = 5; export const MAX_ACTIVE_PINNED_CHATS = 5;