diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-11-17 18:32:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-17 18:32:42 +0900 |
| commit | 9784d10c62e294b32cf62b7374bed7ce57a42b9d (patch) | |
| tree | 02a917ca83373cfeb9dc516c07810fdf8f8e5b30 /packages/frontend/src/scripts | |
| parent | Merge pull request #12177 from misskey-dev/develop (diff) | |
| parent | Revert "chore(frontend): tweak rt style for safari" (diff) | |
| download | misskey-9784d10c62e294b32cf62b7374bed7ce57a42b9d.tar.gz misskey-9784d10c62e294b32cf62b7374bed7ce57a42b9d.tar.bz2 misskey-9784d10c62e294b32cf62b7374bed7ce57a42b9d.zip | |
Merge pull request #12330 from misskey-dev/develop
Release: 2023.11.1
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/lookup-user.ts | 23 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/mfm-tags.ts | 6 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/sound.ts | 39 |
3 files changed, 50 insertions, 18 deletions
diff --git a/packages/frontend/src/scripts/lookup-user.ts b/packages/frontend/src/scripts/lookup-user.ts index 3dbc03f777..a35fe898e4 100644 --- a/packages/frontend/src/scripts/lookup-user.ts +++ b/packages/frontend/src/scripts/lookup-user.ts @@ -39,3 +39,26 @@ export async function lookupUser() { notFound(); }); } + +export async function lookupUserByEmail() { + const { canceled, result } = await os.inputText({ + title: i18n.ts.emailAddress, + type: 'email', + }); + if (canceled) return; + + try { + const user = await os.apiWithDialog('admin/accounts/find-by-email', { email: result }); + + os.pageWindow(`/admin/user/${user.id}`); + } catch (err) { + if (err.code === 'USER_NOT_FOUND') { + os.alert({ + type: 'error', + text: i18n.ts.noSuchUser, + }); + } else { + throw err; + } + } +} diff --git a/packages/frontend/src/scripts/mfm-tags.ts b/packages/frontend/src/scripts/mfm-tags.ts deleted file mode 100644 index dc78e42238..0000000000 --- a/packages/frontend/src/scripts/mfm-tags.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'scale', 'position', 'fg', 'bg', 'font', 'blur', 'rainbow', 'sparkle', 'rotate']; diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts index f995c122d1..4b0cd0bb39 100644 --- a/packages/frontend/src/scripts/sound.ts +++ b/packages/frontend/src/scripts/sound.ts @@ -5,7 +5,8 @@ import { defaultStore } from '@/store.js'; -const cache = new Map<string, HTMLAudioElement>(); +const ctx = new AudioContext(); +const cache = new Map<string, AudioBuffer>(); export const soundsTypes = [ null, @@ -60,15 +61,20 @@ export const soundsTypes = [ 'noizenecio/kick_gaba7', ] as const; -export function getAudio(file: string, useCache = true): HTMLAudioElement { - let audio: HTMLAudioElement; +export async function getAudio(file: string, useCache = true) { if (useCache && cache.has(file)) { - audio = cache.get(file); - } else { - audio = new Audio(`/client-assets/sounds/${file}.mp3`); - if (useCache) cache.set(file, audio); + return cache.get(file)!; } - return audio; + + const response = await fetch(`/client-assets/sounds/${file}.mp3`); + const arrayBuffer = await response.arrayBuffer(); + const audioBuffer = await ctx.decodeAudioData(arrayBuffer); + + if (useCache) { + cache.set(file, audioBuffer); + } + + return audioBuffer; } export function setVolume(audio: HTMLAudioElement, volume: number): HTMLAudioElement { @@ -84,8 +90,17 @@ export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notifica playFile(sound.type, sound.volume); } -export function playFile(file: string, volume: number) { - const audio = setVolume(getAudio(file), volume); - if (audio.volume === 0) return; - audio.play(); +export async function playFile(file: string, volume: number) { + const masterVolume = defaultStore.state.sound_masterVolume; + if (masterVolume === 0 || volume === 0) { + return; + } + + const gainNode = ctx.createGain(); + gainNode.gain.value = masterVolume * volume; + + const soundSource = ctx.createBufferSource(); + soundSource.buffer = await getAudio(file); + soundSource.connect(gainNode).connect(ctx.destination); + soundSource.start(); } |