signal-desktop/ts/state/smart/CollidingAvatars.tsx
Fedor Indutny eb82ace2de
Conversation details changes for PNP
Co-authored-by: Scott Nonnenberg <scott@signal.org>
2024-02-05 18:13:13 -08:00

28 lines
932 B
TypeScript

// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useMemo } from 'react';
import { useSelector } from 'react-redux';
import { CollidingAvatars } from '../../components/CollidingAvatars';
import { getIntl } from '../selectors/user';
import { getConversationSelector } from '../selectors/conversations';
export type PropsType = Readonly<{
conversationIds: ReadonlyArray<string>;
}>;
export function SmartCollidingAvatars({
conversationIds,
}: PropsType): JSX.Element {
const i18n = useSelector(getIntl);
const getConversation = useSelector(getConversationSelector);
const conversations = useMemo(() => {
return conversationIds.map(getConversation).sort((a, b) => {
return (b.profileLastUpdatedAt ?? 0) - (a.profileLastUpdatedAt ?? 0);
});
}, [conversationIds, getConversation]);
return <CollidingAvatars i18n={i18n} conversations={conversations} />;
}