summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authoranatawa12 <anatawa12@icloud.com>2024-07-28 14:44:15 +0900
committerGitHub <noreply@github.com>2024-07-28 14:44:15 +0900
commit865b3039ccf6eec4f277dbb33296ab767d2ed7ce (patch)
tree6757123ceaec4fe7006142b905ad317fbf4eaec4 /packages
parentBump version to 2024.7.0-beta.3 (diff)
downloadsharkey-865b3039ccf6eec4f277dbb33296ab767d2ed7ce.tar.gz
sharkey-865b3039ccf6eec4f277dbb33296ab767d2ed7ce.tar.bz2
sharkey-865b3039ccf6eec4f277dbb33296ab767d2ed7ce.zip
fix: deck uiの通知音が重なる問題 (#14029)
* fix: deck uiの通知音が重なる * docs: Fix: deck uiの通知音が重なる問題 * unexport internal function * fix Co-authored-by: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> * chore: improve condition * docs: move js dco comment --------- Co-authored-by: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages')
-rw-r--r--packages/frontend/src/scripts/sound.ts23
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts
index bba855cd64..814e080811 100644
--- a/packages/frontend/src/scripts/sound.ts
+++ b/packages/frontend/src/scripts/sound.ts
@@ -124,10 +124,23 @@ export async function loadAudio(url: string, options?: { useCache?: boolean; })
*/
export function playMisskeySfx(operationType: OperationType) {
const sound = defaultStore.state[`sound_${operationType}`];
- if (sound.type == null || !canPlay || ('userActivation' in navigator && !navigator.userActivation.hasBeenActive)) return;
+ playMisskeySfxFile(sound);
+}
+
+/**
+ * サウンド設定形式で指定された音声を再生する
+ * @param soundStore サウンド設定
+ */
+export function playMisskeySfxFile(soundStore: SoundStore) {
+ // 連続して再生しない
+ if (!canPlay) return;
+ // ユーザーアクティベーションが必要な場合はそれがない場合は再生しない
+ if ('userActivation' in navigator && !navigator.userActivation.hasBeenActive) return;
+ // サウンドがない場合は再生しない
+ if (soundStore.type === null || soundStore.type === '_driveFile_' && !soundStore.fileUrl) return;
canPlay = false;
- playMisskeySfxFile(sound).finally(() => {
+ playMisskeySfxFileInternal(soundStore).finally(() => {
// ごく短時間に音が重複しないように
setTimeout(() => {
canPlay = true;
@@ -135,11 +148,7 @@ export function playMisskeySfx(operationType: OperationType) {
});
}
-/**
- * サウンド設定形式で指定された音声を再生する
- * @param soundStore サウンド設定
- */
-export async function playMisskeySfxFile(soundStore: SoundStore) {
+async function playMisskeySfxFileInternal(soundStore: SoundStore) {
if (soundStore.type === null || (soundStore.type === '_driveFile_' && !soundStore.fileUrl)) {
return;
}