mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
import: added hash to url translation for old maps support
editor: fixed setProvider
This commit is contained in:
parent
7bf737b62b
commit
d95f51bd3b
3 changed files with 28 additions and 10 deletions
|
@ -10,10 +10,13 @@ import { getUrlData } from '$utils/history';
|
||||||
import { store } from '$redux/store';
|
import { store } from '$redux/store';
|
||||||
import {
|
import {
|
||||||
resetSaveDialog,
|
resetSaveDialog,
|
||||||
setActiveSticker, setAddress,
|
setActiveSticker,
|
||||||
|
setAddress,
|
||||||
setChanged,
|
setChanged,
|
||||||
setDistance, setLogo,
|
setDistance,
|
||||||
|
setLogo,
|
||||||
setMode,
|
setMode,
|
||||||
|
setProvider,
|
||||||
setRouterPoints,
|
setRouterPoints,
|
||||||
setTitle,
|
setTitle,
|
||||||
} from '$redux/user/actions';
|
} from '$redux/user/actions';
|
||||||
|
@ -325,12 +328,14 @@ export class Editor {
|
||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
});
|
});
|
||||||
|
|
||||||
setProvider = provider => {
|
// setProvider = provider => {
|
||||||
if (provider === this.provider) return;
|
// if (provider === this.provider) return;
|
||||||
|
//
|
||||||
|
// this.provider = provider;
|
||||||
|
// this.map.setProvider(provider);
|
||||||
|
// };
|
||||||
|
|
||||||
this.provider = provider;
|
setProvider = provider => store.dispatch(setProvider(provider));
|
||||||
this.map.setProvider(provider);
|
|
||||||
};
|
|
||||||
|
|
||||||
get isEmpty() {
|
get isEmpty() {
|
||||||
const { route, stickers } = this.dumpData();
|
const { route, stickers } = this.dumpData();
|
||||||
|
|
|
@ -102,8 +102,19 @@ function* loadMapSaga(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function* mapInitSaga() {
|
function* mapInitSaga() {
|
||||||
|
const { hash } = getUrlData();
|
||||||
|
|
||||||
|
if (hash && /^#map/.test(hash)) {
|
||||||
|
const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);
|
||||||
|
|
||||||
|
if (newUrl) {
|
||||||
|
yield pushPath(`/${newUrl}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const { path, mode } = getUrlData();
|
const { path, mode } = getUrlData();
|
||||||
|
|
||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
const map = yield call(loadMapSaga, path);
|
const map = yield call(loadMapSaga, path);
|
||||||
// const map = yield call(getStoredMap, { name: path });
|
// const map = yield call(getStoredMap, { name: path });
|
||||||
|
@ -326,7 +337,9 @@ function* cropAShotSaga(params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProviderSaga({ provider }) {
|
function setProviderSaga({ provider }) {
|
||||||
editor.setProvider(provider);
|
// editor.setProvider(provider);
|
||||||
|
editor.provider = provider;
|
||||||
|
editor.map.setProvider(provider);
|
||||||
|
|
||||||
return put(setMode(MODES.NONE));
|
return put(setMode(MODES.NONE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const pushPath = url => {
|
||||||
|
|
||||||
export const getUrlData = (url = getPath()) => {
|
export const getUrlData = (url = getPath()) => {
|
||||||
const [, path, mode] = url.split('/');
|
const [, path, mode] = url.split('/');
|
||||||
const { host } = window.location;
|
const { host, hash } = window.location;
|
||||||
|
|
||||||
return { path, mode, host };
|
return { path, mode, host, hash };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue