mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-12 17:17:24 +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 = {
|
type StateProps = {
|
||||||
|
currentUserId?: number;
|
||||||
usersById: Record<number, ApiUser>;
|
usersById: Record<number, ApiUser>;
|
||||||
localContactIds?: number[];
|
localContactIds?: number[];
|
||||||
searchQuery?: string;
|
searchQuery?: string;
|
||||||
@ -43,6 +44,7 @@ const NewChatStep1: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
onSelectedMemberIdsChange,
|
onSelectedMemberIdsChange,
|
||||||
onNextStep,
|
onNextStep,
|
||||||
onReset,
|
onReset,
|
||||||
|
currentUserId,
|
||||||
usersById,
|
usersById,
|
||||||
localContactIds,
|
localContactIds,
|
||||||
searchQuery,
|
searchQuery,
|
||||||
@ -65,18 +67,20 @@ const NewChatStep1: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
}, [setGlobalSearchQuery]);
|
}, [setGlobalSearchQuery]);
|
||||||
|
|
||||||
const displayedIds = useMemo(() => {
|
const displayedIds = useMemo(() => {
|
||||||
|
const contactIds = localContactIds ? localContactIds.filter((id) => id !== currentUserId) : [];
|
||||||
|
|
||||||
if (!searchQuery) {
|
if (!searchQuery) {
|
||||||
return localContactIds || [];
|
return contactIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
const foundLocalContacts = localContactIds ? localContactIds.filter((id) => {
|
const foundLocalContacts = contactIds.filter((id) => {
|
||||||
const user = usersById[id];
|
const user = usersById[id];
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const fullName = getUserFullName(user);
|
const fullName = getUserFullName(user);
|
||||||
return fullName && searchWords(fullName, searchQuery);
|
return fullName && searchWords(fullName, searchQuery);
|
||||||
}) : [];
|
});
|
||||||
|
|
||||||
return getSortedUserIds(
|
return getSortedUserIds(
|
||||||
unique([
|
unique([
|
||||||
@ -87,7 +91,7 @@ const NewChatStep1: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
usersById,
|
usersById,
|
||||||
selectedMemberIds,
|
selectedMemberIds,
|
||||||
);
|
);
|
||||||
}, [searchQuery, localContactIds, localUsers, globalUsers, usersById, selectedMemberIds]);
|
}, [localContactIds, searchQuery, localUsers, globalUsers, usersById, selectedMemberIds, currentUserId]);
|
||||||
|
|
||||||
const handleNextStep = useCallback(() => {
|
const handleNextStep = useCallback(() => {
|
||||||
if (selectedMemberIds.length) {
|
if (selectedMemberIds.length) {
|
||||||
@ -140,6 +144,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
(global): StateProps => {
|
(global): StateProps => {
|
||||||
const { userIds: localContactIds } = global.contactList || {};
|
const { userIds: localContactIds } = global.contactList || {};
|
||||||
const { byId: usersById } = global.users;
|
const { byId: usersById } = global.users;
|
||||||
|
const { currentUserId } = global;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
query: searchQuery,
|
query: searchQuery,
|
||||||
@ -151,6 +156,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const { users: localUsers } = localResults || {};
|
const { users: localUsers } = localResults || {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
currentUserId,
|
||||||
usersById,
|
usersById,
|
||||||
localContactIds,
|
localContactIds,
|
||||||
searchQuery,
|
searchQuery,
|
||||||
|
Loading…
Reference in New Issue
Block a user