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:
+10
-6
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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 },
|
||||
|
||||
|
||||
Reference in New Issue
Block a user