Folder Settings: Hide unknown chats (#4751)
This commit is contained in:
parent
43459b8ea9
commit
ff9a0e3fdf
@ -50,7 +50,7 @@ const SettingsFoldersChatFilters: FC<OwnProps & StateProps> = ({
|
|||||||
const { openLimitReachedModal } = getActions();
|
const { openLimitReachedModal } = getActions();
|
||||||
|
|
||||||
const { chatFilter } = state;
|
const { chatFilter } = state;
|
||||||
const { selectedChatIds, selectedChatTypes } = selectChatFilters(state, mode, true);
|
const { selectedChatIds, selectedChatTypes } = useMemo(() => selectChatFilters(state, mode, true), [mode, state]);
|
||||||
const chatTypes = mode === 'included' ? CUSTOM_PEER_INCLUDED_CHAT_TYPES : CUSTOM_PEER_EXCLUDED_CHAT_TYPES;
|
const chatTypes = mode === 'included' ? CUSTOM_PEER_INCLUDED_CHAT_TYPES : CUSTOM_PEER_EXCLUDED_CHAT_TYPES;
|
||||||
|
|
||||||
const [isTouched, setIsTouched] = useState(false);
|
const [isTouched, setIsTouched] = useState(false);
|
||||||
|
|||||||
@ -113,11 +113,11 @@ const SettingsFoldersEdit: FC<OwnProps & StateProps> = ({
|
|||||||
const {
|
const {
|
||||||
selectedChatIds: includedChatIds,
|
selectedChatIds: includedChatIds,
|
||||||
selectedChatTypes: includedChatTypes,
|
selectedChatTypes: includedChatTypes,
|
||||||
} = selectChatFilters(state, 'included');
|
} = useMemo(() => selectChatFilters(state, 'included'), [state]);
|
||||||
const {
|
const {
|
||||||
selectedChatIds: excludedChatIds,
|
selectedChatIds: excludedChatIds,
|
||||||
selectedChatTypes: excludedChatTypes,
|
selectedChatTypes: excludedChatTypes,
|
||||||
} = selectChatFilters(state, 'excluded');
|
} = useMemo(() => selectChatFilters(state, 'excluded'), [state]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsIncludedChatsListExpanded(false);
|
setIsIncludedChatsListExpanded(false);
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
|
import { getGlobal } from '../../global';
|
||||||
|
|
||||||
import type { ApiChatFolder } from '../../api/types';
|
import type { ApiChatFolder } from '../../api/types';
|
||||||
import type { IconName } from '../../types/icons';
|
import type { IconName } from '../../types/icons';
|
||||||
import type { Dispatch, StateReducer } from '../useReducer';
|
import type { Dispatch, StateReducer } from '../useReducer';
|
||||||
|
|
||||||
|
import { selectChat } from '../../global/selectors';
|
||||||
import { omit, pick } from '../../util/iteratees';
|
import { omit, pick } from '../../util/iteratees';
|
||||||
import useReducer from '../useReducer';
|
import useReducer from '../useReducer';
|
||||||
|
|
||||||
@ -69,8 +72,11 @@ export function selectChatFilters(state: FoldersState, mode: 'included' | 'exclu
|
|||||||
.filter((key) => Boolean(excludeFilters[key]));
|
.filter((key) => Boolean(excludeFilters[key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const global = getGlobal();
|
||||||
|
const existingSelectedChatIds = selectedChatIds.filter((id) => selectChat(global, id));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedChatIds,
|
selectedChatIds: existingSelectedChatIds,
|
||||||
selectedChatTypes,
|
selectedChatTypes,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user