From dccc6c7e1822f999c94760ee4879ef1cc566c132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Simon=20Fauteux-Chapleau?= <francois-simon.fauteux-chapleau@savoirfairelinux.com> Date: Mon, 19 Aug 2024 09:45:40 -0400 Subject: [PATCH] NotificationArea: don't rely on signal that's not always received The current implementation of NotificationArea assumes that the onActiveCallsChanged function in ChatView.qml will be called at least once before the notification area becomes visible, but this isn't necessarily the case. GitLab: #1823 Change-Id: Ic85392dd9b6748b43f6c8d9cc002df973fc8be0e --- src/app/mainview/components/ChatView.qml | 9 --------- .../mainview/components/NotificationArea.qml | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/app/mainview/components/ChatView.qml b/src/app/mainview/components/ChatView.qml index a07809c1a..9cf0890b0 100644 --- a/src/app/mainview/components/ChatView.qml +++ b/src/app/mainview/components/ChatView.qml @@ -167,15 +167,6 @@ Rectangle { target: CurrentConversation enabled: true - function onActiveCallsChanged() { - if (CurrentConversation.activeCalls.length > 0) { - notificationArea.id = CurrentConversation.activeCalls[0]["id"]; - notificationArea.uri = CurrentConversation.activeCalls[0]["uri"]; - notificationArea.device = CurrentConversation.activeCalls[0]["device"]; - } - notificationArea.visible = CurrentConversation.activeCalls.length > 0 && !root.inCallView; - } - function onErrorsChanged() { if (CurrentConversation.errors.length > 0) { errorRect.errorLabel.text = CurrentConversation.errors[0]; diff --git a/src/app/mainview/components/NotificationArea.qml b/src/app/mainview/components/NotificationArea.qml index 4eaba8519..395e54f37 100644 --- a/src/app/mainview/components/NotificationArea.qml +++ b/src/app/mainview/components/NotificationArea.qml @@ -29,9 +29,7 @@ Rectangle { opacity: visible color: CurrentConversation.color - property string id: "" - property string uri: "" - property string device: "" + property var activeCall: CurrentConversation.activeCalls.length > 0 ? CurrentConversation.activeCalls[0] : null property string textColor: UtilsAdapter.luma(root.color) ? JamiTheme.chatviewTextColorLight : JamiTheme.chatviewTextColorDark RowLayout { @@ -64,7 +62,10 @@ Rectangle { border.width: 1 border.color: root.textColor - onClicked: MessagesAdapter.joinCall(uri, device, id, true) + onClicked: { + if (activeCall !== null) + MessagesAdapter.joinCall(activeCall["uri"], activeCall["device"], activeCall["id"], true) + } } PushButton { @@ -82,7 +83,10 @@ Rectangle { border.color: root.textColor visible: CurrentAccount.videoEnabled_Video - onClicked: MessagesAdapter.joinCall(uri, device, id) + onClicked: { + if (activeCall !== null) + MessagesAdapter.joinCall(activeCall["uri"], activeCall["device"], activeCall["id"]) + } } PushButton { @@ -94,7 +98,10 @@ Rectangle { source: JamiResources.round_close_24dp_svg - onClicked: ConversationsAdapter.ignoreActiveCall(CurrentConversation.id, id, uri, device) + onClicked: { + if (activeCall !== null) + ConversationsAdapter.ignoreActiveCall(CurrentConversation.id, activeCall["id"], activeCall["uri"], activeCall["device"]) + } } } -- GitLab