[FIX] mail: play sound effect from new message with push notif
When odoo tab is out-of-focus and user receives a new message, it should play a sound effect. This works when showing notification in Odoo, but when push notifications were enabled it did not play the audio. This commit fixes the issue by playing audio when receiving push notification of new message while out-of-focusing the tab. closes odoo/odoo#125305 X-original-commit: b0b4f300705595df31588e747e1b12ad99f6d8d0 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com> Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -103,14 +103,7 @@ export class OutOfFocusService {
|
||||
*/
|
||||
async sendOdooNotification(message, options) {
|
||||
this.notificationService.add(message, options);
|
||||
if (this.canPlayAudio && this.multiTab.isOnMainTab()) {
|
||||
try {
|
||||
await this.audio.play();
|
||||
} catch {
|
||||
// Ignore errors due to the user not having interracted
|
||||
// with the page before playing the sound.
|
||||
}
|
||||
}
|
||||
this._playSound();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,6 +124,18 @@ export class OutOfFocusService {
|
||||
window.focus();
|
||||
notification.close();
|
||||
});
|
||||
this._playSound();
|
||||
}
|
||||
|
||||
async _playSound() {
|
||||
if (this.canPlayAudio && this.multiTab.isOnMainTab()) {
|
||||
try {
|
||||
await this.audio.play();
|
||||
} catch {
|
||||
// Ignore errors due to the user not having interracted
|
||||
// with the page before playing the sound.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get canPlayAudio() {
|
||||
|
||||
Reference in New Issue
Block a user