2021-07-20 20:18:35 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React, { useState } from 'react';
|
2022-12-14 19:05:32 +00:00
|
|
|
import type {
|
|
|
|
ConversationType,
|
|
|
|
ShowConversationType,
|
|
|
|
} from '../state/ducks/conversations';
|
2021-07-20 20:18:35 +00:00
|
|
|
import { Intl } from './Intl';
|
2021-11-02 23:01:13 +00:00
|
|
|
import type { LocalizerType, ThemeType } from '../types/Util';
|
2021-07-20 20:18:35 +00:00
|
|
|
import { Modal } from './Modal';
|
|
|
|
import { ConversationListItem } from './conversationList/ConversationListItem';
|
|
|
|
|
|
|
|
type PropsType = {
|
|
|
|
groupAdmins: Array<ConversationType>;
|
|
|
|
i18n: LocalizerType;
|
2022-12-14 19:05:32 +00:00
|
|
|
showConversation: ShowConversationType;
|
2021-11-02 23:01:13 +00:00
|
|
|
theme: ThemeType;
|
2021-07-20 20:18:35 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AnnouncementsOnlyGroupBanner({
|
2021-07-20 20:18:35 +00:00
|
|
|
groupAdmins,
|
|
|
|
i18n,
|
2022-12-14 19:05:32 +00:00
|
|
|
showConversation,
|
2021-11-02 23:01:13 +00:00
|
|
|
theme,
|
2022-11-18 00:45:19 +00:00
|
|
|
}: PropsType): JSX.Element {
|
2021-07-20 20:18:35 +00:00
|
|
|
const [isShowingAdmins, setIsShowingAdmins] = useState(false);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{isShowingAdmins && (
|
|
|
|
<Modal
|
2022-09-27 20:24:21 +00:00
|
|
|
modalName="AnnouncmentsOnlyGroupBanner"
|
2021-07-20 20:18:35 +00:00
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => setIsShowingAdmins(false)}
|
2023-03-30 00:03:25 +00:00
|
|
|
title={i18n('icu:AnnouncementsOnlyGroupBanner--modal')}
|
2021-07-20 20:18:35 +00:00
|
|
|
>
|
|
|
|
{groupAdmins.map(admin => (
|
|
|
|
<ConversationListItem
|
|
|
|
{...admin}
|
2023-04-10 16:31:45 +00:00
|
|
|
draftPreview={undefined}
|
2022-12-14 19:05:32 +00:00
|
|
|
i18n={i18n}
|
2021-07-20 20:18:35 +00:00
|
|
|
lastMessage={undefined}
|
|
|
|
lastUpdated={undefined}
|
2022-12-14 19:05:32 +00:00
|
|
|
onClick={() => {
|
|
|
|
showConversation({ conversationId: admin.id });
|
|
|
|
}}
|
2021-11-02 23:01:13 +00:00
|
|
|
theme={theme}
|
2021-07-20 20:18:35 +00:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Modal>
|
|
|
|
)}
|
|
|
|
<div className="AnnouncementsOnlyGroupBanner__banner">
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
2023-03-30 00:03:25 +00:00
|
|
|
id="icu:AnnouncementsOnlyGroupBanner--announcements-only"
|
2023-03-27 23:37:39 +00:00
|
|
|
components={{
|
|
|
|
admins: (
|
|
|
|
<button
|
|
|
|
className="AnnouncementsOnlyGroupBanner__banner--admins"
|
|
|
|
type="button"
|
|
|
|
onClick={() => setIsShowingAdmins(true)}
|
|
|
|
>
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:AnnouncementsOnlyGroupBanner--admins')}
|
2023-03-27 23:37:39 +00:00
|
|
|
</button>
|
|
|
|
),
|
|
|
|
}}
|
2021-07-20 20:18:35 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|