Skip to content

Commit

Permalink
vuexのstoreの呼び出しをリテラル引数からDot記法へ: components/Sing (#2330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Segu-g authored Oct 28, 2024
1 parent e49d70e commit 9ba51de
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 108 deletions.
82 changes: 41 additions & 41 deletions src/components/Sing/ScoreSequencer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const onLyricInput = (text: string, note: Note) => {
const onLyricConfirmed = (nextNoteId: NoteId | undefined) => {
commitPreviewLyrics();
void store.dispatch("SET_EDITING_LYRIC_NOTE_ID", { noteId: nextNoteId });
void store.actions.SET_EDITING_LYRIC_NOTE_ID({ noteId: nextNoteId });
};
// プレビュー
Expand Down Expand Up @@ -763,9 +763,9 @@ const getYInBorderBox = (clientY: number, element: HTMLElement) => {
};
const selectOnlyThis = (note: Note) => {
void store.dispatch("DESELECT_ALL_NOTES");
void store.dispatch("SELECT_NOTES", { noteIds: [note.id] });
void store.dispatch("PLAY_PREVIEW_SOUND", {
void store.actions.DESELECT_ALL_NOTES();
void store.actions.SELECT_NOTES({ noteIds: [note.id] });
void store.actions.PLAY_PREVIEW_SOUND({
noteNumber: note.noteNumber,
duration: PREVIEW_SOUND_DURATION,
});
Expand Down Expand Up @@ -811,7 +811,7 @@ const startPreview = (event: MouseEvent, mode: PreviewMode, note?: Note) => {
noteNumber: cursorNoteNumber,
lyric: getDoremiFromNoteNumber(cursorNoteNumber),
};
void store.dispatch("DESELECT_ALL_NOTES");
void store.actions.DESELECT_ALL_NOTES();
copiedNotes.push(note);
} else {
if (!note) {
Expand All @@ -834,9 +834,9 @@ const startPreview = (event: MouseEvent, mode: PreviewMode, note?: Note) => {
noteIdsToSelect.push(noteId);
}
}
void store.dispatch("SELECT_NOTES", { noteIds: noteIdsToSelect });
void store.actions.SELECT_NOTES({ noteIds: noteIdsToSelect });
} else if (isOnCommandOrCtrlKeyDown(event)) {
void store.dispatch("SELECT_NOTES", { noteIds: [note.id] });
void store.actions.SELECT_NOTES({ noteIds: [note.id] });
} else if (!selectedNoteIds.value.has(note.id)) {
void selectOnlyThis(note);
}
Expand Down Expand Up @@ -895,21 +895,21 @@ const endPreview = () => {
// 編集ターゲットがノートのときにプレビューを開始した場合の処理
if (edited) {
if (previewMode.value === "ADD_NOTE") {
void store.dispatch("COMMAND_ADD_NOTES", {
void store.actions.COMMAND_ADD_NOTES({
notes: previewNotes.value,
trackId: selectedTrackId.value,
});
void store.dispatch("SELECT_NOTES", {
void store.actions.SELECT_NOTES({
noteIds: previewNotes.value.map((value) => value.id),
});
} else {
void store.dispatch("COMMAND_UPDATE_NOTES", {
void store.actions.COMMAND_UPDATE_NOTES({
notes: previewNotes.value,
trackId: selectedTrackId.value,
});
}
if (previewNotes.value.length === 1) {
void store.dispatch("PLAY_PREVIEW_SOUND", {
void store.actions.PLAY_PREVIEW_SOUND({
noteNumber: previewNotes.value[0].noteNumber,
duration: PREVIEW_SOUND_DURATION,
});
Expand All @@ -932,14 +932,14 @@ const endPreview = () => {
applyGaussianFilter(data, 0.7);
data = data.map((value) => Math.exp(value));
void store.dispatch("COMMAND_SET_PITCH_EDIT_DATA", {
void store.actions.COMMAND_SET_PITCH_EDIT_DATA({
pitchArray: data,
startFrame: previewPitchEdit.value.startFrame,
trackId: selectedTrackId.value,
});
}
} else if (previewPitchEditType === "erase") {
void store.dispatch("COMMAND_ERASE_PITCH_EDIT_DATA", {
void store.actions.COMMAND_ERASE_PITCH_EDIT_DATA({
startFrame: previewPitchEdit.value.startFrame,
frameLength: previewPitchEdit.value.frameLength,
trackId: selectedTrackId.value,
Expand Down Expand Up @@ -972,7 +972,7 @@ const onNoteBarDoubleClick = (event: MouseEvent, note: Note) => {
}
const mouseButton = getButton(event);
if (mouseButton === "LEFT_BUTTON" && note.id !== state.editingLyricNoteId) {
void store.dispatch("SET_EDITING_LYRIC_NOTE_ID", { noteId: note.id });
void store.actions.SET_EDITING_LYRIC_NOTE_ID({ noteId: note.id });
}
};
Expand Down Expand Up @@ -1017,7 +1017,7 @@ const onMouseDown = (event: MouseEvent) => {
startPreview(event, "ADD_NOTE");
}
} else {
void store.dispatch("DESELECT_ALL_NOTES");
void store.actions.DESELECT_ALL_NOTES();
}
} else if (editTarget.value === "PITCH") {
if (mouseButton === "LEFT_BUTTON") {
Expand Down Expand Up @@ -1105,9 +1105,9 @@ const rectSelect = (additive: boolean) => {
}
}
if (!additive) {
void store.dispatch("DESELECT_ALL_NOTES");
void store.actions.DESELECT_ALL_NOTES();
}
void store.dispatch("SELECT_NOTES", { noteIds: noteIdsToSelect });
void store.actions.SELECT_NOTES({ noteIds: noteIdsToSelect });
};
const onMouseEnter = () => {
Expand All @@ -1128,13 +1128,13 @@ const handleNotesArrowUp = () => {
if (editedNotes.some((note) => note.noteNumber > 127)) {
return;
}
void store.dispatch("COMMAND_UPDATE_NOTES", {
void store.actions.COMMAND_UPDATE_NOTES({
notes: editedNotes,
trackId: selectedTrackId.value,
});
if (editedNotes.length === 1) {
void store.dispatch("PLAY_PREVIEW_SOUND", {
void store.actions.PLAY_PREVIEW_SOUND({
noteNumber: editedNotes[0].noteNumber,
duration: PREVIEW_SOUND_DURATION,
});
Expand All @@ -1150,13 +1150,13 @@ const handleNotesArrowDown = () => {
if (editedNotes.some((note) => note.noteNumber < 0)) {
return;
}
void store.dispatch("COMMAND_UPDATE_NOTES", {
void store.actions.COMMAND_UPDATE_NOTES({
notes: editedNotes,
trackId: selectedTrackId.value,
});
if (editedNotes.length === 1) {
void store.dispatch("PLAY_PREVIEW_SOUND", {
void store.actions.PLAY_PREVIEW_SOUND({
noteNumber: editedNotes[0].noteNumber,
duration: PREVIEW_SOUND_DURATION,
});
Expand All @@ -1173,7 +1173,7 @@ const handleNotesArrowRight = () => {
// TODO: 例外処理は`UPDATE_NOTES`内に移す?
return;
}
void store.dispatch("COMMAND_UPDATE_NOTES", {
void store.actions.COMMAND_UPDATE_NOTES({
notes: editedNotes,
trackId: selectedTrackId.value,
});
Expand All @@ -1191,7 +1191,7 @@ const handleNotesArrowLeft = () => {
) {
return;
}
void store.dispatch("COMMAND_UPDATE_NOTES", {
void store.actions.COMMAND_UPDATE_NOTES({
notes: editedNotes,
trackId: selectedTrackId.value,
});
Expand All @@ -1202,7 +1202,7 @@ const handleNotesBackspaceOrDelete = () => {
// TODO: 例外処理は`COMMAND_REMOVE_SELECTED_NOTES`内に移す?
return;
}
void store.dispatch("COMMAND_REMOVE_SELECTED_NOTES");
void store.actions.COMMAND_REMOVE_SELECTED_NOTES();
};
const handleKeydown = (event: KeyboardEvent) => {
Expand Down Expand Up @@ -1230,7 +1230,7 @@ const handleKeydown = (event: KeyboardEvent) => {
handleNotesBackspaceOrDelete();
break;
case "Escape":
void store.dispatch("DESELECT_ALL_NOTES");
void store.actions.DESELECT_ALL_NOTES();
break;
}
};
Expand All @@ -1251,7 +1251,7 @@ const setZoomX = (value: number | null) => {
const scrollTop = sequencerBodyElement.scrollTop;
const clientWidth = sequencerBodyElement.clientWidth;
void store.dispatch("SET_ZOOM_X", { zoomX: newZoomX }).then(() => {
void store.actions.SET_ZOOM_X({ zoomX: newZoomX }).then(() => {
const centerBaseX = (scrollLeft + clientWidth / 2) / oldZoomX;
const newScrollLeft = centerBaseX * newZoomX - clientWidth / 2;
sequencerBodyElement.scrollTo(newScrollLeft, scrollTop);
Expand All @@ -1274,7 +1274,7 @@ const setZoomY = (value: number | null) => {
const scrollTop = sequencerBodyElement.scrollTop;
const clientHeight = sequencerBodyElement.clientHeight;
void store.dispatch("SET_ZOOM_Y", { zoomY: newZoomY }).then(() => {
void store.actions.SET_ZOOM_Y({ zoomY: newZoomY }).then(() => {
const centerBaseY = (scrollTop + clientHeight / 2) / oldZoomY;
const newScrollTop = centerBaseY * newZoomY - clientHeight / 2;
sequencerBodyElement.scrollTo(scrollLeft, newScrollTop);
Expand All @@ -1301,7 +1301,7 @@ const onWheel = (event: WheelEvent) => {
const scrollTop = sequencerBodyElement.scrollTop;
guideLineX.value = 0; // 補助線がはみ出さないように位置を一旦0にする
void store.dispatch("SET_ZOOM_X", { zoomX: newZoomX }).then(() => {
void store.actions.SET_ZOOM_X({ zoomX: newZoomX }).then(() => {
const cursorBaseX = (scrollLeft + cursorX.value) / oldZoomX;
const newScrollLeft = cursorBaseX * newZoomX - cursorX.value;
sequencerBodyElement.scrollTo(newScrollLeft, scrollTop);
Expand Down Expand Up @@ -1392,7 +1392,7 @@ onActivated(() => {
// リスナー登録
onActivated(() => {
void store.dispatch("ADD_PLAYHEAD_POSITION_CHANGE_LISTENER", {
void store.actions.ADD_PLAYHEAD_POSITION_CHANGE_LISTENER({
listener: playheadPositionChangeListener,
});
Expand All @@ -1403,7 +1403,7 @@ onActivated(() => {
// リスナー解除
onDeactivated(() => {
void store.dispatch("REMOVE_PLAYHEAD_POSITION_CHANGE_LISTENER", {
void store.actions.REMOVE_PLAYHEAD_POSITION_CHANGE_LISTENER({
listener: playheadPositionChangeListener,
});
Expand All @@ -1426,7 +1426,7 @@ registerHotkeyWithCleanup({
if (selectedNoteIds.value.size === 0) {
return;
}
void store.dispatch("COPY_NOTES_TO_CLIPBOARD");
void store.actions.COPY_NOTES_TO_CLIPBOARD();
},
});
Expand All @@ -1440,7 +1440,7 @@ registerHotkeyWithCleanup({
if (selectedNoteIds.value.size === 0) {
return;
}
void store.dispatch("COMMAND_CUT_NOTES_TO_CLIPBOARD");
void store.actions.COMMAND_CUT_NOTES_TO_CLIPBOARD();
},
});
Expand All @@ -1451,7 +1451,7 @@ registerHotkeyWithCleanup({
if (nowPreviewing.value) {
return;
}
void store.dispatch("COMMAND_PASTE_NOTES_FROM_CLIPBOARD");
void store.actions.COMMAND_PASTE_NOTES_FROM_CLIPBOARD();
},
});
Expand All @@ -1462,7 +1462,7 @@ registerHotkeyWithCleanup({
if (nowPreviewing.value) {
return;
}
void store.dispatch("SELECT_ALL_NOTES_IN_TRACK", {
void store.actions.SELECT_ALL_NOTES_IN_TRACK({
trackId: selectedTrackId.value,
});
},
Expand All @@ -1477,7 +1477,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "コピー",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("COPY_NOTES_TO_CLIPBOARD");
void store.actions.COPY_NOTES_TO_CLIPBOARD();
},
disabled: !isNoteSelected.value,
disableWhenUiLocked: true,
Expand All @@ -1487,7 +1487,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "切り取り",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("COMMAND_CUT_NOTES_TO_CLIPBOARD");
void store.actions.COMMAND_CUT_NOTES_TO_CLIPBOARD();
},
disabled: !isNoteSelected.value,
disableWhenUiLocked: true,
Expand All @@ -1497,7 +1497,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "貼り付け",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("COMMAND_PASTE_NOTES_FROM_CLIPBOARD");
void store.actions.COMMAND_PASTE_NOTES_FROM_CLIPBOARD();
},
disableWhenUiLocked: true,
},
Expand All @@ -1507,7 +1507,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "すべて選択",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("SELECT_ALL_NOTES_IN_TRACK", {
void store.actions.SELECT_ALL_NOTES_IN_TRACK({
trackId: selectedTrackId.value,
});
},
Expand All @@ -1518,7 +1518,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "選択解除",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("DESELECT_ALL_NOTES");
void store.actions.DESELECT_ALL_NOTES();
},
disabled: !isNoteSelected.value,
disableWhenUiLocked: true,
Expand All @@ -1529,7 +1529,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "クオンタイズ",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("COMMAND_QUANTIZE_SELECTED_NOTES");
void store.actions.COMMAND_QUANTIZE_SELECTED_NOTES();
},
disabled: !isNoteSelected.value,
disableWhenUiLocked: true,
Expand All @@ -1540,7 +1540,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
label: "削除",
onClick: () => {
contextMenu.value?.hide();
void store.dispatch("COMMAND_REMOVE_SELECTED_NOTES");
void store.actions.COMMAND_REMOVE_SELECTED_NOTES();
},
disabled: !isNoteSelected.value,
disableWhenUiLocked: true,
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sing/SequencerKeys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ let resizeObserver: ResizeObserver | undefined;
const onMouseDown = (noteNumber: number) => {
noteNumberOfKeyBeingPressed.value = noteNumber;
void store.dispatch("PLAY_PREVIEW_SOUND", { noteNumber });
void store.actions.PLAY_PREVIEW_SOUND({ noteNumber });
};
const onMouseUp = () => {
if (noteNumberOfKeyBeingPressed.value != undefined) {
const noteNumber = noteNumberOfKeyBeingPressed.value;
noteNumberOfKeyBeingPressed.value = undefined;
void store.dispatch("STOP_PREVIEW_SOUND", { noteNumber });
void store.actions.STOP_PREVIEW_SOUND({ noteNumber });
}
};
Expand All @@ -172,11 +172,11 @@ const onMouseEnter = (noteNumber: number) => {
noteNumberOfKeyBeingPressed.value != undefined &&
noteNumberOfKeyBeingPressed.value !== noteNumber
) {
void store.dispatch("STOP_PREVIEW_SOUND", {
void store.actions.STOP_PREVIEW_SOUND({
noteNumber: noteNumberOfKeyBeingPressed.value,
});
noteNumberOfKeyBeingPressed.value = noteNumber;
void store.dispatch("PLAY_PREVIEW_SOUND", { noteNumber });
void store.actions.PLAY_PREVIEW_SOUND({ noteNumber });
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sing/SequencerNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
disabled: props.nowPreviewing,
onClick: async () => {
contextMenu.value?.hide();
await store.dispatch("COPY_NOTES_TO_CLIPBOARD");
await store.actions.COPY_NOTES_TO_CLIPBOARD();
},
disableWhenUiLocked: true,
},
Expand All @@ -207,7 +207,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
disabled: props.nowPreviewing,
onClick: async () => {
contextMenu.value?.hide();
await store.dispatch("COMMAND_CUT_NOTES_TO_CLIPBOARD");
await store.actions.COMMAND_CUT_NOTES_TO_CLIPBOARD();
},
disableWhenUiLocked: true,
},
Expand All @@ -218,7 +218,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
disabled: props.nowPreviewing || !props.isSelected,
onClick: async () => {
contextMenu.value?.hide();
await store.dispatch("COMMAND_QUANTIZE_SELECTED_NOTES");
await store.actions.COMMAND_QUANTIZE_SELECTED_NOTES();
},
disableWhenUiLocked: true,
},
Expand All @@ -229,7 +229,7 @@ const contextMenuData = computed<ContextMenuItemData[]>(() => {
disabled: props.nowPreviewing || !props.isSelected,
onClick: async () => {
contextMenu.value?.hide();
await store.dispatch("COMMAND_REMOVE_SELECTED_NOTES");
await store.actions.COMMAND_REMOVE_SELECTED_NOTES();
},
disableWhenUiLocked: true,
},
Expand Down
Loading

0 comments on commit 9ba51de

Please sign in to comment.