Skip to content

Commit

Permalink
Merge pull request #14023 from nextcloud/fix/noid/muted-warner-toast
Browse files Browse the repository at this point in the history
fix(SpeakingWhileMutedWarner): show toast message
  • Loading branch information
Antreesy authored Dec 19, 2024
2 parents 7f3b693 + 5559cc8 commit 77842ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/components/CallView/shared/LocalAudioControlButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
7 changes: 1 addition & 6 deletions src/components/TopBar/TopBarMediaControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export default {

data() {
return {
speakingWhileMutedNotification: null,
screenSharingMenuOpen: false,
boundaryElement: document.querySelector('.main-view'),
mouseover: false,
Expand Down Expand Up @@ -398,7 +397,7 @@ export default {
},

mounted() {
this.speakingWhileMutedWarner = new SpeakingWhileMutedWarner(this.model, this)
this.speakingWhileMutedWarner = new SpeakingWhileMutedWarner(this.model)
},

beforeDestroy() {
Expand All @@ -408,10 +407,6 @@ export default {
methods: {
t,

setSpeakingWhileMutedNotification(message) {
this.speakingWhileMutedNotification = message
},

toggleVirtualBackground() {
if (this.model.attributes.virtualBackgroundEnabled) {
this.model.disableVirtualBackground()
Expand Down
25 changes: 15 additions & 10 deletions src/utils/webrtc/SpeakingWhileMutedWarner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

/**
Expand All @@ -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)

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 77842ae

Please sign in to comment.