Fix sounds not being loaded from assets host (#25931)

local
Stanislas Signoud 11 months ago committed by GitHub
parent ca955ada0b
commit 1392f31ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      app/javascript/mastodon/store/middlewares/sounds.ts

@ -1,5 +1,8 @@
import type { Middleware, AnyAction } from 'redux'; import type { Middleware, AnyAction } from 'redux';
import ready from 'mastodon/ready';
import { assetHost } from 'mastodon/utils/config';
import type { RootState } from '..'; import type { RootState } from '..';
interface AudioSource { interface AudioSource {
@ -35,18 +38,20 @@ export const soundsMiddleware = (): Middleware<
Record<string, never>, Record<string, never>,
RootState RootState
> => { > => {
const soundCache: { [key: string]: HTMLAudioElement } = { const soundCache: { [key: string]: HTMLAudioElement } = {};
boop: createAudio([
void ready(() => {
soundCache.boop = createAudio([
{ {
src: '/sounds/boop.ogg', src: `${assetHost}/sounds/boop.ogg`,
type: 'audio/ogg', type: 'audio/ogg',
}, },
{ {
src: '/sounds/boop.mp3', src: `${assetHost}/sounds/boop.mp3`,
type: 'audio/mpeg', type: 'audio/mpeg',
}, },
]), ]);
}; });
return () => return () =>
(next) => (next) =>

Loading…
Cancel
Save