summaryrefslogtreecommitdiff
path: root/packages/frontend/src
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2023-11-26 13:04:44 +0900
committerGitHub <noreply@github.com>2023-11-26 13:04:44 +0900
commit5bdae9f6d03bbb1fc1cf341b2e6b3e5d15d03fad (patch)
tree70dff15751b9796067de64cb667a026edd41bf97 /packages/frontend/src
parentfix: query error in notes/featured (#12439) (diff)
downloadsharkey-5bdae9f6d03bbb1fc1cf341b2e6b3e5d15d03fad.tar.gz
sharkey-5bdae9f6d03bbb1fc1cf341b2e6b3e5d15d03fad.tar.bz2
sharkey-5bdae9f6d03bbb1fc1cf341b2e6b3e5d15d03fad.zip
enhance(frontend): リアクション選択時に音を流せるように (#12441)
* (add) リアクション選択時に音を鳴らせるように * Update Changelog * tweak sound * tweak sound --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/frontend/src')
-rw-r--r--packages/frontend/src/components/MkNote.vue5
-rw-r--r--packages/frontend/src/components/MkNoteDetailed.vue5
-rw-r--r--packages/frontend/src/components/MkReactionsViewer.reaction.vue7
-rw-r--r--packages/frontend/src/pages/settings/sounds.vue3
-rw-r--r--packages/frontend/src/scripts/sound.ts4
-rw-r--r--packages/frontend/src/store.ts4
6 files changed, 26 insertions, 2 deletions
diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue
index 6349df2e30..d047495dc9 100644
--- a/packages/frontend/src/components/MkNote.vue
+++ b/packages/frontend/src/components/MkNote.vue
@@ -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';
@@ -336,6 +337,8 @@ function react(viaKeyboard = false): void {
pleaseLogin();
showMovedDialog();
if (appearNote.reactionAcceptance === 'likeOnly') {
+ sound.play('reaction');
+
if (props.mock) {
return;
}
@@ -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;
diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue
index d1bc3f676f..d8089ac36f 100644
--- a/packages/frontend/src/components/MkNoteDetailed.vue
+++ b/packages/frontend/src/components/MkNoteDetailed.vue
@@ -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';
@@ -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: '❤️',
@@ -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,
diff --git a/packages/frontend/src/components/MkReactionsViewer.reaction.vue b/packages/frontend/src/components/MkReactionsViewer.reaction.vue
index 9a107c3674..65a5c2374e 100644
--- a/packages/frontend/src/components/MkReactionsViewer.reaction.vue
+++ b/packages/frontend/src/components/MkReactionsViewer.reaction.vue
@@ -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;
@@ -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;
@@ -75,6 +80,8 @@ async function toggleReaction() {
}
});
} else {
+ sound.play('reaction');
+
if (mock) {
emit('reactionToggled', props.reaction, (props.count + 1));
return;
diff --git a/packages/frontend/src/pages/settings/sounds.vue b/packages/frontend/src/pages/settings/sounds.vue
index cd1707a594..244bb1e0e2 100644
--- a/packages/frontend/src/pages/settings/sounds.vue
+++ b/packages/frontend/src/pages/settings/sounds.vue
@@ -38,7 +38,7 @@ 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,
@@ -46,6 +46,7 @@ const sounds = ref<Record<typeof soundsKeys[number], Ref<any>>>({
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) {
diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts
index 2b604bd98a..4d7ef9bdee 100644
--- a/packages/frontend/src/scripts/sound.ts
+++ b/packages/frontend/src/scripts/sound.ts
@@ -38,6 +38,8 @@ export const soundsTypes = [
'syuilo/waon',
'syuilo/popo',
'syuilo/triple',
+ 'syuilo/bubble1',
+ 'syuilo/bubble2',
'syuilo/poi1',
'syuilo/poi2',
'syuilo/pirori',
@@ -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;
diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts
index 12660e9e8d..f2ed4e7c0b 100644
--- a/packages/frontend/src/store.ts
+++ b/packages/frontend/src/store.ts
@@ -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を同期