2024-02-06 02:13:13 +00:00
|
|
|
// Copyright 2024 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo, useMemo } from 'react';
|
2024-02-06 02:13:13 +00:00
|
|
|
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>;
|
|
|
|
}>;
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartCollidingAvatars = memo(function SmartCollidingAvatars({
|
2024-02-06 02:13:13 +00:00
|
|
|
conversationIds,
|
2024-03-13 20:44:13 +00:00
|
|
|
}: PropsType) {
|
2024-02-06 02:13:13 +00:00
|
|
|
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} />;
|
2024-03-13 20:44:13 +00:00
|
|
|
});
|