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 = {
*/
export class Editor extends React.PureComponent<any, stateTypes> {
private rendererRef: React.RefObject<GraphRenderer2D>;
private defaultSpaceId = "Graph";
constructor(props: any) {
super(props);
......@@ -112,8 +111,6 @@ export class Editor extends React.PureComponent<any, stateTypes> {
this.rendererRef = React.createRef();
this.loadListOfSpaces();
// Set as new state
this.state = {
graph: undefined,
......@@ -145,12 +142,17 @@ export class Editor extends React.PureComponent<any, stateTypes> {
* Tries to load initial graph after webpage finished loading.
*/
componentDidMount() {
// Try to load given spaceId from Config
// If not available, just load default space
const initialSpaceId = this.state.spaceId
? this.state.spaceId
: this.defaultSpaceId;
this.loadSpace(initialSpaceId);
// Get list of all available spaces and pick initial space based on that
this.loadListOfSpaces().then(
(spaces: string[]) => {
// Try to load first element in list of available spaces
// If not available, just load default space
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