summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/sound.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-11-04 10:09:21 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-11-04 10:09:21 +0900
commit67414e0181877730d598f76dcc54bc1d10b86bd3 (patch)
treea3b4576ada6336e464aa8affb9b5f931991e21ee /packages/frontend/src/scripts/sound.ts
parentUpdate about-misskey.vue (diff)
downloadsharkey-67414e0181877730d598f76dcc54bc1d10b86bd3.tar.gz
sharkey-67414e0181877730d598f76dcc54bc1d10b86bd3.tar.bz2
sharkey-67414e0181877730d598f76dcc54bc1d10b86bd3.zip
perf(frontend): soundConfigStore を defaultStore に統合しAPIリクエストを削減
Diffstat (limited to 'packages/frontend/src/scripts/sound.ts')
-rw-r--r--packages/frontend/src/scripts/sound.ts46
1 files changed, 3 insertions, 43 deletions
diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts
index 1ef075818f..f995c122d1 100644
--- a/packages/frontend/src/scripts/sound.ts
+++ b/packages/frontend/src/scripts/sound.ts
@@ -3,47 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
-import { markRaw } from 'vue';
-import { Storage } from '@/pizzax.js';
-
-export const soundConfigStore = markRaw(new Storage('sound', {
- sound_masterVolume: {
- where: 'device',
- default: 0.3,
- },
- sound_note: {
- where: 'account',
- default: { type: 'syuilo/n-aec', volume: 1 },
- },
- sound_noteMy: {
- where: 'account',
- default: { type: 'syuilo/n-cea-4va', volume: 1 },
- },
- sound_notification: {
- where: 'account',
- default: { type: 'syuilo/n-ea', volume: 1 },
- },
- sound_antenna: {
- where: 'account',
- default: { type: 'syuilo/triple', volume: 1 },
- },
- sound_channel: {
- where: 'account',
- default: { type: 'syuilo/square-pico', volume: 1 },
- },
-}));
-
-await soundConfigStore.ready;
-
-//#region サウンドのColdDeviceStorage => indexedDBのマイグレーション
-for (const target of Object.keys(soundConfigStore.state) as Array<keyof typeof soundConfigStore.state>) {
- const value = localStorage.getItem(`miux:${target}`);
- if (value) {
- soundConfigStore.set(target, JSON.parse(value) as typeof soundConfigStore.def[typeof target]['default']);
- localStorage.removeItem(`miux:${target}`);
- }
-}
-//#endregion
+import { defaultStore } from '@/store.js';
const cache = new Map<string, HTMLAudioElement>();
@@ -112,13 +72,13 @@ export function getAudio(file: string, useCache = true): HTMLAudioElement {
}
export function setVolume(audio: HTMLAudioElement, volume: number): HTMLAudioElement {
- const masterVolume = soundConfigStore.state.sound_masterVolume;
+ const masterVolume = defaultStore.state.sound_masterVolume;
audio.volume = masterVolume - ((1 - volume) * masterVolume);
return audio;
}
export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notification') {
- const sound = soundConfigStore.state[`sound_${type}`];
+ const sound = defaultStore.state[`sound_${type}`];
if (_DEV_) console.log('play', type, sound);
if (sound.type == null) return;
playFile(sound.type, sound.volume);