Skip to content

Commit

Permalink
vuexのstoreの呼び出しをリテラル引数からDot記法へ: components/Dialog (#2328)
Browse files Browse the repository at this point in the history
  • Loading branch information
Segu-g authored Oct 28, 2024
1 parent ffc315c commit da93c23
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const modelValueComputed = computed({
});
const handler = (acceptRetrieveTelemetry: boolean) => {
void store.dispatch("SET_ACCEPT_RETRIEVE_TELEMETRY", {
void store.actions.SET_ACCEPT_RETRIEVE_TELEMETRY({
acceptRetrieveTelemetry: acceptRetrieveTelemetry ? "Accepted" : "Refused",
});
Expand All @@ -48,6 +48,6 @@ const handler = (acceptRetrieveTelemetry: boolean) => {
const privacyPolicy = ref("");
onMounted(async () => {
privacyPolicy.value = await store.dispatch("GET_PRIVACY_POLICY_TEXT");
privacyPolicy.value = await store.actions.GET_PRIVACY_POLICY_TEXT();
});
</script>
6 changes: 3 additions & 3 deletions src/components/Dialog/AcceptDialog/AcceptTermsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const modelValueComputed = computed({
});
const handler = (acceptTerms: boolean) => {
void store.dispatch("SET_ACCEPT_TERMS", {
void store.actions.SET_ACCEPT_TERMS({
acceptTerms: acceptTerms ? "Accepted" : "Rejected",
});
if (acceptTerms) {
void store.dispatch("CHECK_EDITED_AND_NOT_SAVE", {
void store.actions.CHECK_EDITED_AND_NOT_SAVE({
closeOrReload: "close",
});
}
Expand All @@ -49,6 +49,6 @@ const handler = (acceptTerms: boolean) => {
const terms = ref("");
onMounted(async () => {
terms.value = await store.dispatch("GET_POLICY_TEXT");
terms.value = await store.actions.GET_POLICY_TEXT();
});
</script>
24 changes: 12 additions & 12 deletions src/components/Dialog/AllDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ const store = useStore();
// ライセンス表示
const isHelpDialogOpenComputed = computed({
get: () => store.state.isHelpDialogOpen,
set: (val) => store.dispatch("SET_DIALOG_OPEN", { isHelpDialogOpen: val }),
set: (val) => store.actions.SET_DIALOG_OPEN({ isHelpDialogOpen: val }),
});
// 設定
const isSettingDialogOpenComputed = computed({
get: () => store.state.isSettingDialogOpen,
set: (val) => store.dispatch("SET_DIALOG_OPEN", { isSettingDialogOpen: val }),
set: (val) => store.actions.SET_DIALOG_OPEN({ isSettingDialogOpen: val }),
});
// ショートカットキー設定
const isHotkeySettingDialogOpenComputed = computed({
get: () => store.state.isHotkeySettingDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isHotkeySettingDialogOpen: val,
}),
});
Expand All @@ -74,7 +74,7 @@ const isHotkeySettingDialogOpenComputed = computed({
const isToolbarSettingDialogOpenComputed = computed({
get: () => store.state.isToolbarSettingDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isToolbarSettingDialogOpen: val,
}),
});
Expand All @@ -83,7 +83,7 @@ const isToolbarSettingDialogOpenComputed = computed({
const isAcceptTermsDialogOpenComputed = computed({
get: () => store.state.isAcceptTermsDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isAcceptTermsDialogOpen: val,
}),
});
Expand All @@ -97,7 +97,7 @@ const isCharacterOrderDialogOpenComputed = computed({
!store.state.isAcceptTermsDialogOpen &&
store.state.isCharacterOrderDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isCharacterOrderDialogOpen: val,
}),
});
Expand All @@ -115,7 +115,7 @@ const isDefaultStyleSelectDialogOpenComputed = computed({
!store.state.isCharacterOrderDialogOpen &&
store.state.isDefaultStyleSelectDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isDefaultStyleSelectDialogOpen: val,
}),
});
Expand All @@ -124,7 +124,7 @@ const isDefaultStyleSelectDialogOpenComputed = computed({
const isEngineManageDialogOpenComputed = computed({
get: () => store.state.isEngineManageDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isEngineManageDialogOpen: val,
}),
});
Expand All @@ -133,7 +133,7 @@ const isEngineManageDialogOpenComputed = computed({
const isDictionaryManageDialogOpenComputed = computed({
get: () => store.state.isDictionaryManageDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isDictionaryManageDialogOpen: val,
}),
});
Expand All @@ -145,7 +145,7 @@ const isAcceptRetrieveTelemetryDialogOpenComputed = computed({
!store.state.isDefaultStyleSelectDialogOpen &&
store.state.isAcceptRetrieveTelemetryDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isAcceptRetrieveTelemetryDialogOpen: val,
}),
});
Expand All @@ -165,7 +165,7 @@ const canOpenNotificationDialog = computed(() => {
const isExportSongAudioDialogOpen = computed({
get: () => store.state.isExportSongAudioDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isExportSongAudioDialogOpen: val,
}),
});
Expand All @@ -174,7 +174,7 @@ const isExportSongAudioDialogOpen = computed({
const isImportSongProjectDialogOpenComputed = computed({
get: () => store.state.isImportSongProjectDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
store.actions.SET_DIALOG_OPEN({
isImportSongProjectDialogOpen: val,
}),
});
Expand Down
5 changes: 2 additions & 3 deletions src/components/Dialog/CharacterOrderDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ watch(
async (newValue, oldValue) => {
if (!oldValue && newValue) {
// 新しいキャラクター
newCharacters.value = await store.dispatch("GET_NEW_CHARACTERS");
newCharacters.value = await store.actions.GET_NEW_CHARACTERS();
// サンプルの順番、新しいキャラクターは上に
sampleCharacterOrder.value = [
Expand Down Expand Up @@ -256,8 +256,7 @@ const togglePlayOrStop = (
const characterOrderDragging = ref(false);
const closeDialog = () => {
void store.dispatch(
"SET_USER_CHARACTER_ORDER",
void store.actions.SET_USER_CHARACTER_ORDER(
characterOrder.value.map((info) => info.metas.speakerUuid),
);
stop();
Expand Down
3 changes: 1 addition & 2 deletions src/components/Dialog/DefaultStyleListDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ watch([() => props.modelValue], async ([newValue]) => {
const isHoverableItem = ref(true);
const closeDialog = () => {
void store.dispatch(
"SET_DEFAULT_STYLE_IDS",
void store.actions.SET_DEFAULT_STYLE_IDS(
Object.entries(selectedStyleIndexes.value).map(
([speakerUuidStr, styleIndex]) => {
const speakerUuid = SpeakerId(speakerUuidStr);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DefaultStyleSelectDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const closeDialog = () => {
const defaultStyleIds = JSON.parse(
JSON.stringify(store.state.defaultStyleIds),
) as DefaultStyleId[];
void store.dispatch("SET_DEFAULT_STYLE_IDS", [
void store.actions.SET_DEFAULT_STYLE_IDS([
...defaultStyleIds.filter(
(defaultStyleId) =>
defaultStyleId.speakerUuid !== props.characterInfo.metas.speakerUuid,
Expand Down
40 changes: 20 additions & 20 deletions src/components/Dialog/DictionaryManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ const loadingDictProcess = async () => {
loadingDictState.value = "loading";
try {
userDict.value = await createUILockAction(
store.dispatch("LOAD_ALL_USER_DICT"),
store.actions.LOAD_ALL_USER_DICT(),
);
} catch {
const result = await store.dispatch("SHOW_ALERT_DIALOG", {
const result = await store.actions.SHOW_ALERT_DIALOG({
title: "辞書の取得に失敗しました",
message: "エンジンの再起動をお試しください。",
});
Expand All @@ -352,9 +352,9 @@ const loadingDictProcess = async () => {
}
loadingDictState.value = "synchronizing";
try {
await createUILockAction(store.dispatch("SYNC_ALL_USER_DICT"));
await createUILockAction(store.actions.SYNC_ALL_USER_DICT());
} catch {
await store.dispatch("SHOW_ALERT_DIALOG", {
await store.actions.SHOW_ALERT_DIALOG({
title: "辞書の同期に失敗しました",
message: "エンジンの再起動をお試しください。",
});
Expand Down Expand Up @@ -441,7 +441,7 @@ const setYomi = async (text: string, changeWord?: boolean) => {
text = convertLongVowel(text);
accentPhrase.value = (
await createUILockAction(
store.dispatch("FETCH_ACCENT_PHRASES", {
store.actions.FETCH_ACCENT_PHRASES({
text: text + "ガ'",
engineId,
styleId,
Expand All @@ -465,7 +465,7 @@ const changeAccent = async (_: number, accent: number) => {
accentPhrase.value.accent = accent;
accentPhrase.value = (
await createUILockAction(
store.dispatch("FETCH_MORA_DATA", {
store.actions.FETCH_MORA_DATA({
accentPhrases: [accentPhrase.value],
engineId,
styleId,
Expand All @@ -479,7 +479,7 @@ const play = async () => {
if (!accentPhrase.value) return;
nowGenerating.value = true;
const audioItem = await store.dispatch("GENERATE_AUDIO_ITEM", {
const audioItem = await store.actions.GENERATE_AUDIO_ITEM({
text: yomi.value,
voice: voiceComputed.value,
});
Expand All @@ -491,13 +491,13 @@ const play = async () => {
let fetchAudioResult: FetchAudioResult;
try {
fetchAudioResult = await store.dispatch("FETCH_AUDIO_FROM_AUDIO_ITEM", {
fetchAudioResult = await store.actions.FETCH_AUDIO_FROM_AUDIO_ITEM({
audioItem,
});
} catch (e) {
window.backend.logError(e);
nowGenerating.value = false;
void store.dispatch("SHOW_ALERT_DIALOG", {
void store.actions.SHOW_ALERT_DIALOG({
title: "生成に失敗しました",
message: "エンジンの再起動をお試しください。",
});
Expand All @@ -507,11 +507,11 @@ const play = async () => {
const { blob } = fetchAudioResult;
nowGenerating.value = false;
nowPlaying.value = true;
await store.dispatch("PLAY_AUDIO_BLOB", { audioBlob: blob });
await store.actions.PLAY_AUDIO_BLOB({ audioBlob: blob });
nowPlaying.value = false;
};
const stop = () => {
void store.dispatch("STOP_AUDIO");
void store.actions.STOP_AUDIO();
};
// accent phraseにあるaccentと実際に登録するアクセントには差が生まれる
Expand Down Expand Up @@ -562,15 +562,15 @@ const saveWord = async () => {
const accent = computeRegisteredAccent();
if (selectedId.value) {
try {
await store.dispatch("REWRITE_WORD", {
await store.actions.REWRITE_WORD({
wordUuid: selectedId.value,
surface: surface.value,
pronunciation: yomi.value,
accentType: accent,
priority: wordPriority.value,
});
} catch {
void store.dispatch("SHOW_ALERT_DIALOG", {
void store.actions.SHOW_ALERT_DIALOG({
title: "単語の更新に失敗しました",
message: "エンジンの再起動をお試しください。",
});
Expand All @@ -579,15 +579,15 @@ const saveWord = async () => {
} else {
try {
await createUILockAction(
store.dispatch("ADD_WORD", {
store.actions.ADD_WORD({
surface: surface.value,
pronunciation: yomi.value,
accentType: accent,
priority: wordPriority.value,
}),
);
} catch {
void store.dispatch("SHOW_ALERT_DIALOG", {
void store.actions.SHOW_ALERT_DIALOG({
title: "単語の登録に失敗しました",
message: "エンジンの再起動をお試しください。",
});
Expand All @@ -598,20 +598,20 @@ const saveWord = async () => {
toInitialState();
};
const deleteWord = async () => {
const result = await store.dispatch("SHOW_WARNING_DIALOG", {
const result = await store.actions.SHOW_WARNING_DIALOG({
title: "登録された単語を削除しますか?",
message: "削除された単語は元に戻せません。",
actionName: "削除",
});
if (result === "OK") {
try {
await createUILockAction(
store.dispatch("DELETE_WORD", {
store.actions.DELETE_WORD({
wordUuid: selectedId.value,
}),
);
} catch {
void store.dispatch("SHOW_ALERT_DIALOG", {
void store.actions.SHOW_ALERT_DIALOG({
title: "単語の削除に失敗しました",
message: "エンジンの再起動をお試しください。",
});
Expand All @@ -622,7 +622,7 @@ const deleteWord = async () => {
}
};
const resetWord = async (id: string) => {
const result = await store.dispatch("SHOW_WARNING_DIALOG", {
const result = await store.actions.SHOW_WARNING_DIALOG({
title: "単語の変更をリセットしますか?",
message: "単語の変更は破棄されてリセットされます。",
actionName: "リセット",
Expand All @@ -637,7 +637,7 @@ const resetWord = async (id: string) => {
};
const discardOrNotDialog = async (okCallback: () => void) => {
if (isWordChanged.value) {
const result = await store.dispatch("SHOW_WARNING_DIALOG", {
const result = await store.actions.SHOW_WARNING_DIALOG({
title: "単語の追加・変更を破棄しますか?",
message: "破棄すると、単語の追加・変更はリセットされます。",
actionName: "破棄",
Expand Down
Loading

0 comments on commit da93c23

Please sign in to comment.