chore: Use different files for widget and dashboard audio alert (#4637)
This commit is contained in:
parent
ef850eda0f
commit
2e0d43c093
8 changed files with 7 additions and 7 deletions
|
@ -121,7 +121,7 @@ export const IFrameHelper = {
|
||||||
|
|
||||||
setupAudioListeners: () => {
|
setupAudioListeners: () => {
|
||||||
const { baseUrl = '' } = window.$chatwoot;
|
const { baseUrl = '' } = window.$chatwoot;
|
||||||
getAlertAudio(baseUrl).then(() =>
|
getAlertAudio(baseUrl, 'widget').then(() =>
|
||||||
initOnEvents.forEach(event => {
|
initOnEvents.forEach(event => {
|
||||||
document.removeEventListener(
|
document.removeEventListener(
|
||||||
event,
|
event,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { IFrameHelper } from 'widget/helpers/utils';
|
||||||
import { showBadgeOnFavicon } from './faviconHelper';
|
import { showBadgeOnFavicon } from './faviconHelper';
|
||||||
|
|
||||||
export const initOnEvents = ['click', 'touchstart', 'keypress', 'keydown'];
|
export const initOnEvents = ['click', 'touchstart', 'keypress', 'keydown'];
|
||||||
export const getAlertAudio = async (baseUrl = '') => {
|
export const getAlertAudio = async (baseUrl = '', type = 'dashboard') => {
|
||||||
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
const playsound = audioBuffer => {
|
const playsound = audioBuffer => {
|
||||||
window.playAudioAlert = () => {
|
window.playAudioAlert = () => {
|
||||||
|
@ -17,7 +17,7 @@ export const getAlertAudio = async (baseUrl = '') => {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resourceUrl = `${baseUrl}/dashboard/audios/ding.mp3`;
|
const resourceUrl = `${baseUrl}/audio/${type}/ding.mp3`;
|
||||||
const audioRequest = new Request(resourceUrl);
|
const audioRequest = new Request(resourceUrl);
|
||||||
|
|
||||||
fetch(audioRequest)
|
fetch(audioRequest)
|
||||||
|
|
|
@ -82,7 +82,7 @@ Rails.application.configure do
|
||||||
allow do
|
allow do
|
||||||
origins '*'
|
origins '*'
|
||||||
resource '/packs/*', headers: :any, methods: [:get, :options]
|
resource '/packs/*', headers: :any, methods: [:get, :options]
|
||||||
resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options]
|
resource '/audio/*', headers: :any, methods: [:get, :options]
|
||||||
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry']
|
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -121,7 +121,7 @@ Rails.application.configure do
|
||||||
allow do
|
allow do
|
||||||
origins '*'
|
origins '*'
|
||||||
resource '/packs/*', headers: :any, methods: [:get, :options]
|
resource '/packs/*', headers: :any, methods: [:get, :options]
|
||||||
resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options]
|
resource '/audio/*', headers: :any, methods: [:get, :options]
|
||||||
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false))
|
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false))
|
||||||
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry']
|
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry']
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,7 +87,7 @@ Rails.application.configure do
|
||||||
allow do
|
allow do
|
||||||
origins '*'
|
origins '*'
|
||||||
resource '/packs/*', headers: :any, methods: [:get, :options]
|
resource '/packs/*', headers: :any, methods: [:get, :options]
|
||||||
resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options]
|
resource '/audio/*', headers: :any, methods: [:get, :options]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,7 +58,7 @@ Rails.application.configure do
|
||||||
allow do
|
allow do
|
||||||
origins '*'
|
origins '*'
|
||||||
resource '/packs/*', headers: :any, methods: [:get, :options]
|
resource '/packs/*', headers: :any, methods: [:get, :options]
|
||||||
resource '/dashboard/audios/ding.mp3', headers: :any, methods: [:get, :options]
|
resource '/audio/*', headers: :any, methods: [:get, :options]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
BIN
public/audio/widget/ding.mp3
Normal file
BIN
public/audio/widget/ding.mp3
Normal file
Binary file not shown.
Loading…
Reference in a new issue