From 19bd6007e8ebc4fd5c698e87a85ebf0e06954af4 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Wed, 18 Dec 2024 20:45:18 +0100 Subject: [PATCH] fix(SpeakingWhileMutedWarner): show toast message instead of removed tooltip Signed-off-by: Maksim Sukharev --- .../shared/LocalAudioControlButton.vue | 4 --- src/components/TopBar/TopBarMediaControls.vue | 7 +----- src/utils/webrtc/SpeakingWhileMutedWarner.js | 25 +++++++++++-------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/components/CallView/shared/LocalAudioControlButton.vue b/src/components/CallView/shared/LocalAudioControlButton.vue index ac809d7dce3..613b3e46ec2 100644 --- a/src/components/CallView/shared/LocalAudioControlButton.vue +++ b/src/components/CallView/shared/LocalAudioControlButton.vue @@ -85,10 +85,6 @@ export default { return t('spreed', 'No audio. Click to select device') } - if (this.speakingWhileMutedNotification && !this.screenSharingMenuOpen) { - return this.speakingWhileMutedNotification - } - if (this.model.attributes.audioEnabled) { return this.disableKeyboardShortcuts ? t('spreed', 'Mute audio') diff --git a/src/components/TopBar/TopBarMediaControls.vue b/src/components/TopBar/TopBarMediaControls.vue index 001317ad971..8d2f1f44efb 100644 --- a/src/components/TopBar/TopBarMediaControls.vue +++ b/src/components/TopBar/TopBarMediaControls.vue @@ -180,7 +180,6 @@ export default { data() { return { - speakingWhileMutedNotification: null, screenSharingMenuOpen: false, boundaryElement: document.querySelector('.main-view'), mouseover: false, @@ -398,7 +397,7 @@ export default { }, mounted() { - this.speakingWhileMutedWarner = new SpeakingWhileMutedWarner(this.model, this) + this.speakingWhileMutedWarner = new SpeakingWhileMutedWarner(this.model) }, beforeDestroy() { @@ -408,10 +407,6 @@ export default { methods: { t, - setSpeakingWhileMutedNotification(message) { - this.speakingWhileMutedNotification = message - }, - toggleVirtualBackground() { if (this.model.attributes.virtualBackgroundEnabled) { this.model.disableVirtualBackground() diff --git a/src/utils/webrtc/SpeakingWhileMutedWarner.js b/src/utils/webrtc/SpeakingWhileMutedWarner.js index 22a6884b467..4fc4022d17e 100644 --- a/src/utils/webrtc/SpeakingWhileMutedWarner.js +++ b/src/utils/webrtc/SpeakingWhileMutedWarner.js @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import { showWarning, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs' import { t } from '@nextcloud/l10n' /** @@ -28,12 +29,11 @@ import { t } from '@nextcloud/l10n' * * @param {object} LocalMediaModel the model that emits "speakingWhileMuted" * events. - * @param {object} view the view that provides the * "setSpeakingWhileMutedNotification" method. */ -export default function SpeakingWhileMutedWarner(LocalMediaModel, view) { +export default function SpeakingWhileMutedWarner(LocalMediaModel) { this._model = LocalMediaModel - this._view = view + this._toast = null this._handleSpeakingWhileMutedChangeBound = this._handleSpeakingWhileMutedChange.bind(this) @@ -89,12 +89,19 @@ SpeakingWhileMutedWarner.prototype = { }, _showNotification(message) { - if (this._notification) { + if (this._toast) { return } - this._view.setSpeakingWhileMutedNotification(message) - this._notification = true + this._toast = showWarning(message, { + timeout: TOAST_PERMANENT_TIMEOUT, + onClick: () => { + this._toast.hideToast() + }, + onRemove: () => { + this._toast = null + } + }) }, _showBrowserNotification(message) { @@ -143,10 +150,8 @@ SpeakingWhileMutedWarner.prototype = { _hideWarning() { this._pendingBrowserNotification = false - if (this._notification) { - this._view.setSpeakingWhileMutedNotification(null) - - this._notification = false + if (this._toast) { + this._toast.hideToast() } if (this._browserNotification) {