Skip to content

Commit

Permalink
rename createDotNotationUILockAction to createUILockAction
Browse files Browse the repository at this point in the history
  • Loading branch information
Segu-g committed Oct 26, 2024
1 parent 23e8971 commit 29b7ca2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 46 deletions.
5 changes: 1 addition & 4 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import path from "path";
import Encoding from "encoding-japanese";
import {
createDotNotationUILockAction as createUILockAction,
withProgress,
} from "./ui";
import { createUILockAction, withProgress } from "./ui";
import {
AudioItem,
SaveResultObject,
Expand Down
2 changes: 1 addition & 1 deletion src/store/engine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EngineState, EngineStoreState, EngineStoreTypes } from "./type";
import { createDotNotationUILockAction as createUILockAction } from "./ui";
import { createUILockAction } from "./ui";
import { createPartialStore } from "./vuex";
import { createLogger } from "@/domain/frontend/log";
import type { EngineManifest } from "@/openapi";
Expand Down
2 changes: 1 addition & 1 deletion src/store/project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getBaseName } from "./utility";
import { createPartialStore, DotNotationDispatch } from "./vuex";
import { createDotNotationUILockAction as createUILockAction } from "@/store/ui";
import { createUILockAction } from "@/store/ui";
import {
AllActions,
AudioItem,
Expand Down
2 changes: 1 addition & 1 deletion src/store/setting.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SettingStoreState, SettingStoreTypes } from "./type";
import { createDotNotationUILockAction as createUILockAction } from "./ui";
import { createUILockAction } from "./ui";
import { createPartialStore } from "./vuex";
import { themes } from "@/domain/theme";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/store/singing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import { toRaw } from "vue";
import { createPartialStore } from "./vuex";
import { createDotNotationUILockAction as createUILockAction } from "./ui";
import { createUILockAction } from "./ui";
import {
Tempo,
TimeSignature,
Expand Down
49 changes: 11 additions & 38 deletions src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ import {
} from "@/components/Dialog/Dialog";

export function createUILockAction<S, A extends ActionsBase, K extends keyof A>(
action: (
context: ActionContext<S, S, AllGetters, AllActions, AllMutations>,
payload: Parameters<A[K]>[0],
) => ReturnType<A[K]> extends Promise<unknown>
? ReturnType<A[K]>
: Promise<ReturnType<A[K]>>,
): Action<S, S, A, K, AllGetters, AllActions, AllMutations> {
return (context, payload: Parameters<A[K]>[0]) => {
context.commit("LOCK_UI");
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
return action(context, payload).finally(() => {
context.commit("UNLOCK_UI");
});
};
}

export function createDotNotationUILockAction<
S,
A extends ActionsBase,
K extends keyof A,
>(
action: (
context: DotNotationActionContext<
S,
Expand Down Expand Up @@ -141,7 +120,7 @@ export const uiStore = createPartialStore<UiStoreTypes>({
},

ASYNC_UI_LOCK: {
action: createDotNotationUILockAction(
action: createUILockAction(
async (_, { callback }: { callback: () => Promise<void> }) => {
await callback();
},
Expand Down Expand Up @@ -236,27 +215,21 @@ export const uiStore = createPartialStore<UiStoreTypes>({
},

SHOW_ALERT_DIALOG: {
action: createDotNotationUILockAction(
async (_, payload: AlertDialogOptions) => {
return await showAlertDialog(payload);
},
),
action: createUILockAction(async (_, payload: AlertDialogOptions) => {
return await showAlertDialog(payload);
}),
},

SHOW_CONFIRM_DIALOG: {
action: createDotNotationUILockAction(
async (_, payload: ConfirmDialogOptions) => {
return await showConfirmDialog(payload);
},
),
action: createUILockAction(async (_, payload: ConfirmDialogOptions) => {
return await showConfirmDialog(payload);
}),
},

SHOW_WARNING_DIALOG: {
action: createDotNotationUILockAction(
async (_, payload: WarningDialogOptions) => {
return await showWarningDialog(payload);
},
),
action: createUILockAction(async (_, payload: WarningDialogOptions) => {
return await showWarningDialog(payload);
}),
},

SHOW_NOTIFY_AND_NOT_SHOW_AGAIN_BUTTON: {
Expand Down Expand Up @@ -463,7 +436,7 @@ export const uiStore = createPartialStore<UiStoreTypes>({
},

RELOAD_APP: {
action: createDotNotationUILockAction(
action: createUILockAction(
async (
{ actions },
{ isMultiEngineOffMode }: { isMultiEngineOffMode?: boolean },
Expand Down

0 comments on commit 29b7ca2

Please sign in to comment.