2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2020-05-27 21:37:06 +00:00
|
|
|
import { ConversationHero } from '../../components/conversation/ConversationHero';
|
2021-11-02 23:01:13 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2023-03-08 02:15:25 +00:00
|
|
|
import { getHasStoriesSelector } from '../selectors/stories2';
|
2022-11-09 02:38:19 +00:00
|
|
|
import { isSignalConversation } from '../../util/isSignalConversation';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
|
|
|
import { useStoriesActions } from '../ducks/stories';
|
2020-05-27 21:37:06 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
type SmartHeroRowProps = Readonly<{
|
2020-05-27 21:37:06 +00:00
|
|
|
id: string;
|
2024-03-13 20:44:13 +00:00
|
|
|
}>;
|
2020-05-27 21:37:06 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartHeroRow = memo(function SmartHeroRow({
|
|
|
|
id,
|
|
|
|
}: SmartHeroRowProps) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
|
|
|
const hasStoriesSelector = useSelector(getHasStoriesSelector);
|
|
|
|
const conversationSelector = useSelector(getConversationSelector);
|
|
|
|
const conversation = conversationSelector(id);
|
|
|
|
if (conversation == null) {
|
2020-05-27 21:37:06 +00:00
|
|
|
throw new Error(`Did not find conversation ${id} in state!`);
|
|
|
|
}
|
2024-03-13 20:44:13 +00:00
|
|
|
const badge = getPreferredBadge(conversation.badges);
|
|
|
|
const hasStories = hasStoriesSelector(id);
|
|
|
|
const isSignalConversationValue = isSignalConversation(conversation);
|
|
|
|
const { unblurAvatar, updateSharedGroups } = useConversationsActions();
|
|
|
|
const { toggleAboutContactModal } = useGlobalModalActions();
|
|
|
|
const { viewUserStories } = useStoriesActions();
|
|
|
|
const {
|
|
|
|
about,
|
|
|
|
acceptedMessageRequest,
|
|
|
|
avatarPath,
|
|
|
|
groupDescription,
|
|
|
|
isMe,
|
|
|
|
membersCount,
|
|
|
|
phoneNumber,
|
|
|
|
profileName,
|
|
|
|
sharedGroupNames,
|
|
|
|
title,
|
|
|
|
type,
|
|
|
|
unblurredAvatarPath,
|
|
|
|
} = conversation;
|
|
|
|
return (
|
|
|
|
<ConversationHero
|
|
|
|
about={about}
|
|
|
|
acceptedMessageRequest={acceptedMessageRequest}
|
|
|
|
avatarPath={avatarPath}
|
|
|
|
badge={badge}
|
|
|
|
conversationType={type}
|
|
|
|
groupDescription={groupDescription}
|
|
|
|
hasStories={hasStories}
|
|
|
|
i18n={i18n}
|
|
|
|
id={id}
|
|
|
|
isMe={isMe}
|
|
|
|
isSignalConversation={isSignalConversationValue}
|
|
|
|
membersCount={membersCount}
|
|
|
|
phoneNumber={phoneNumber}
|
|
|
|
profileName={profileName}
|
|
|
|
sharedGroupNames={sharedGroupNames}
|
|
|
|
theme={theme}
|
|
|
|
title={title}
|
|
|
|
toggleAboutContactModal={toggleAboutContactModal}
|
|
|
|
unblurAvatar={unblurAvatar}
|
|
|
|
unblurredAvatarPath={unblurredAvatarPath}
|
|
|
|
updateSharedGroups={updateSharedGroups}
|
|
|
|
viewUserStories={viewUserStories}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|