Skip to content

Commit

Permalink
fix(SpeakingWhileMutedWarner): show toast message instead of removed …
Browse files Browse the repository at this point in the history
…tooltip

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Dec 19, 2024
1 parent 1a87b78 commit 0aa0350
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
7 changes: 0 additions & 7 deletions src/components/CallView/shared/LocalAudioControlButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -200,7 +200,6 @@ export default {

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

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

beforeDestroy() {
Expand Down Expand Up @@ -446,10 +445,6 @@ export default {

},

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

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

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

0 comments on commit 0aa0350

Please sign in to comment.