Skip to content
Snippets Groups Projects
Commit fd59dc0d authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Improved loading of intial space to be more useful

parent d8ea36af
No related branches found
No related tags found
No related merge requests found
Pipeline #57031 passed
...@@ -70,7 +70,6 @@ type stateTypes = { ...@@ -70,7 +70,6 @@ type stateTypes = {
*/ */
export class Editor extends React.PureComponent<any, stateTypes> { export class Editor extends React.PureComponent<any, stateTypes> {
private rendererRef: React.RefObject<GraphRenderer2D>; private rendererRef: React.RefObject<GraphRenderer2D>;
private defaultSpaceId = "Graph";
constructor(props: any) { constructor(props: any) {
super(props); super(props);
...@@ -112,8 +111,6 @@ export class Editor extends React.PureComponent<any, stateTypes> { ...@@ -112,8 +111,6 @@ export class Editor extends React.PureComponent<any, stateTypes> {
this.rendererRef = React.createRef(); this.rendererRef = React.createRef();
this.loadListOfSpaces();
// Set as new state // Set as new state
this.state = { this.state = {
graph: undefined, graph: undefined,
...@@ -145,12 +142,17 @@ export class Editor extends React.PureComponent<any, stateTypes> { ...@@ -145,12 +142,17 @@ export class Editor extends React.PureComponent<any, stateTypes> {
* Tries to load initial graph after webpage finished loading. * Tries to load initial graph after webpage finished loading.
*/ */
componentDidMount() { componentDidMount() {
// Try to load given spaceId from Config // Get list of all available spaces and pick initial space based on that
// If not available, just load default space this.loadListOfSpaces().then(
const initialSpaceId = this.state.spaceId (spaces: string[]) => {
? this.state.spaceId // Try to load first element in list of available spaces
: this.defaultSpaceId; // If not available, just load default space
this.loadSpace(initialSpaceId); const initialSpaceId =
spaces.length > 0 ? spaces[0] : this.state.spaceId;
this.loadSpace(initialSpaceId);
},
() => this.loadSpace(this.state.spaceId)
);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment