mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
starting empty editor on map loading error
This commit is contained in:
parent
e3e209ff65
commit
e0f5d0238a
3 changed files with 16 additions and 6 deletions
|
@ -26,6 +26,7 @@ export class App extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.authInit();
|
this.authInit();
|
||||||
|
window.editor = this.editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapInit = () => {
|
mapInit = () => {
|
||||||
|
@ -41,7 +42,7 @@ export class App extends React.Component {
|
||||||
this.editor.stopEditing();
|
this.editor.stopEditing();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(this.hideLoader);
|
.catch(this.startEmptyEditor);
|
||||||
} else {
|
} else {
|
||||||
// this.hideLoader();
|
// this.hideLoader();
|
||||||
this.startEmptyEditor();
|
this.startEmptyEditor();
|
||||||
|
@ -50,9 +51,13 @@ export class App extends React.Component {
|
||||||
|
|
||||||
startEmptyEditor = () => {
|
startEmptyEditor = () => {
|
||||||
const { user } = this.state;
|
const { user } = this.state;
|
||||||
if (!user || !user.random_url) return;
|
if (!user || !user.random_url || !user.id) return;
|
||||||
|
|
||||||
replacePath(`/${user.random_url}/edit`);
|
replacePath(`/${user.random_url}/edit`);
|
||||||
|
|
||||||
|
this.editor.owner = user.id;
|
||||||
|
this.editor.startEditing();
|
||||||
|
|
||||||
this.hideLoader();
|
this.hideLoader();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class Editor {
|
||||||
setLogo,
|
setLogo,
|
||||||
}) {
|
}) {
|
||||||
this.logo = DEFAULT_LOGO;
|
this.logo = DEFAULT_LOGO;
|
||||||
|
this.owner = null;
|
||||||
this.map = new Map({ container });
|
this.map = new Map({ container });
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -166,9 +166,9 @@ export class Editor {
|
||||||
this.logo = logo;
|
this.logo = logo;
|
||||||
this.setLogo(logo);
|
this.setLogo(logo);
|
||||||
this.changeMode(MODES.NONE);
|
this.changeMode(MODES.NONE);
|
||||||
}
|
};
|
||||||
|
|
||||||
setData = ({ route, stickers, format = 'old' }) => {
|
setData = ({ route, stickers, format = 'old', owner }) => {
|
||||||
if (route) {
|
if (route) {
|
||||||
this.poly.setPoints(route);
|
this.poly.setPoints(route);
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,11 @@ export class Editor {
|
||||||
sticker: parseStickerStyle({ style, format }),
|
sticker: parseStickerStyle({ style, format }),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
this.map.map.fitBounds(this.poly.poly.getBounds());
|
this.map.map.fitBounds(this.poly.poly.getBounds());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,4 +31,4 @@ export const getStoredMap = ({ name }) => axios.get(API.GET_MAP, {
|
||||||
name,
|
name,
|
||||||
action: 'load'
|
action: 'load'
|
||||||
}
|
}
|
||||||
}).then(result => (result && result.data && result.data.data));
|
}).then(result => (result && result.data && result.data.data && result.data.owner && { ...result.data.data, owner: result.data.owner }));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue