(
action: (
context: DotNotationActionContext<
S,
S,
AllGetters,
AllActions,
AllMutations
>,
payload: Parameters<A[K]>[0],
) => ReturnType<A[K]> extends Promise<unknown>
? ReturnType<A[K]>
: Promise<ReturnType<A[K]>>,
)
| 30 | import { objectEntries } from "@/helpers/typedEntries"; |
| 31 | |
| 32 | export function createUILockAction<S, A extends ActionsBase, K extends keyof A>( |
| 33 | action: ( |
| 34 | context: DotNotationActionContext< |
| 35 | S, |
| 36 | S, |
| 37 | AllGetters, |
| 38 | AllActions, |
| 39 | AllMutations |
| 40 | >, |
| 41 | payload: Parameters<A[K]>[0], |
| 42 | ) => ReturnType<A[K]> extends Promise<unknown> |
| 43 | ? ReturnType<A[K]> |
| 44 | : Promise<ReturnType<A[K]>>, |
| 45 | ): DotNotationAction<S, S, A, K, AllGetters, AllActions, AllMutations> { |
| 46 | return (context, payload: Parameters<A[K]>[0]) => { |
| 47 | context.mutations.LOCK_UI(); |
| 48 | // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call |
| 49 | return action(context, payload).finally(() => { |
| 50 | context.mutations.UNLOCK_UI(); |
| 51 | }); |
| 52 | }; |
| 53 | } |
| 54 | |
| 55 | export function withProgress<T>( |
| 56 | action: Promise<T>, |
no test coverage detected