From 3890b5c5fddab0e44cf2a5ab07b25d7c4ab3c753 Mon Sep 17 00:00:00 2001 From: Stanislas Signoud Date: Wed, 12 Jul 2023 03:02:32 +0200 Subject: [PATCH] [Glitch] Fix sounds not being loaded from assets host Port 01b9ee2b81091c4b000a76841c5f53589aa35f36 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/store/middlewares/sounds.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/store/middlewares/sounds.ts b/app/javascript/flavours/glitch/store/middlewares/sounds.ts index 6005d3649e..f7a07149d4 100644 --- a/app/javascript/flavours/glitch/store/middlewares/sounds.ts +++ b/app/javascript/flavours/glitch/store/middlewares/sounds.ts @@ -1,5 +1,8 @@ import type { Middleware, AnyAction } from 'redux'; +import ready from 'flavours/glitch/ready'; +import { assetHost } from 'flavours/glitch/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) =>