From 0aa035069d4f1412e249a1154fde14bbcd55ab0f 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 | 7 ----- src/components/TopBar/TopBarMediaControls.vue | 7 +---- src/utils/webrtc/SpeakingWhileMutedWarner.js | 27 ++++++++++++------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/components/CallView/shared/LocalAudioControlButton.vue b/src/components/CallView/shared/LocalAudioControlButton.vue index b0aaa556c4a..02e978e9a4c 100644 --- a/src/components/CallView/shared/LocalAudioControlButton.vue +++ b/src/components/CallView/shared/LocalAudioControlButton.vue @@ -101,13 +101,6 @@ export default { } } - if (this.speakingWhileMutedNotification && !this.screenSharingMenuOpen) { - return { - content: this.speakingWhileMutedNotification, - show: true, - } - } - let content = '' if (this.model.attributes.audioEnabled) { content = this.disableKeyboardShortcuts diff --git a/src/components/TopBar/TopBarMediaControls.vue b/src/components/TopBar/TopBarMediaControls.vue index 3c406385ef2..cc9cbd2c69f 100644 --- a/src/components/TopBar/TopBarMediaControls.vue +++ b/src/components/TopBar/TopBarMediaControls.vue @@ -200,7 +200,6 @@ export default { data() { return { - speakingWhileMutedNotification: null, screenSharingMenuOpen: false, boundaryElement: document.querySelector('.main-view'), mouseover: false, @@ -414,7 +413,7 @@ export default { }, mounted() { - this.speakingWhileMutedWarner = new SpeakingWhileMutedWarner(this.model, this) + this.speakingWhileMutedWarner = new SpeakingWhileMutedWarner(this.model) }, beforeDestroy() { @@ -446,10 +445,6 @@ export default { }, - 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 bf13984ac26..acf272d5e93 100644 --- a/src/utils/webrtc/SpeakingWhileMutedWarner.js +++ b/src/utils/webrtc/SpeakingWhileMutedWarner.js @@ -19,6 +19,9 @@ * */ +import { showWarning, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs' +import { t } from '@nextcloud/l10n' + /** * Helper to warn the user if she is talking while muted. * @@ -42,12 +45,11 @@ * * @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) @@ -103,12 +105,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) { @@ -157,10 +166,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) {