diff --git a/app/javascript/mastodon/store/middlewares/sounds.ts b/app/javascript/mastodon/store/middlewares/sounds.ts index 6005d3649..47b9fb8ba 100644 --- a/app/javascript/mastodon/store/middlewares/sounds.ts +++ b/app/javascript/mastodon/store/middlewares/sounds.ts @@ -1,5 +1,8 @@ import type { Middleware, AnyAction } from 'redux'; +import ready from 'mastodon/ready'; +import { assetHost } from 'mastodon/utils/config'; + import type { RootState } from '..'; interface AudioSource { @@ -35,18 +38,20 @@ export const soundsMiddleware = (): Middleware< Record, RootState > => { - const soundCache: { [key: string]: HTMLAudioElement } = { - boop: createAudio([ + const soundCache: { [key: string]: HTMLAudioElement } = {}; + + void ready(() => { + soundCache.boop = createAudio([ { - src: '/sounds/boop.ogg', + src: `${assetHost}/sounds/boop.ogg`, type: 'audio/ogg', }, { - src: '/sounds/boop.mp3', + src: `${assetHost}/sounds/boop.mp3`, type: 'audio/mpeg', }, - ]), - }; + ]); + }); return () => (next) =>