make sounds great again

This commit is contained in:
syuilo 2018-03-04 18:50:30 +09:00
parent bad780ce96
commit 9cff3868de
6 changed files with 30 additions and 0 deletions

View file

@ -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;
/**

View file

@ -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);

View file

@ -26,6 +26,13 @@
<mk-switch v-model="os.i.client_settings.showPostFormOnTopOfTl" @change="onChangeShowPostFormOnTopOfTl" text="タイムライン上部に投稿フォームを表示する"/>
</section>
<section class="web" v-show="page == 'web'">
<h1>サウンド</h1>
<mk-switch v-model="enableSounds" text="サウンドを有効にする">
<span>投稿やメッセージを送受信したときなどにサウンドを再生しますこの設定はブラウザに記憶されます</span>
</mk-switch>
</section>
<section class="web" v-show="page == 'web'">
<h1>モバイル</h1>
<mk-switch v-model="os.i.client_settings.disableViaMobile" @change="onChangeDisableViaMobile" text="「モバイルからの投稿」フラグを付けない"/>
@ -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);
},

View file

@ -18,6 +18,7 @@
<script lang="ts">
import Vue from 'vue';
import { url } from '../../../config';
export default Vue.extend({
data() {
@ -93,6 +94,11 @@ export default Vue.extend({
});
},
onPost(post) {
//
if ((this as any).os.isEnableSounds) {
new Audio(`${url}/assets/post.mp3`).play();
}
this.posts.unshift(post);
},
onChangeFollowing() {

BIN
src/web/assets/message.mp3 Normal file

Binary file not shown.

BIN
src/web/assets/post.mp3 Normal file

Binary file not shown.