Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(frontend): リアクション選択時に音を流せるように #12441

Merged
merged 6 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
### Client
- Enhance: 絵文字のオートコンプリート機能強化 #12364
- Enhance: ユーザーのRawデータを表示するページが復活
- Enhance: リアクション選択時に音を鳴らせるように
- fix: 「設定のバックアップ」で一部の項目がバックアップに含まれていなかった問題を修正
- Fix: ウィジェットのジョブキューにて音声の発音方法変更に追従できていなかったのを修正 #12367
- Fix: コードエディタが正しく表示されない問題を修正
Expand Down
1 change: 1 addition & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,7 @@ export interface Locale {
"notification": string;
"antenna": string;
"channel": string;
"reaction": string;
};
"_ago": {
"future": string;
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@ _sfx:
notification: "通知"
antenna: "アンテナ受信"
channel: "チャンネル通知"
reaction: "リアクション選択時"

_ago:
future: "未来"
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/frontend/src/components/MkNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ import { focusPrev, focusNext } from '@/scripts/focus.js';
import { checkWordMute } from '@/scripts/check-word-mute.js';
import { userPage } from '@/filters/user.js';
import * as os from '@/os.js';
import * as sound from '@/scripts/sound.js';
import { defaultStore, noteViewInterruptors } from '@/store.js';
import { reactionPicker } from '@/scripts/reaction-picker.js';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
Expand Down Expand Up @@ -336,6 +337,8 @@ function react(viaKeyboard = false): void {
pleaseLogin();
showMovedDialog();
if (appearNote.reactionAcceptance === 'likeOnly') {
sound.play('reaction');

if (props.mock) {
return;
}
Expand All @@ -354,6 +357,8 @@ function react(viaKeyboard = false): void {
} else {
blur();
reactionPicker.show(reactButton.value, reaction => {
sound.play('reaction');

if (props.mock) {
emit('reaction', reaction);
return;
Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/src/components/MkNoteDetailed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ import { checkWordMute } from '@/scripts/check-word-mute.js';
import { userPage } from '@/filters/user.js';
import { notePage } from '@/filters/note.js';
import * as os from '@/os.js';
import * as sound from '@/scripts/sound.js';
import { defaultStore, noteViewInterruptors } from '@/store.js';
import { reactionPicker } from '@/scripts/reaction-picker.js';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
Expand Down Expand Up @@ -369,6 +370,8 @@ function react(viaKeyboard = false): void {
pleaseLogin();
showMovedDialog();
if (appearNote.reactionAcceptance === 'likeOnly') {
sound.play('reaction');

os.api('notes/reactions/create', {
noteId: appearNote.id,
reaction: '❤️',
Expand All @@ -383,6 +386,8 @@ function react(viaKeyboard = false): void {
} else {
blur();
reactionPicker.show(reactButton.value, reaction => {
sound.play('reaction');

os.api('notes/reactions/create', {
noteId: appearNote.id,
reaction: reaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import MkReactionEffect from '@/components/MkReactionEffect.vue';
import { claimAchievement } from '@/scripts/achievements.js';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
import * as sound from '@/scripts/sound.js';

const props = defineProps<{
reaction: string;
Expand Down Expand Up @@ -59,6 +60,10 @@ async function toggleReaction() {
});
if (confirm.canceled) return;

if (oldReaction !== props.reaction) {
sound.play('reaction');
}

if (mock) {
emit('reactionToggled', props.reaction, (props.count - 1));
return;
Expand All @@ -75,6 +80,8 @@ async function toggleReaction() {
}
});
} else {
sound.play('reaction');

if (mock) {
emit('reactionToggled', props.reaction, (props.count + 1));
return;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/pages/settings/sounds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ import { defaultStore } from '@/store.js';

const masterVolume = computed(defaultStore.makeGetterSetter('sound_masterVolume'));

const soundsKeys = ['note', 'noteMy', 'notification', 'antenna', 'channel'] as const;
const soundsKeys = ['note', 'noteMy', 'notification', 'antenna', 'channel', 'reaction'] as const;

const sounds = ref<Record<typeof soundsKeys[number], Ref<any>>>({
note: defaultStore.reactiveState.sound_note,
noteMy: defaultStore.reactiveState.sound_noteMy,
notification: defaultStore.reactiveState.sound_notification,
antenna: defaultStore.reactiveState.sound_antenna,
channel: defaultStore.reactiveState.sound_channel,
reaction: defaultStore.reactiveState.sound_reaction,
});

async function updated(type: keyof typeof sounds.value, sound) {
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/scripts/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const soundsTypes = [
'syuilo/waon',
'syuilo/popo',
'syuilo/triple',
'syuilo/bubble1',
'syuilo/bubble2',
'syuilo/poi1',
'syuilo/poi2',
'syuilo/pirori',
Expand Down Expand Up @@ -77,7 +79,7 @@ export async function loadAudio(file: string, useCache = true) {
return audioBuffer;
}

export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notification') {
export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notification' | 'reaction') {
const sound = defaultStore.state[`sound_${type}`];
if (_DEV_) console.log('play', type, sound);
if (sound.type == null) return;
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: { type: 'syuilo/square-pico', volume: 1 },
},
sound_reaction: {
where: 'device',
default: { type: 'syuilo/bubble2', volume: 1 },
},
}));

// TODO: 他のタブと永続化されたstateを同期
Expand Down
Loading