Forward Modal: Hotfix for duplicate Saved Messages in Forward Modal (#4917)

This commit is contained in:
Alexander Zinchuk 2024-08-29 15:52:51 +02:00
parent 0685adbfe8
commit d51fc2a3a2
2 changed files with 14 additions and 5 deletions

View File

@ -83,13 +83,16 @@ const RecipientPicker: FC<OwnProps & StateProps> = ({
return chat && getCanPostInChat(chat, MAIN_THREAD_ID, undefined, chatFullInfoById[id]);
});
const sorted = [
...(currentUserId ? [currentUserId] : []),
...sortChatIds(unique([
const sorted = sortChatIds(
unique([
...(currentUserId ? [currentUserId] : []),
...filterChatsByName(lang, chatIds, chatsById, search, currentUserId),
...(contactIds && filter.includes('users') ? filterUsersByName(contactIds, usersById, search) : []),
]), undefined, priorityIds),
];
]),
undefined,
priorityIds,
currentUserId,
);
return filterChatIdsByType(global, sorted, filter);
}, [pinnedIds, currentUserId, activeListIds, search, archivedListIds, lang, contactIds, filter, isOpen]);

View File

@ -10,10 +10,16 @@ export default function sortChatIds(
chatIds: string[],
shouldPrioritizeVerified = false,
priorityIds?: string[],
currentUserId?: string,
) {
// Avoid calling sort on every global change
const global = getGlobal();
return orderBy(chatIds, (id) => {
if (id === currentUserId) {
return Infinity;
}
const chat = selectChat(global, id);
if (!chat) {
return 0;