mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
fix: AudioContext warning when loading widget on Chrome (#3956)
* fix: AudioContext warning when loading widget on Chrome * minor fixes * Minor fixes * adds event on document * Play audio from parent window through SDK * Adds notification to dashboard Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
This commit is contained in:
@@ -21,7 +21,10 @@ import App from '../dashboard/App';
|
||||
import i18n from '../dashboard/i18n';
|
||||
import createAxios from '../dashboard/helper/APIHelper';
|
||||
import commonHelpers, { isJSONValid } from '../dashboard/helper/commons';
|
||||
import { getAlertAudio } from '../shared/helpers/AudioNotificationHelper';
|
||||
import {
|
||||
getAlertAudio,
|
||||
initOnEvents,
|
||||
} from '../shared/helpers/AudioNotificationHelper';
|
||||
import { initFaviconSwitcher } from '../shared/helpers/faviconHelper';
|
||||
import router from '../dashboard/routes';
|
||||
import store from '../dashboard/store';
|
||||
@@ -102,6 +105,13 @@ window.onload = () => {
|
||||
vueActionCable.init();
|
||||
};
|
||||
|
||||
const setupAudioListeners = () => {
|
||||
getAlertAudio().then(() => {
|
||||
initOnEvents.forEach(event => {
|
||||
document.removeEventListener(event, setupAudioListeners, false);
|
||||
});
|
||||
});
|
||||
};
|
||||
window.addEventListener('load', () => {
|
||||
verifyServiceWorkerExistence(registration =>
|
||||
registration.pushManager.getSubscription().then(subscription => {
|
||||
@@ -110,6 +120,9 @@ window.addEventListener('load', () => {
|
||||
}
|
||||
})
|
||||
);
|
||||
getAlertAudio();
|
||||
window.playAudioAlert = () => {};
|
||||
initOnEvents.forEach(e => {
|
||||
document.addEventListener(e, setupAudioListeners, false);
|
||||
});
|
||||
initFaviconSwitcher();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user