From 9cff3868deaa35e5433bc39a392f8fd6d3e5a89e Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 4 Mar 2018 18:50:30 +0900 Subject: [PATCH] make sounds great again --- src/web/app/common/mios.ts | 7 +++++++ .../common/views/components/messaging-room.vue | 6 ++++++ .../app/desktop/views/components/settings.vue | 11 +++++++++++ .../app/desktop/views/components/timeline.vue | 6 ++++++ src/web/assets/message.mp3 | Bin 0 -> 4584 bytes src/web/assets/post.mp3 | Bin 0 -> 2506 bytes 6 files changed, 30 insertions(+) create mode 100644 src/web/assets/message.mp3 create mode 100644 src/web/assets/post.mp3 diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index bc83ec0bbb..c5f0d1d4dc 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -94,6 +94,13 @@ export default class MiOS extends EventEmitter { return localStorage.getItem('debug') == 'true'; } + /** + * Whether enable sounds + */ + public get isEnableSounds() { + return localStorage.getItem('enableSounds') == 'true'; + } + public apis: API; /** diff --git a/src/web/app/common/views/components/messaging-room.vue b/src/web/app/common/views/components/messaging-room.vue index 0a675ba03e..e15e10ec7d 100644 --- a/src/web/app/common/views/components/messaging-room.vue +++ b/src/web/app/common/views/components/messaging-room.vue @@ -29,6 +29,7 @@ import Vue from 'vue'; import MessagingStreamConnection from '../../scripts/streaming/messaging-stream'; import XMessage from './messaging-room.message.vue'; import XForm from './messaging-room.form.vue'; +import { url } from '../../../config'; export default Vue.extend({ components: { @@ -147,6 +148,11 @@ export default Vue.extend({ }, onMessage(message) { + // サウンドを再生する + if ((this as any).os.isEnableSounds) { + new Audio(`${url}/assets/message.mp3`).play(); + } + const isBottom = this.isBottom(); this.messages.push(message); diff --git a/src/web/app/desktop/views/components/settings.vue b/src/web/app/desktop/views/components/settings.vue index cba14f5f95..a0ffc4e0aa 100644 --- a/src/web/app/desktop/views/components/settings.vue +++ b/src/web/app/desktop/views/components/settings.vue @@ -26,6 +26,13 @@ +
+

サウンド

+ + 投稿やメッセージを送受信したときなどにサウンドを再生します。この設定はブラウザに記憶されます。 + +
+

モバイル

@@ -166,6 +173,7 @@ export default Vue.extend({ version, latestVersion: undefined, checkingForUpdate: false, + enableSounds: localStorage.getItem('enableSounds') == 'true', lang: localStorage.getItem('lang') || '', preventUpdate: localStorage.getItem('preventUpdate') == 'true', debug: localStorage.getItem('debug') == 'true', @@ -173,6 +181,9 @@ export default Vue.extend({ }; }, watch: { + enableSounds() { + localStorage.setItem('enableSounds', this.enableSounds ? 'true' : 'false'); + }, lang() { localStorage.setItem('lang', this.lang); }, diff --git a/src/web/app/desktop/views/components/timeline.vue b/src/web/app/desktop/views/components/timeline.vue index 0d16d60df9..c35baa159e 100644 --- a/src/web/app/desktop/views/components/timeline.vue +++ b/src/web/app/desktop/views/components/timeline.vue @@ -18,6 +18,7 @@