/* * Wire * Copyright (C) 2023 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import {FC, ReactNode} from 'react'; import ko from 'knockout'; import {Link, LinkVariant} from '@wireapp/react-ui-kit'; import * as Icon from 'Components/Icon'; import {CONVERSATION_READONLY_STATE} from 'src/script/conversation/ConversationRepository'; import {Conversation} from 'src/script/entity/Conversation'; import {useKoSubscribableChildren} from 'Util/ComponentUtil'; import {t} from 'Util/LocalizerUtil'; import {replaceReactComponents} from 'Util/LocalizerUtil/ReactLocalizerUtil'; interface ReadOnlyConversationMessageProps { reloadApp: () => void; conversation: Conversation; } const userPlaceholder = {isBlocked: ko.observable(false)}; export const ReadOnlyConversationMessage: FC = ({conversation, reloadApp}) => { const { readOnlyState, is1to1, participating_user_ets: participatingUserEts, } = useKoSubscribableChildren(conversation, ['readOnlyState', 'is1to1', 'participating_user_ets']); const user = (is1to1 && participatingUserEts[0]) || null; const {isBlocked: isUserBlocked} = useKoSubscribableChildren(user || userPlaceholder, ['isBlocked']); if (!user) { // This should never happen for 1:1 conversations return null; } if (isUserBlocked) { return ( {t('conversationWithBlockedUser')} ); } if (readOnlyState) { switch (readOnlyState) { case CONVERSATION_READONLY_STATE.READONLY_ONE_TO_ONE_OTHER_UNSUPPORTED_MLS: return ( {replaceReactComponents(t('otherUserNotSupportMLSMsg'), [ { exactMatch: '{participantName}', render: () => {user.name()}, }, ])} ); case CONVERSATION_READONLY_STATE.READONLY_ONE_TO_ONE_SELF_UNSUPPORTED_MLS: return ( {replaceReactComponents(t('selfNotSupportMLSMsgPart1'), [ { exactMatch: '{selfUserName}', render: () => {user.name()}, }, ])} <> {' '} {t('downloadLatestMLS')} {' '} {t('selfNotSupportMLSMsgPart2')} ); case CONVERSATION_READONLY_STATE.READONLY_ONE_TO_ONE_NO_KEY_PACKAGES: return ( {replaceReactComponents(t('otherUserNoAvailableKeyPackages'), [ { exactMatch: '{participantName}', render: () => {user.name()}, }, ])} ); } } return null; }; const ReadOnlyConversationMessageBase = ({children}: {children: ReactNode}) => { return (

{children}

); };