From cb18f87c98beaf37b337639669263b96170dc3c7 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Fri, 14 Apr 2023 00:45:49 +0200 Subject: [PATCH] smaller video chat bugfixes (#3186) * do not save custom video chat provider if it only contains whitespaces * sendCallInvitation: show error message instead of `[object Object]` * don't show video chat in attachment menu when the feature is turned off * update changelog somehow forgot to commit it --- CHANGELOG.md | 3 +++ src/renderer/components/attachment/menuAttachment.tsx | 7 +++++-- .../components/dialogs/Settings-ExperimentalFeatures.tsx | 2 +- src/renderer/components/helpers/ChatMethods.ts | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e99fbe05b0..f687f79cc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - improve confirm abort dialog for setup second device #3173 ### Fixed +- do not save custom video chat provider if it only contains whitespaces +- fix show error messages when starting a video chat +- don't show video chat in attachment menu when the feature is turned off - fix "Always Load Remote Images" should be hidden for contact requests #3180 diff --git a/src/renderer/components/attachment/menuAttachment.tsx b/src/renderer/components/attachment/menuAttachment.tsx index 854d7e8bce..da4e91e663 100644 --- a/src/renderer/components/attachment/menuAttachment.tsx +++ b/src/renderer/components/attachment/menuAttachment.tsx @@ -13,6 +13,8 @@ import { MEDIA_EXTENSIONS } from '../../../shared/constants' import { sendCallInvitation } from '../helpers/ChatMethods' import { Type } from '../../backend-com' +import { useStore } from '../../stores/store' +import SettingsStoreInstance from '../../stores/settings' //function to populate Menu const MenuAttachmentItems = ({ itemsArray, @@ -44,6 +46,7 @@ const MenuAttachment = ({ }) => { const tx = useTranslationFunction() const screenContext = useContext(ScreenContext) + const [settings] = useStore(SettingsStoreInstance) const addFilenameFile = async () => { //function for files const file = await runtime.showOpenFileDialog({ @@ -94,7 +97,7 @@ const MenuAttachment = ({ } // item array used to populate menu const items = [ - { + settings?.settings.webrtc_instance && { id: 0, icon: 'phone' as IconName, text: tx('videochat'), @@ -115,7 +118,7 @@ const MenuAttachment = ({ onClick: addFilenameFile.bind(null), attachment: 'attachment-files', }, - ] + ].filter(item => !!item) as MenuAttachmentItemObject[] return (
diff --git a/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx b/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx index 5eceb46e5e..812fa257a7 100644 --- a/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx +++ b/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx @@ -131,7 +131,7 @@ export function EditVideochatInstanceDialog({ } const onClickOk = () => { onClose() - onOk(configValue) + onOk(configValue.trim()) // the trim is here to not save custom provider if it only contains whitespaces } const onChangeRadio = (event: FormEvent) => { const currentRadioValue = event.currentTarget.value as RadioButtonValue diff --git a/src/renderer/components/helpers/ChatMethods.ts b/src/renderer/components/helpers/ChatMethods.ts index 29785bd267..5f27aa3651 100644 --- a/src/renderer/components/helpers/ChatMethods.ts +++ b/src/renderer/components/helpers/ChatMethods.ts @@ -176,7 +176,9 @@ export async function sendCallInvitation( await joinCall(screenContext, messageId) } catch (error: todo) { log.error('failed send call invitation', error) - screenContext.openDialog(AlertDialog, { message: error.toString() }) + screenContext.openDialog(AlertDialog, { + message: error?.message || error.toString(), + }) } }