Settings Folders: Save state only from main screen (#6218)
This commit is contained in:
parent
7cfaadefb1
commit
174c97e1ae
@ -71,7 +71,7 @@ const SettingsFolders: FC<OwnProps> = ({
|
||||
const isCreating = state.mode === 'create';
|
||||
|
||||
const saveState = useCallback((newState: FoldersState) => {
|
||||
const { title } = newState.folder;
|
||||
const { title: { text: title } } = newState.folder;
|
||||
|
||||
if (!title) {
|
||||
dispatch({ type: 'setError', payload: ERROR_NO_TITLE });
|
||||
@ -108,10 +108,9 @@ const SettingsFolders: FC<OwnProps> = ({
|
||||
}, [saveState, state]);
|
||||
|
||||
const handleSaveFilter = useCallback(() => {
|
||||
const newState = dispatch({ type: 'saveFilters' });
|
||||
dispatch({ type: 'saveFilters' });
|
||||
handleReset();
|
||||
saveState(newState);
|
||||
}, [dispatch, handleReset, saveState]);
|
||||
}, [dispatch, handleReset]);
|
||||
|
||||
const handleCreateFolder = useCallback(() => {
|
||||
dispatch({ type: 'reset' });
|
||||
|
||||
@ -11,7 +11,7 @@ import type {
|
||||
FoldersState,
|
||||
} 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 { selectCurrentLimit } from '../../../../global/selectors/limits';
|
||||
import buildClassName from '../../../../util/buildClassName';
|
||||
@ -309,6 +309,7 @@ const SettingsFoldersEdit: FC<OwnProps & StateProps> = ({
|
||||
className="mb-0"
|
||||
label={lang('FilterNameHint')}
|
||||
value={state.folder.title.text}
|
||||
maxLength={FOLDER_TITLE_MAX_LENGTH}
|
||||
onChange={handleChange}
|
||||
error={state.error && state.error === ERROR_NO_TITLE ? ERROR_NO_TITLE : undefined}
|
||||
/>
|
||||
|
||||
@ -339,6 +339,7 @@ export const DEFAULT_GIF_SEARCH_BOT_USERNAME = 'gif';
|
||||
export const ALL_FOLDER_ID = 0;
|
||||
export const ARCHIVED_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 MAX_MEDIA_FILES_FOR_ALBUM = 10;
|
||||
export const MAX_ACTIVE_PINNED_CHATS = 5;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user