mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-03 10:07:55 +01:00
New Chat Form: Hide Saved Messages (#1022)
This commit is contained in:
parent
8594981a51
commit
b0d8edd9e9
@ -25,6 +25,7 @@ export type OwnProps = {
|
||||
};
|
||||
|
||||
type StateProps = {
|
||||
currentUserId?: number;
|
||||
usersById: Record<number, ApiUser>;
|
||||
localContactIds?: number[];
|
||||
searchQuery?: string;
|
||||
@ -43,6 +44,7 @@ const NewChatStep1: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
onSelectedMemberIdsChange,
|
||||
onNextStep,
|
||||
onReset,
|
||||
currentUserId,
|
||||
usersById,
|
||||
localContactIds,
|
||||
searchQuery,
|
||||
@ -65,18 +67,20 @@ const NewChatStep1: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
}, [setGlobalSearchQuery]);
|
||||
|
||||
const displayedIds = useMemo(() => {
|
||||
const contactIds = localContactIds ? localContactIds.filter((id) => id !== currentUserId) : [];
|
||||
|
||||
if (!searchQuery) {
|
||||
return localContactIds || [];
|
||||
return contactIds;
|
||||
}
|
||||
|
||||
const foundLocalContacts = localContactIds ? localContactIds.filter((id) => {
|
||||
const foundLocalContacts = contactIds.filter((id) => {
|
||||
const user = usersById[id];
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
const fullName = getUserFullName(user);
|
||||
return fullName && searchWords(fullName, searchQuery);
|
||||
}) : [];
|
||||
});
|
||||
|
||||
return getSortedUserIds(
|
||||
unique([
|
||||
@ -87,7 +91,7 @@ const NewChatStep1: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
usersById,
|
||||
selectedMemberIds,
|
||||
);
|
||||
}, [searchQuery, localContactIds, localUsers, globalUsers, usersById, selectedMemberIds]);
|
||||
}, [localContactIds, searchQuery, localUsers, globalUsers, usersById, selectedMemberIds, currentUserId]);
|
||||
|
||||
const handleNextStep = useCallback(() => {
|
||||
if (selectedMemberIds.length) {
|
||||
@ -140,6 +144,7 @@ export default memo(withGlobal<OwnProps>(
|
||||
(global): StateProps => {
|
||||
const { userIds: localContactIds } = global.contactList || {};
|
||||
const { byId: usersById } = global.users;
|
||||
const { currentUserId } = global;
|
||||
|
||||
const {
|
||||
query: searchQuery,
|
||||
@ -151,6 +156,7 @@ export default memo(withGlobal<OwnProps>(
|
||||
const { users: localUsers } = localResults || {};
|
||||
|
||||
return {
|
||||
currentUserId,
|
||||
usersById,
|
||||
localContactIds,
|
||||
searchQuery,
|
||||
|
Loading…
Reference in New Issue
Block a user