2021-03-09 19:16:56 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 21:19:24 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
import React, { useState } from 'react';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
2021-10-20 23:46:41 +00:00
|
|
|
import { Button, ButtonIconType, ButtonVariant } from '../../Button';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationType } from '../../../state/ducks/conversations';
|
2021-11-17 21:11:21 +00:00
|
|
|
import type { PreferredBadgeSelectorType } from '../../../state/selectors/badges';
|
2021-03-11 21:29:31 +00:00
|
|
|
import { assert } from '../../../util/assert';
|
2021-08-05 12:35:33 +00:00
|
|
|
import { getMutedUntilText } from '../../../util/getMutedUntilText';
|
2021-05-03 23:24:40 +00:00
|
|
|
|
2021-11-02 23:01:13 +00:00
|
|
|
import type { LocalizerType, ThemeType } from '../../../types/Util';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { MediaItemType } from '../../../types/MediaItem';
|
2021-11-02 23:01:13 +00:00
|
|
|
import type { BadgeType } from '../../../badges/types';
|
2021-09-22 00:58:03 +00:00
|
|
|
import { CapabilityError } from '../../../types/errors';
|
2021-03-11 21:29:31 +00:00
|
|
|
import { missingCaseError } from '../../../util/missingCaseError';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
2021-06-25 23:52:56 +00:00
|
|
|
import { DisappearingTimerSelect } from '../../DisappearingTimerSelect';
|
2021-06-01 20:45:43 +00:00
|
|
|
|
2021-01-29 21:19:24 +00:00
|
|
|
import { PanelRow } from './PanelRow';
|
|
|
|
import { PanelSection } from './PanelSection';
|
2021-03-11 21:29:31 +00:00
|
|
|
import { AddGroupMembersModal } from './AddGroupMembersModal';
|
2021-01-29 21:19:24 +00:00
|
|
|
import { ConversationDetailsActions } from './ConversationDetailsActions';
|
|
|
|
import { ConversationDetailsHeader } from './ConversationDetailsHeader';
|
2021-10-20 23:46:41 +00:00
|
|
|
import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon';
|
2021-01-29 21:19:24 +00:00
|
|
|
import { ConversationDetailsMediaList } from './ConversationDetailsMediaList';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { GroupV2Membership } from './ConversationDetailsMembershipList';
|
|
|
|
import { ConversationDetailsMembershipList } from './ConversationDetailsMembershipList';
|
|
|
|
import type {
|
2021-05-13 14:47:30 +00:00
|
|
|
GroupV2PendingMembership,
|
|
|
|
GroupV2RequestingMembership,
|
|
|
|
} from './PendingInvites';
|
2021-03-11 21:29:31 +00:00
|
|
|
import { EditConversationAttributesModal } from './EditConversationAttributesModal';
|
|
|
|
import { RequestState } from './util';
|
2021-05-28 16:15:17 +00:00
|
|
|
import { getCustomColorStyle } from '../../../util/getCustomColorStyle';
|
2021-07-20 20:18:35 +00:00
|
|
|
import { ConfirmationDialog } from '../../ConfirmationDialog';
|
2021-10-20 23:46:41 +00:00
|
|
|
import { ConversationNotificationsModal } from './ConversationNotificationsModal';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type {
|
2021-08-06 00:17:05 +00:00
|
|
|
AvatarDataType,
|
|
|
|
DeleteAvatarFromDiskActionType,
|
|
|
|
ReplaceAvatarActionType,
|
|
|
|
SaveAvatarToDiskActionType,
|
|
|
|
} from '../../../types/Avatar';
|
2021-10-20 23:46:41 +00:00
|
|
|
import { isMuted } from '../../../util/isMuted';
|
2021-03-11 21:29:31 +00:00
|
|
|
|
|
|
|
enum ModalState {
|
|
|
|
NothingOpen,
|
2021-06-03 00:07:37 +00:00
|
|
|
EditingGroupDescription,
|
|
|
|
EditingGroupTitle,
|
2021-03-11 21:29:31 +00:00
|
|
|
AddingGroupMembers,
|
2021-10-20 23:46:41 +00:00
|
|
|
MuteNotifications,
|
|
|
|
UnmuteNotifications,
|
2021-03-11 21:29:31 +00:00
|
|
|
}
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
export type StateProps = {
|
2021-03-11 21:29:31 +00:00
|
|
|
addMembers: (conversationIds: ReadonlyArray<string>) => Promise<void>;
|
2021-11-02 23:01:13 +00:00
|
|
|
badges?: ReadonlyArray<BadgeType>;
|
2021-01-29 21:19:24 +00:00
|
|
|
canEditGroupInfo: boolean;
|
2021-03-11 21:29:31 +00:00
|
|
|
candidateContactsToAdd: Array<ConversationType>;
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation?: ConversationType;
|
|
|
|
hasGroupLink: boolean;
|
2021-11-17 21:11:21 +00:00
|
|
|
getPreferredBadge: PreferredBadgeSelectorType;
|
2021-01-29 21:19:24 +00:00
|
|
|
i18n: LocalizerType;
|
|
|
|
isAdmin: boolean;
|
2021-10-20 23:46:41 +00:00
|
|
|
isGroup: boolean;
|
2021-01-29 21:19:24 +00:00
|
|
|
loadRecentMediaItems: (limit: number) => void;
|
2021-04-29 18:32:38 +00:00
|
|
|
memberships: Array<GroupV2Membership>;
|
2021-05-13 14:47:30 +00:00
|
|
|
pendingApprovalMemberships: ReadonlyArray<GroupV2RequestingMembership>;
|
|
|
|
pendingMemberships: ReadonlyArray<GroupV2PendingMembership>;
|
2021-01-29 21:19:24 +00:00
|
|
|
setDisappearingMessages: (seconds: number) => void;
|
|
|
|
showAllMedia: () => void;
|
2021-10-20 23:46:41 +00:00
|
|
|
showChatColorEditor: () => void;
|
2021-01-29 21:19:24 +00:00
|
|
|
showGroupLinkManagement: () => void;
|
|
|
|
showGroupV2Permissions: () => void;
|
|
|
|
showPendingInvites: () => void;
|
|
|
|
showLightboxForMedia: (
|
|
|
|
selectedMediaItem: MediaItemType,
|
|
|
|
media: Array<MediaItemType>
|
|
|
|
) => void;
|
2021-08-05 12:35:33 +00:00
|
|
|
showConversationNotificationsSettings: () => void;
|
2021-03-09 19:16:56 +00:00
|
|
|
updateGroupAttributes: (
|
|
|
|
_: Readonly<{
|
2021-09-24 00:49:05 +00:00
|
|
|
avatar?: undefined | Uint8Array;
|
2021-06-02 00:24:28 +00:00
|
|
|
description?: string;
|
2021-03-09 19:16:56 +00:00
|
|
|
title?: string;
|
|
|
|
}>
|
2021-03-12 23:31:47 +00:00
|
|
|
) => Promise<void>;
|
2021-04-28 20:27:16 +00:00
|
|
|
onBlock: () => void;
|
|
|
|
onLeave: () => void;
|
2021-10-20 23:46:41 +00:00
|
|
|
onUnblock: () => void;
|
2021-11-02 23:01:13 +00:00
|
|
|
theme: ThemeType;
|
2021-08-06 00:17:05 +00:00
|
|
|
userAvatarData: Array<AvatarDataType>;
|
2021-10-20 23:46:41 +00:00
|
|
|
setMuteExpiration: (muteExpiresAt: undefined | number) => unknown;
|
|
|
|
onOutgoingAudioCallInConversation: () => unknown;
|
|
|
|
onOutgoingVideoCallInConversation: () => unknown;
|
2021-08-06 00:17:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type ActionProps = {
|
|
|
|
deleteAvatarFromDisk: DeleteAvatarFromDiskActionType;
|
|
|
|
replaceAvatar: ReplaceAvatarActionType;
|
|
|
|
saveAvatarToDisk: SaveAvatarToDiskActionType;
|
2021-09-21 22:37:10 +00:00
|
|
|
showContactModal: (contactId: string, conversationId: string) => void;
|
2021-10-20 23:46:41 +00:00
|
|
|
toggleSafetyNumberModal: (conversationId: string) => unknown;
|
2021-11-01 18:43:02 +00:00
|
|
|
searchInConversation: (id: string) => unknown;
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|
|
|
|
|
2021-08-06 00:17:05 +00:00
|
|
|
export type Props = StateProps & ActionProps;
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
export const ConversationDetails: React.ComponentType<Props> = ({
|
2021-03-11 21:29:31 +00:00
|
|
|
addMembers,
|
2021-11-02 23:01:13 +00:00
|
|
|
badges,
|
2021-01-29 21:19:24 +00:00
|
|
|
canEditGroupInfo,
|
2021-03-11 21:29:31 +00:00
|
|
|
candidateContactsToAdd,
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation,
|
2021-10-20 23:46:41 +00:00
|
|
|
deleteAvatarFromDisk,
|
2021-01-29 21:19:24 +00:00
|
|
|
hasGroupLink,
|
2021-11-17 21:11:21 +00:00
|
|
|
getPreferredBadge,
|
2021-01-29 21:19:24 +00:00
|
|
|
i18n,
|
|
|
|
isAdmin,
|
2021-10-20 23:46:41 +00:00
|
|
|
isGroup,
|
2021-01-29 21:19:24 +00:00
|
|
|
loadRecentMediaItems,
|
2021-04-29 18:32:38 +00:00
|
|
|
memberships,
|
2021-10-20 23:46:41 +00:00
|
|
|
onBlock,
|
|
|
|
onLeave,
|
|
|
|
onOutgoingAudioCallInConversation,
|
|
|
|
onOutgoingVideoCallInConversation,
|
|
|
|
onUnblock,
|
2021-05-13 14:47:30 +00:00
|
|
|
pendingApprovalMemberships,
|
|
|
|
pendingMemberships,
|
2021-10-20 23:46:41 +00:00
|
|
|
replaceAvatar,
|
|
|
|
saveAvatarToDisk,
|
|
|
|
searchInConversation,
|
2021-01-29 21:19:24 +00:00
|
|
|
setDisappearingMessages,
|
2021-10-20 23:46:41 +00:00
|
|
|
setMuteExpiration,
|
2021-01-29 21:19:24 +00:00
|
|
|
showAllMedia,
|
2021-10-20 23:46:41 +00:00
|
|
|
showChatColorEditor,
|
2021-01-29 21:19:24 +00:00
|
|
|
showContactModal,
|
2021-10-20 23:46:41 +00:00
|
|
|
showConversationNotificationsSettings,
|
2021-01-29 21:19:24 +00:00
|
|
|
showGroupLinkManagement,
|
|
|
|
showGroupV2Permissions,
|
|
|
|
showLightboxForMedia,
|
2021-10-20 23:46:41 +00:00
|
|
|
showPendingInvites,
|
2021-11-02 23:01:13 +00:00
|
|
|
theme,
|
2021-10-20 23:46:41 +00:00
|
|
|
toggleSafetyNumberModal,
|
2021-03-09 19:16:56 +00:00
|
|
|
updateGroupAttributes,
|
2021-08-06 00:17:05 +00:00
|
|
|
userAvatarData,
|
2021-01-29 21:19:24 +00:00
|
|
|
}) => {
|
2021-03-11 21:29:31 +00:00
|
|
|
const [modalState, setModalState] = useState<ModalState>(
|
|
|
|
ModalState.NothingOpen
|
2021-03-09 19:16:56 +00:00
|
|
|
);
|
2021-11-11 22:43:05 +00:00
|
|
|
const [editGroupAttributesRequestState, setEditGroupAttributesRequestState] =
|
|
|
|
useState<RequestState>(RequestState.Inactive);
|
|
|
|
const [addGroupMembersRequestState, setAddGroupMembersRequestState] =
|
|
|
|
useState<RequestState>(RequestState.Inactive);
|
|
|
|
const [membersMissingCapability, setMembersMissingCapability] =
|
|
|
|
useState(false);
|
2021-03-09 19:16:56 +00:00
|
|
|
|
2021-01-29 21:19:24 +00:00
|
|
|
if (conversation === undefined) {
|
|
|
|
throw new Error('ConversationDetails rendered without a conversation');
|
|
|
|
}
|
|
|
|
|
|
|
|
const invitesCount =
|
|
|
|
pendingMemberships.length + pendingApprovalMemberships.length;
|
|
|
|
|
2021-04-05 17:44:13 +00:00
|
|
|
const otherMemberships = memberships.filter(({ member }) => !member.isMe);
|
|
|
|
const isJustMe = otherMemberships.length === 0;
|
|
|
|
const isAnyoneElseAnAdmin = otherMemberships.some(
|
|
|
|
membership => membership.isAdmin
|
|
|
|
);
|
|
|
|
const cannotLeaveBecauseYouAreLastAdmin =
|
|
|
|
isAdmin && !isJustMe && !isAnyoneElseAnAdmin;
|
|
|
|
|
2021-03-11 21:29:31 +00:00
|
|
|
let modalNode: ReactNode;
|
|
|
|
switch (modalState) {
|
|
|
|
case ModalState.NothingOpen:
|
|
|
|
modalNode = undefined;
|
|
|
|
break;
|
2021-06-03 00:07:37 +00:00
|
|
|
case ModalState.EditingGroupDescription:
|
|
|
|
case ModalState.EditingGroupTitle:
|
2021-03-11 21:29:31 +00:00
|
|
|
modalNode = (
|
|
|
|
<EditConversationAttributesModal
|
2021-08-06 00:17:05 +00:00
|
|
|
avatarColor={conversation.color}
|
2021-03-11 21:29:31 +00:00
|
|
|
avatarPath={conversation.avatarPath}
|
2021-08-06 00:17:05 +00:00
|
|
|
conversationId={conversation.id}
|
2021-06-02 00:24:28 +00:00
|
|
|
groupDescription={conversation.groupDescription}
|
2021-03-11 21:29:31 +00:00
|
|
|
i18n={i18n}
|
2021-06-04 14:55:34 +00:00
|
|
|
initiallyFocusDescription={
|
|
|
|
modalState === ModalState.EditingGroupDescription
|
|
|
|
}
|
2021-03-11 21:29:31 +00:00
|
|
|
makeRequest={async (
|
|
|
|
options: Readonly<{
|
2021-09-24 00:49:05 +00:00
|
|
|
avatar?: undefined | Uint8Array;
|
2021-06-02 00:24:28 +00:00
|
|
|
description?: string;
|
2021-03-11 21:29:31 +00:00
|
|
|
title?: string;
|
|
|
|
}>
|
|
|
|
) => {
|
|
|
|
setEditGroupAttributesRequestState(RequestState.Active);
|
|
|
|
|
|
|
|
try {
|
|
|
|
await updateGroupAttributes(options);
|
|
|
|
setModalState(ModalState.NothingOpen);
|
|
|
|
setEditGroupAttributesRequestState(RequestState.Inactive);
|
|
|
|
} catch (err) {
|
|
|
|
setEditGroupAttributesRequestState(
|
|
|
|
RequestState.InactiveWithError
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
onClose={() => {
|
|
|
|
setModalState(ModalState.NothingOpen);
|
|
|
|
setEditGroupAttributesRequestState(RequestState.Inactive);
|
|
|
|
}}
|
|
|
|
requestState={editGroupAttributesRequestState}
|
|
|
|
title={conversation.title}
|
2021-08-06 00:17:05 +00:00
|
|
|
deleteAvatarFromDisk={deleteAvatarFromDisk}
|
|
|
|
replaceAvatar={replaceAvatar}
|
|
|
|
saveAvatarToDisk={saveAvatarToDisk}
|
|
|
|
userAvatarData={userAvatarData}
|
2021-03-11 21:29:31 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case ModalState.AddingGroupMembers:
|
|
|
|
modalNode = (
|
|
|
|
<AddGroupMembersModal
|
|
|
|
candidateContacts={candidateContactsToAdd}
|
|
|
|
clearRequestError={() => {
|
|
|
|
setAddGroupMembersRequestState(oldRequestState => {
|
|
|
|
assert(
|
|
|
|
oldRequestState !== RequestState.Active,
|
|
|
|
'Should not be clearing an active request state'
|
|
|
|
);
|
|
|
|
return RequestState.Inactive;
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
conversationIdsAlreadyInGroup={
|
2021-04-05 17:44:13 +00:00
|
|
|
new Set(memberships.map(membership => membership.member.id))
|
2021-03-11 21:29:31 +00:00
|
|
|
}
|
2021-11-17 21:11:21 +00:00
|
|
|
getPreferredBadge={getPreferredBadge}
|
2021-03-11 21:29:31 +00:00
|
|
|
groupTitle={conversation.title}
|
|
|
|
i18n={i18n}
|
|
|
|
makeRequest={async conversationIds => {
|
|
|
|
setAddGroupMembersRequestState(RequestState.Active);
|
|
|
|
|
|
|
|
try {
|
|
|
|
await addMembers(conversationIds);
|
|
|
|
setModalState(ModalState.NothingOpen);
|
|
|
|
setAddGroupMembersRequestState(RequestState.Inactive);
|
|
|
|
} catch (err) {
|
2021-09-22 00:58:03 +00:00
|
|
|
if (err instanceof CapabilityError) {
|
2021-07-20 20:18:35 +00:00
|
|
|
setMembersMissingCapability(true);
|
|
|
|
setAddGroupMembersRequestState(RequestState.InactiveWithError);
|
|
|
|
} else {
|
|
|
|
setAddGroupMembersRequestState(RequestState.InactiveWithError);
|
|
|
|
}
|
2021-03-11 21:29:31 +00:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
onClose={() => {
|
|
|
|
setModalState(ModalState.NothingOpen);
|
|
|
|
setEditGroupAttributesRequestState(RequestState.Inactive);
|
|
|
|
}}
|
|
|
|
requestState={addGroupMembersRequestState}
|
2021-11-02 23:01:13 +00:00
|
|
|
theme={theme}
|
2021-03-11 21:29:31 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
break;
|
2021-10-20 23:46:41 +00:00
|
|
|
case ModalState.MuteNotifications:
|
|
|
|
modalNode = (
|
|
|
|
<ConversationNotificationsModal
|
|
|
|
i18n={i18n}
|
|
|
|
muteExpiresAt={conversation.muteExpiresAt}
|
|
|
|
onClose={() => {
|
|
|
|
setModalState(ModalState.NothingOpen);
|
|
|
|
}}
|
|
|
|
setMuteExpiration={setMuteExpiration}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case ModalState.UnmuteNotifications:
|
|
|
|
modalNode = (
|
|
|
|
<ConfirmationDialog
|
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
action: () => setMuteExpiration(0),
|
|
|
|
style: 'affirmative',
|
|
|
|
text: i18n('unmute'),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
hasXButton
|
|
|
|
i18n={i18n}
|
|
|
|
title={i18n('ConversationDetails__unmute--title')}
|
|
|
|
onClose={() => {
|
|
|
|
setModalState(ModalState.NothingOpen);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{getMutedUntilText(Number(conversation.muteExpiresAt), i18n)}
|
|
|
|
</ConfirmationDialog>
|
|
|
|
);
|
|
|
|
break;
|
2021-03-11 21:29:31 +00:00
|
|
|
default:
|
|
|
|
throw missingCaseError(modalState);
|
|
|
|
}
|
|
|
|
|
2021-10-20 23:46:41 +00:00
|
|
|
const isConversationMuted = isMuted(conversation.muteExpiresAt);
|
|
|
|
|
2021-01-29 21:19:24 +00:00
|
|
|
return (
|
|
|
|
<div className="conversation-details-panel">
|
2021-07-20 20:18:35 +00:00
|
|
|
{membersMissingCapability && (
|
|
|
|
<ConfirmationDialog
|
|
|
|
cancelText={i18n('Confirmation--confirm')}
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => setMembersMissingCapability(false)}
|
|
|
|
>
|
|
|
|
{i18n('GroupV2--add--missing-capability')}
|
|
|
|
</ConfirmationDialog>
|
|
|
|
)}
|
|
|
|
|
2021-03-09 19:16:56 +00:00
|
|
|
<ConversationDetailsHeader
|
2021-11-02 23:01:13 +00:00
|
|
|
badges={badges}
|
2021-03-09 19:16:56 +00:00
|
|
|
canEdit={canEditGroupInfo}
|
|
|
|
conversation={conversation}
|
|
|
|
i18n={i18n}
|
2021-10-20 23:46:41 +00:00
|
|
|
isMe={conversation.isMe}
|
|
|
|
isGroup={isGroup}
|
2021-05-13 14:47:30 +00:00
|
|
|
memberships={memberships}
|
2021-06-03 00:07:37 +00:00
|
|
|
startEditing={(isGroupTitle: boolean) => {
|
|
|
|
setModalState(
|
|
|
|
isGroupTitle
|
|
|
|
? ModalState.EditingGroupTitle
|
|
|
|
: ModalState.EditingGroupDescription
|
|
|
|
);
|
2021-03-09 19:16:56 +00:00
|
|
|
}}
|
2021-11-02 23:01:13 +00:00
|
|
|
theme={theme}
|
2021-03-09 19:16:56 +00:00
|
|
|
/>
|
2021-01-29 21:19:24 +00:00
|
|
|
|
2021-10-20 23:46:41 +00:00
|
|
|
<div className="ConversationDetails__header-buttons">
|
|
|
|
{!conversation.isMe && (
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
icon={ButtonIconType.video}
|
|
|
|
onClick={onOutgoingVideoCallInConversation}
|
|
|
|
variant={ButtonVariant.Details}
|
|
|
|
>
|
|
|
|
{i18n('video')}
|
|
|
|
</Button>
|
|
|
|
{!isGroup && (
|
|
|
|
<Button
|
|
|
|
icon={ButtonIconType.audio}
|
|
|
|
onClick={onOutgoingAudioCallInConversation}
|
|
|
|
variant={ButtonVariant.Details}
|
|
|
|
>
|
|
|
|
{i18n('audio')}
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<Button
|
|
|
|
icon={
|
|
|
|
isConversationMuted ? ButtonIconType.muted : ButtonIconType.unmuted
|
|
|
|
}
|
|
|
|
onClick={() => {
|
|
|
|
if (isConversationMuted) {
|
|
|
|
setModalState(ModalState.UnmuteNotifications);
|
|
|
|
} else {
|
|
|
|
setModalState(ModalState.MuteNotifications);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
variant={ButtonVariant.Details}
|
|
|
|
>
|
|
|
|
{isConversationMuted ? i18n('unmute') : i18n('mute')}
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
icon={ButtonIconType.search}
|
|
|
|
onClick={() => {
|
2021-11-01 18:43:02 +00:00
|
|
|
searchInConversation(conversation.id);
|
2021-10-20 23:46:41 +00:00
|
|
|
}}
|
|
|
|
variant={ButtonVariant.Details}
|
|
|
|
>
|
|
|
|
{i18n('search')}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
<PanelSection>
|
2021-10-20 23:46:41 +00:00
|
|
|
{!isGroup || canEditGroupInfo ? (
|
2021-01-29 21:19:24 +00:00
|
|
|
<PanelRow
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
|
|
|
ariaLabel={i18n(
|
|
|
|
'ConversationDetails--disappearing-messages-label'
|
|
|
|
)}
|
2021-10-20 23:46:41 +00:00
|
|
|
icon={IconType.timer}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
|
|
|
}
|
2021-11-20 15:48:27 +00:00
|
|
|
info={i18n(
|
|
|
|
isGroup
|
|
|
|
? 'ConversationDetails--disappearing-messages-info--group'
|
|
|
|
: 'ConversationDetails--disappearing-messages-info--direct'
|
|
|
|
)}
|
2021-01-29 21:19:24 +00:00
|
|
|
label={i18n('ConversationDetails--disappearing-messages-label')}
|
|
|
|
right={
|
2021-06-25 23:52:56 +00:00
|
|
|
<DisappearingTimerSelect
|
|
|
|
i18n={i18n}
|
|
|
|
value={conversation.expireTimer || 0}
|
|
|
|
onChange={setDisappearingMessages}
|
2021-06-01 20:45:43 +00:00
|
|
|
/>
|
|
|
|
}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
2021-05-28 16:15:17 +00:00
|
|
|
) : null}
|
|
|
|
<PanelRow
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
|
|
|
ariaLabel={i18n('showChatColorEditor')}
|
2021-10-20 23:46:41 +00:00
|
|
|
icon={IconType.color}
|
2021-05-28 16:15:17 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={i18n('showChatColorEditor')}
|
2021-10-20 23:46:41 +00:00
|
|
|
onClick={showChatColorEditor}
|
2021-05-28 16:15:17 +00:00
|
|
|
right={
|
|
|
|
<div
|
2021-10-20 23:46:41 +00:00
|
|
|
className={`ConversationDetails__chat-color ConversationDetails__chat-color--${conversation.conversationColor}`}
|
2021-05-28 16:15:17 +00:00
|
|
|
style={{
|
|
|
|
...getCustomColorStyle(conversation.customColor),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
2021-10-20 23:46:41 +00:00
|
|
|
{isGroup && (
|
2021-01-29 21:19:24 +00:00
|
|
|
<PanelRow
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
2021-10-20 23:46:41 +00:00
|
|
|
ariaLabel={i18n('ConversationDetails--notifications')}
|
|
|
|
icon={IconType.notifications}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
|
|
|
}
|
2021-10-20 23:46:41 +00:00
|
|
|
label={i18n('ConversationDetails--notifications')}
|
|
|
|
onClick={showConversationNotificationsSettings}
|
|
|
|
right={
|
|
|
|
conversation.muteExpiresAt
|
|
|
|
? getMutedUntilText(conversation.muteExpiresAt, i18n)
|
|
|
|
: undefined
|
|
|
|
}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
2021-10-20 23:46:41 +00:00
|
|
|
)}
|
|
|
|
{!isGroup && !conversation.isMe && (
|
|
|
|
<>
|
|
|
|
<PanelRow
|
|
|
|
onClick={() => toggleSafetyNumberModal(conversation.id)}
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
|
|
|
ariaLabel={i18n('verifyNewNumber')}
|
|
|
|
icon={IconType.verify}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={
|
|
|
|
<div className="ConversationDetails__safety-number">
|
|
|
|
{i18n('verifyNewNumber')}
|
|
|
|
</div>
|
|
|
|
}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
2021-10-20 23:46:41 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</PanelSection>
|
|
|
|
|
|
|
|
{isGroup && (
|
|
|
|
<ConversationDetailsMembershipList
|
|
|
|
canAddNewMembers={canEditGroupInfo}
|
|
|
|
conversationId={conversation.id}
|
2021-11-17 21:11:21 +00:00
|
|
|
getPreferredBadge={getPreferredBadge}
|
2021-10-20 23:46:41 +00:00
|
|
|
i18n={i18n}
|
|
|
|
memberships={memberships}
|
|
|
|
showContactModal={showContactModal}
|
|
|
|
startAddingNewMembers={() => {
|
|
|
|
setModalState(ModalState.AddingGroupMembers);
|
|
|
|
}}
|
2021-11-02 23:01:13 +00:00
|
|
|
theme={theme}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
2021-10-20 23:46:41 +00:00
|
|
|
)}
|
|
|
|
|
|
|
|
{isGroup && (
|
|
|
|
<PanelSection>
|
|
|
|
{isAdmin || hasGroupLink ? (
|
|
|
|
<PanelRow
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
|
|
|
ariaLabel={i18n('ConversationDetails--group-link')}
|
|
|
|
icon={IconType.link}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={i18n('ConversationDetails--group-link')}
|
|
|
|
onClick={showGroupLinkManagement}
|
|
|
|
right={hasGroupLink ? i18n('on') : i18n('off')}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-01-29 21:19:24 +00:00
|
|
|
<PanelRow
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
2021-10-20 23:46:41 +00:00
|
|
|
ariaLabel={i18n('ConversationDetails--requests-and-invites')}
|
|
|
|
icon={IconType.invites}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
|
|
|
}
|
2021-10-20 23:46:41 +00:00
|
|
|
label={i18n('ConversationDetails--requests-and-invites')}
|
|
|
|
onClick={showPendingInvites}
|
|
|
|
right={invitesCount}
|
2021-01-29 21:19:24 +00:00
|
|
|
/>
|
2021-10-20 23:46:41 +00:00
|
|
|
{isAdmin ? (
|
|
|
|
<PanelRow
|
|
|
|
icon={
|
|
|
|
<ConversationDetailsIcon
|
|
|
|
ariaLabel={i18n('permissions')}
|
|
|
|
icon={IconType.lock}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={i18n('permissions')}
|
|
|
|
onClick={showGroupV2Permissions}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</PanelSection>
|
|
|
|
)}
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
<ConversationDetailsMediaList
|
|
|
|
conversation={conversation}
|
|
|
|
i18n={i18n}
|
|
|
|
loadRecentMediaItems={loadRecentMediaItems}
|
|
|
|
showAllMedia={showAllMedia}
|
|
|
|
showLightboxForMedia={showLightboxForMedia}
|
|
|
|
/>
|
|
|
|
|
2021-10-20 23:46:41 +00:00
|
|
|
{!conversation.isMe && (
|
|
|
|
<ConversationDetailsActions
|
|
|
|
cannotLeaveBecauseYouAreLastAdmin={cannotLeaveBecauseYouAreLastAdmin}
|
|
|
|
conversationTitle={conversation.title}
|
|
|
|
i18n={i18n}
|
|
|
|
isBlocked={Boolean(conversation.isBlocked)}
|
|
|
|
isGroup={isGroup}
|
|
|
|
left={Boolean(conversation.left)}
|
|
|
|
onBlock={onBlock}
|
|
|
|
onLeave={onLeave}
|
|
|
|
onUnblock={onUnblock}
|
|
|
|
/>
|
|
|
|
)}
|
2021-03-09 19:16:56 +00:00
|
|
|
|
2021-03-11 21:29:31 +00:00
|
|
|
{modalNode}
|
2021-01-29 21:19:24 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|