mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-53222 - Fix: Calls Ringing sometimes controllable with media keys (#23775)
* prevent media keys from controlling calls ring sounds * stop ring on pause --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
fe8d66bc98
commit
9bc22b633f
@ -54,12 +54,19 @@ export function ring(name: string) {
|
|||||||
stopRing();
|
stopRing();
|
||||||
|
|
||||||
currentRing = loopNotificationRing(name);
|
currentRing = loopNotificationRing(name);
|
||||||
|
currentRing.addEventListener('pause', () => {
|
||||||
|
stopRing();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stopRing() {
|
export function stopRing() {
|
||||||
currentRing?.pause();
|
if (currentRing) {
|
||||||
|
currentRing.pause();
|
||||||
|
currentRing.src = '';
|
||||||
|
currentRing.remove();
|
||||||
currentRing = null;
|
currentRing = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let currentTryRing: HTMLAudioElement | null = null;
|
let currentTryRing: HTMLAudioElement | null = null;
|
||||||
let currentTimer: NodeJS.Timeout;
|
let currentTimer: NodeJS.Timeout;
|
||||||
@ -71,15 +78,23 @@ export function tryNotificationRing(name: string) {
|
|||||||
clearTimeout(currentTimer);
|
clearTimeout(currentTimer);
|
||||||
|
|
||||||
currentTryRing = loopNotificationRing(name);
|
currentTryRing = loopNotificationRing(name);
|
||||||
|
currentTryRing.addEventListener('pause', () => {
|
||||||
|
stopTryNotificationRing();
|
||||||
|
});
|
||||||
|
|
||||||
currentTimer = setTimeout(() => {
|
currentTimer = setTimeout(() => {
|
||||||
stopTryNotificationRing();
|
stopTryNotificationRing();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stopTryNotificationRing() {
|
export function stopTryNotificationRing() {
|
||||||
currentTryRing?.pause();
|
if (currentTryRing) {
|
||||||
|
currentTryRing.pause();
|
||||||
|
currentTryRing.src = '';
|
||||||
|
currentTryRing.remove();
|
||||||
currentTryRing = null;
|
currentTryRing = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function loopNotificationRing(name: string) {
|
export function loopNotificationRing(name: string) {
|
||||||
const audio = new Audio(callsNotificationSounds.get(name) ?? callsNotificationSounds.get('Dynamic'));
|
const audio = new Audio(callsNotificationSounds.get(name) ?? callsNotificationSounds.get('Dynamic'));
|
||||||
|
Loading…
Reference in New Issue
Block a user