update(store): remove promise from setState

* add default values for nodeTypes/edgeTypes - empty array for customs

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-25 15:21:36 +01:00
parent fd83a6d365
commit 233e915376
3 changed files with 13 additions and 7 deletions
+10 -6
View File
@@ -178,7 +178,7 @@ export default (id: string, preloadedState: FlowState) => {
const { nodes, edges } = parseElements(elements, this.elements, this.nodeExtent)
this.elements = [...this.elements, ...nodes, ...edges]
},
async setState(state) {
setState(state) {
if (typeof state.panOnScroll !== 'undefined') this.panOnScroll = state.panOnScroll
if (typeof state.panOnScrollMode !== 'undefined') this.panOnScrollMode = state.panOnScrollMode
if (typeof state.panOnScrollSpeed !== 'undefined') this.panOnScrollSpeed = state.panOnScrollSpeed
@@ -206,11 +206,15 @@ export default (id: string, preloadedState: FlowState) => {
if (typeof state.multiSelectionKeyCode !== 'undefined') this.multiSelectionKeyCode = state.multiSelectionKeyCode
if (typeof state.snapToGrid !== 'undefined') this.snapToGrid = state.snapToGrid
if (typeof state.snapGrid !== 'undefined') this.snapGrid = state.snapGrid
if (typeof !this.isReady) await until(() => this.d3Zoom).not.toBeUndefined()
if (typeof state.maxZoom !== 'undefined') this.setMaxZoom(state.maxZoom)
if (typeof state.minZoom !== 'undefined') this.setMinZoom(state.minZoom)
if (typeof state.translateExtent !== 'undefined') this.setTranslateExtent(state.translateExtent)
if (typeof state.nodeExtent !== 'undefined') this.setNodeExtent(state.nodeExtent)
if (typeof !this.isReady)
until(() => this.d3Zoom)
.not.toBeUndefined()
.then(() => {
if (typeof state.maxZoom !== 'undefined') this.setMaxZoom(state.maxZoom)
if (typeof state.minZoom !== 'undefined') this.setMinZoom(state.minZoom)
if (typeof state.translateExtent !== 'undefined') this.setTranslateExtent(state.translateExtent)
if (typeof state.nodeExtent !== 'undefined') this.setNodeExtent(state.nodeExtent)
})
},
},
})
+1 -1
View File
@@ -89,7 +89,7 @@ export interface FlowActions {
setConnectionNodeId: (payload: SetConnectionId) => void
setInteractive: (isInteractive: boolean) => void
addElements: (elements: Elements) => void
setState: (state: FlowOptions) => Promise<void>
setState: (state: FlowOptions) => void
}
export interface FlowGetters {
+2
View File
@@ -22,6 +22,8 @@ export const initialState = (): FlowState => ({
},
transform: [0, 0, 1],
elements: [],
nodeTypes: [],
edgeTypes: [],
selectedElements: undefined,
selectedNodesBbox: { x: 0, y: 0, width: 0, height: 0 },