simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Affero General Public License as |
| 6 | * published by the Free Software Foundation; either version 3 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Affero General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Affero General Public |
| 15 | * License along with this program. If not, see |
| 16 | * <https://www.gnu.org/licenses/>. |
| 17 | */ |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 18 | import { Box, ListItemButton, Stack, Typography } from '@mui/material'; |
| 19 | import dayjs from 'dayjs'; |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 20 | import { IConversationSummary } from 'jami-web-common'; |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 21 | import { QRCodeCanvas } from 'qrcode.react'; |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 22 | import { useCallback, useContext, useMemo, useState } from 'react'; |
simon | 4e7445c | 2022-11-16 21:18:46 -0500 | [diff] [blame] | 23 | import { useTranslation } from 'react-i18next'; |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 24 | import { useNavigate } from 'react-router-dom'; |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 25 | |
simon | 5da8ca6 | 2022-11-09 15:21:25 -0500 | [diff] [blame] | 26 | import { useAuthContext } from '../contexts/AuthProvider'; |
simon | e35acc2 | 2022-12-02 16:51:12 -0500 | [diff] [blame] | 27 | import { CallManagerContext } from '../contexts/CallManagerProvider'; |
Michelle Sepkap Sime | c050d9c | 2022-12-05 09:39:34 -0500 | [diff] [blame] | 28 | import { CallStatus, useCallContext } from '../contexts/CallProvider'; |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 29 | import { useUrlParams } from '../hooks/useUrlParams'; |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 30 | import { setRefreshFromSlice } from '../redux/appSlice'; |
| 31 | import { useAppDispatch } from '../redux/hooks'; |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 32 | import { ConversationRouteParams } from '../router'; |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 33 | import { getMessageCallText, getMessageMemberText } from '../utils/chatmessages'; |
| 34 | import { formatRelativeDate, formatTime } from '../utils/dates×'; |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 35 | import ContextMenu, { ContextMenuHandler, useContextMenuHandler } from './ContextMenu'; |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 36 | import ConversationAvatar from './ConversationAvatar'; |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 37 | import { ConfirmationDialog, DialogContentList, InfosDialog, useDialogHandler } from './Dialog'; |
| 38 | import { PopoverListItemData } from './PopoverList'; |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 39 | import { AudioCallIcon, CancelIcon, MessageIcon, PersonIcon, VideoCallIcon } from './SvgIcon'; |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 40 | |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 41 | type ConversationListItemProps = { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 42 | conversationSummary: IConversationSummary; |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 45 | export default function ConversationListItem({ conversationSummary }: ConversationListItemProps) { |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 46 | const { account } = useAuthContext(); |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 47 | const { |
| 48 | urlParams: { conversationId: selectedConversationId }, |
| 49 | } = useUrlParams<ConversationRouteParams>(); |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 50 | const contextMenuHandler = useContextMenuHandler(); |
Michelle Sepkap Sime | c050d9c | 2022-12-05 09:39:34 -0500 | [diff] [blame] | 51 | const callContext = useCallContext(true); |
| 52 | const { callData } = useContext(CallManagerContext); |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 53 | const { t, i18n } = useTranslation(); |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 54 | const navigate = useNavigate(); |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 55 | |
| 56 | const conversationId = conversationSummary.id; |
| 57 | const isSelected = conversationId === selectedConversationId; |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 58 | |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 59 | const onClick = useCallback(() => { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 60 | if (conversationId) { |
| 61 | navigate(`/conversation/${conversationId}`); |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 62 | } |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 63 | }, [navigate, conversationId]); |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 64 | |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 65 | const timeIndicator = useMemo(() => { |
| 66 | const message = conversationSummary.lastMessage; |
| 67 | const time = dayjs.unix(Number(message.timestamp)); |
| 68 | if (time.isToday()) { |
| 69 | return formatTime(time, i18n); |
| 70 | } else { |
| 71 | return formatRelativeDate(time, i18n); |
| 72 | } |
| 73 | }, [conversationSummary, i18n]); |
| 74 | |
| 75 | const lastMessageText = useMemo(() => { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 76 | if (!callContext || !callData || callData.conversationId !== conversationSummary.id) { |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 77 | const message = conversationSummary.lastMessage; |
| 78 | switch (message.type) { |
| 79 | case 'initial': { |
| 80 | return t('message_swarm_created'); |
| 81 | } |
| 82 | case 'application/data-transfer+json': { |
| 83 | return message.fileId; |
| 84 | } |
| 85 | case 'application/call-history+json': { |
| 86 | const isAccountMessage = message.author === account.getUri(); |
| 87 | return getMessageCallText(isAccountMessage, message, i18n); |
| 88 | } |
| 89 | case 'member': { |
| 90 | return getMessageMemberText(message, i18n); |
| 91 | } |
| 92 | case 'text/plain': { |
| 93 | return message.body; |
| 94 | } |
| 95 | default: { |
| 96 | console.error(`${ConversationListItem.name} received an unexpected lastMessage type: ${message.type}`); |
| 97 | return ''; |
| 98 | } |
| 99 | } |
Michelle Sepkap Sime | c050d9c | 2022-12-05 09:39:34 -0500 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | if (callContext.callStatus === CallStatus.InCall) { |
| 103 | return callContext.isAudioOn ? t('ongoing_call_unmuted') : t('ongoing_call_muted'); |
| 104 | } |
| 105 | |
| 106 | if (callContext.callStatus === CallStatus.Connecting) { |
| 107 | return t('connecting_call'); |
| 108 | } |
| 109 | |
| 110 | return callContext.callRole === 'caller' ? t('outgoing_call') : t('incoming_call'); |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 111 | }, [account, conversationSummary, callContext, callData, t, i18n]); |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 112 | |
| 113 | const conversationName = useMemo( |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 114 | () => conversationSummary.title || conversationSummary.membersNames.join(', ') || account.getDisplayName(), |
| 115 | [account, conversationSummary] |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 116 | ); |
Michelle Sepkap Sime | c050d9c | 2022-12-05 09:39:34 -0500 | [diff] [blame] | 117 | |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 118 | return ( |
idillon | 22ed819 | 2022-11-29 12:17:04 -0500 | [diff] [blame] | 119 | <Box> |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 120 | <ConversationMenu |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 121 | conversationId={conversationId} |
| 122 | conversationName={conversationName} |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 123 | onMessageClick={onClick} |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 124 | isSelected={isSelected} |
| 125 | contextMenuProps={contextMenuHandler.props} |
| 126 | /> |
idillon | 078bd55 | 2022-12-22 16:41:08 -0500 | [diff] [blame] | 127 | <ListItemButton |
| 128 | alignItems="flex-start" |
| 129 | selected={isSelected} |
| 130 | onClick={onClick} |
| 131 | onContextMenu={contextMenuHandler.handleAnchorPosition} |
| 132 | > |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 133 | <Stack direction="row" spacing="10px"> |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 134 | <ConversationAvatar displayName={conversationName} /> |
idillon | 9e542ca | 2022-12-15 17:54:07 -0500 | [diff] [blame] | 135 | <Stack> |
| 136 | <Typography variant="body1">{conversationName}</Typography> |
| 137 | <Stack direction="row" spacing="5px"> |
| 138 | <Typography variant="body2" fontWeight={isSelected ? 'bold' : 'normal'}> |
| 139 | {timeIndicator} |
| 140 | </Typography> |
| 141 | <Typography variant="body2">{lastMessageText}</Typography> |
| 142 | </Stack> |
| 143 | </Stack> |
| 144 | </Stack> |
| 145 | </ListItemButton> |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 146 | </Box> |
| 147 | ); |
| 148 | } |
| 149 | |
| 150 | interface ConversationMenuProps { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 151 | conversationId: string; |
| 152 | conversationName: string; |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 153 | onMessageClick: () => void; |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 154 | isSelected: boolean; |
| 155 | contextMenuProps: ContextMenuHandler['props']; |
| 156 | } |
| 157 | |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 158 | const ConversationMenu = ({ |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 159 | conversationId, |
| 160 | conversationName, |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 161 | onMessageClick, |
| 162 | isSelected, |
| 163 | contextMenuProps, |
| 164 | }: ConversationMenuProps) => { |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 165 | const { t } = useTranslation(); |
simon | e35acc2 | 2022-12-02 16:51:12 -0500 | [diff] [blame] | 166 | const { startCall } = useContext(CallManagerContext); |
simon | 416d079 | 2022-11-03 02:46:18 -0400 | [diff] [blame] | 167 | const [isSwarm] = useState(true); |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 168 | |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 169 | const detailsDialogHandler = useDialogHandler(); |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 170 | const RemoveConversationDialogHandler = useDialogHandler(); |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 171 | |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 172 | const navigate = useNavigate(); |
| 173 | |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 174 | const menuOptions: PopoverListItemData[] = useMemo( |
| 175 | () => [ |
| 176 | { |
| 177 | label: t('conversation_message'), |
| 178 | Icon: MessageIcon, |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 179 | onClick: onMessageClick, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 180 | }, |
| 181 | { |
| 182 | label: t('conversation_start_audiocall'), |
| 183 | Icon: AudioCallIcon, |
| 184 | onClick: () => { |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 185 | if (conversationId) { |
simon | e35acc2 | 2022-12-02 16:51:12 -0500 | [diff] [blame] | 186 | startCall({ |
| 187 | conversationId, |
| 188 | role: 'caller', |
| 189 | }); |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 190 | } |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 191 | }, |
| 192 | }, |
| 193 | { |
| 194 | label: t('conversation_start_videocall'), |
| 195 | Icon: VideoCallIcon, |
| 196 | onClick: () => { |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 197 | if (conversationId) { |
simon | e35acc2 | 2022-12-02 16:51:12 -0500 | [diff] [blame] | 198 | startCall({ |
| 199 | conversationId, |
| 200 | role: 'caller', |
| 201 | withVideoOn: true, |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 202 | }); |
| 203 | } |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 204 | }, |
| 205 | }, |
| 206 | ...(isSelected |
| 207 | ? [ |
| 208 | { |
| 209 | label: t('conversation_close'), |
| 210 | Icon: CancelIcon, |
| 211 | onClick: () => { |
| 212 | navigate(`/`); |
| 213 | }, |
| 214 | }, |
| 215 | ] |
| 216 | : []), |
| 217 | { |
| 218 | label: t('conversation_details'), |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 219 | Icon: PersonIcon, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 220 | onClick: () => { |
| 221 | detailsDialogHandler.openDialog(); |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 222 | }, |
| 223 | }, |
| 224 | { |
| 225 | label: t('conversation_delete'), |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 226 | Icon: CancelIcon, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 227 | onClick: () => { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 228 | RemoveConversationDialogHandler.openDialog(); |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 229 | }, |
| 230 | }, |
| 231 | ], |
| 232 | [ |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 233 | navigate, |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 234 | onMessageClick, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 235 | isSelected, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 236 | detailsDialogHandler, |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 237 | RemoveConversationDialogHandler, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 238 | t, |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 239 | startCall, |
| 240 | conversationId, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 241 | ] |
| 242 | ); |
simon | 575c940 | 2022-10-25 16:21:40 -0400 | [diff] [blame] | 243 | |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 244 | return ( |
| 245 | <> |
| 246 | <ContextMenu {...contextMenuProps} items={menuOptions} /> |
| 247 | |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 248 | <DetailsDialog |
| 249 | {...detailsDialogHandler.props} |
| 250 | conversationId={conversationId} |
| 251 | conversationName={conversationName} |
| 252 | isSwarm={isSwarm} |
| 253 | /> |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 254 | |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 255 | <RemoveConversationDialog {...RemoveConversationDialogHandler.props} conversationId={conversationId} /> |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 256 | </> |
| 257 | ); |
| 258 | }; |
| 259 | |
| 260 | interface DetailsDialogProps { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 261 | conversationId: string; |
| 262 | conversationName: string; |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 263 | open: boolean; |
| 264 | onClose: () => void; |
| 265 | isSwarm: boolean; |
| 266 | } |
| 267 | |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 268 | const DetailsDialog = ({ conversationId, conversationName, open, onClose, isSwarm }: DetailsDialogProps) => { |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 269 | const { t } = useTranslation(); |
| 270 | const items = useMemo( |
| 271 | () => [ |
| 272 | { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 273 | label: t('conversation_details_name'), |
| 274 | value: conversationName, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 275 | }, |
| 276 | { |
| 277 | label: t('conversation_details_identifier'), |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 278 | value: conversationId, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 279 | }, |
| 280 | { |
| 281 | label: t('conversation_details_qr_code'), |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 282 | value: <QRCodeCanvas size={80} value={`${conversationId}`} />, |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 283 | }, |
| 284 | { |
| 285 | label: t('conversation_details_is_swarm'), |
| 286 | value: isSwarm ? t('conversation_details_is_swarm_true') : t('conversation_details_is_swarm_false'), |
| 287 | }, |
| 288 | ], |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 289 | [conversationId, conversationName, isSwarm, t] |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 290 | ); |
| 291 | return ( |
| 292 | <InfosDialog |
| 293 | open={open} |
| 294 | onClose={onClose} |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 295 | icon={<ConversationAvatar sx={{ width: 'inherit', height: 'inherit' }} displayName={conversationName} />} |
| 296 | title={conversationName} |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 297 | content={<DialogContentList title={t('conversation_details_informations')} items={items} />} |
| 298 | /> |
| 299 | ); |
| 300 | }; |
| 301 | |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 302 | interface RemoveConversationDialogProps { |
| 303 | conversationId: string; |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 304 | open: boolean; |
| 305 | onClose: () => void; |
| 306 | } |
| 307 | |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 308 | const RemoveConversationDialog = ({ conversationId, open, onClose }: RemoveConversationDialogProps) => { |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 309 | const { axiosInstance } = useAuthContext(); |
| 310 | const { t } = useTranslation(); |
| 311 | const dispatch = useAppDispatch(); |
| 312 | |
| 313 | const remove = async () => { |
| 314 | const controller = new AbortController(); |
| 315 | try { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 316 | await axiosInstance.delete(`/conversations/${conversationId}`, { |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 317 | signal: controller.signal, |
| 318 | }); |
| 319 | dispatch(setRefreshFromSlice()); |
| 320 | } catch (e) { |
idillon | 07d31cc | 2022-12-06 22:40:14 -0500 | [diff] [blame] | 321 | console.error(`Error removing conversation : `, e); |
idillon | ef9ab81 | 2022-11-18 13:46:24 -0500 | [diff] [blame] | 322 | dispatch(setRefreshFromSlice()); |
| 323 | } |
| 324 | onClose(); |
| 325 | }; |
| 326 | |
| 327 | return ( |
| 328 | <ConfirmationDialog |
| 329 | open={open} |
| 330 | onClose={onClose} |
| 331 | title={t('dialog_confirm_title_default')} |
| 332 | content={t('conversation_ask_confirm_remove')} |
| 333 | onConfirm={remove} |
| 334 | confirmButtonText={t('conversation_confirm_remove')} |
| 335 | /> |
| 336 | ); |
| 337 | }; |