From 188156dd0bbadce65fb8fad125544b2f9a9007d7 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 24 Mar 2022 20:44:43 +0100 Subject: [PATCH] fix(store): setting store state after init --- src/composables/useVueFlow.ts | 4 +++- src/container/VueFlow/watch.ts | 2 +- src/store/actions.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/composables/useVueFlow.ts b/src/composables/useVueFlow.ts index e874d2a0..b8fd6b48 100644 --- a/src/composables/useVueFlow.ts +++ b/src/composables/useVueFlow.ts @@ -66,8 +66,10 @@ export default (options?: Partial>): UseVueFlo onScopeDispose(() => { storage.remove(name) }) + } else { + if (options) vueFlow.setState(options) } - if (!vueFlow) throw new Error('VueFlow instance not found.') + if (!vueFlow) throw new Error('vue flow store instance not found.') return vueFlow } diff --git a/src/container/VueFlow/watch.ts b/src/container/VueFlow/watch.ts index e2b4b7cd..04276415 100644 --- a/src/container/VueFlow/watch.ts +++ b/src/container/VueFlow/watch.ts @@ -64,7 +64,7 @@ export default ( const skip = ['modelValue', 'edges', 'nodes', 'maxZoom', 'minZoom'] Object.keys(props).forEach((p) => { - if (!skip.indexOf(p)) { + if (!skip.includes(p)) { const prop = props[p as keyof typeof props] watch( () => prop, diff --git a/src/store/actions.ts b/src/store/actions.ts index ba3717d4..ea579345 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -292,7 +292,7 @@ export default (state: State, getters: ComputedGetters): Actions => { if (typeof opts.edges !== 'undefined') setEdges(opts.edges) Object.keys(opts).forEach((o) => { const option = opts[o as keyof typeof opts] - if (!skip.indexOf(o) && isDef(option)) (state)[o] = option + if (!skip.includes(o) && isDef(option)) (state)[o] = option }) if (!state.paneReady) until(() => state.d3Zoom)