diff options
author | Eugen <eugen@zeonfederated.com> | 2017-03-15 22:55:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-15 22:55:22 +0100 |
commit | e245115f47082ffba27205f508301d14e792c369 (patch) | |
tree | 21a77b788dace45b734da6e64f1b0705016192f0 /app/assets/javascripts/components/middleware/sounds.jsx | |
parent | 620f70e42c16c324459ca2da52c68f1def8683de (diff) | |
parent | c1124228e857b0e85f5bf927d2c41c7fadfdf955 (diff) |
Merge branch 'master' into mastodon-site-api
Diffstat (limited to 'app/assets/javascripts/components/middleware/sounds.jsx')
-rw-r--r-- | app/assets/javascripts/components/middleware/sounds.jsx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/assets/javascripts/components/middleware/sounds.jsx b/app/assets/javascripts/components/middleware/sounds.jsx new file mode 100644 index 000000000..200efa3d7 --- /dev/null +++ b/app/assets/javascripts/components/middleware/sounds.jsx @@ -0,0 +1,22 @@ +const play = audio => { + if (!audio.paused) { + audio.pause(); + audio.fastSeek(0); + } + + audio.play(); +}; + +export default function soundsMiddleware() { + const soundCache = { + boop: new Audio(['/sounds/boop.mp3']) + }; + + return ({ dispatch }) => next => (action) => { + if (action.meta && action.meta.sound && soundCache[action.meta.sound]) { + play(soundCache[action.meta.sound]); + } + + return next(action); + }; +}; |