Skip to content

Commit

Permalink
use unref instead of value to simplify testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronicBlueberry committed Nov 6, 2023
1 parent f7a4c04 commit 4e63bbf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions client/src/composables/workflowStores.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inject, onScopeDispose, provide, type Ref, ref } from "vue";
import { inject, onScopeDispose, provide, type Ref, ref, unref } from "vue";

import { useConnectionStore } from "@/stores/workflowConnectionStore";
import { useWorkflowCommentStore } from "@/stores/workflowEditorCommentStore";
Expand Down Expand Up @@ -55,19 +55,20 @@ export function provideScopedWorkflowStores(workflowId: Ref<string> | string) {
* @returns workflow stores
*/
export function useWorkflowStores() {
const workflowId = inject("workflowId") as Ref<string>;
const workflowId = inject("workflowId") as Ref<string> | string;
const id = unref(workflowId);

if (typeof workflowId?.value !== "string") {
if (typeof id !== "string") {
throw new Error(
"Workflow ID not provided by parent component. Use `provideScopedWorkflowStores` on a parent component."
);
}

const connectionStore = useConnectionStore(workflowId.value);
const stateStore = useWorkflowStateStore(workflowId.value);
const stepStore = useWorkflowStepStore(workflowId.value);
const commentStore = useWorkflowCommentStore(workflowId.value);
const toolbarStore = useWorkflowEditorToolbarStore(workflowId.value);
const connectionStore = useConnectionStore(id);
const stateStore = useWorkflowStateStore(id);
const stepStore = useWorkflowStepStore(id);
const commentStore = useWorkflowCommentStore(id);
const toolbarStore = useWorkflowEditorToolbarStore(id);

return {
connectionStore,
Expand Down

0 comments on commit 4e63bbf

Please sign in to comment.