mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Fix try page removing global variables.
This commit is contained in:
parent
935a529bf4
commit
a75962373c
@ -130,8 +130,8 @@ class CacheDecoratorClient implements Client {
|
||||
return this.client.revertHistory(id, cid);
|
||||
}
|
||||
|
||||
buildPersistenceManager(): PersistenceManager {
|
||||
return this.client.buildPersistenceManager();
|
||||
buildPersistenceManager(isTryMode: boolean): PersistenceManager {
|
||||
return this.client.buildPersistenceManager(isTryMode);
|
||||
}
|
||||
|
||||
removePersistenceManager(): void {
|
||||
|
@ -107,9 +107,9 @@ interface Client {
|
||||
fetchHistory(id: number): Promise<ChangeHistory[]>;
|
||||
revertHistory(id: number, cid: number): Promise<void>;
|
||||
|
||||
fetchMindmap(id:number): Mindmap;
|
||||
fetchMindmap(id: number): Mindmap;
|
||||
|
||||
buildPersistenceManager(): PersistenceManager;
|
||||
buildPersistenceManager(isTryMode: boolean): PersistenceManager;
|
||||
removePersistenceManager(): void;
|
||||
|
||||
onSessionExpired(callback?: () => void): () => void;
|
||||
|
@ -357,7 +357,7 @@ class MockClient implements Client {
|
||||
addLabelToMap(labelId: number, mapId: number): Promise<void> {
|
||||
const labelToAdd = this.labels.find((l) => l.id === labelId);
|
||||
if (!labelToAdd) {
|
||||
return Promise.reject({ msg: `unable to find label with id ${labelId}`});
|
||||
return Promise.reject({ msg: `unable to find label with id ${labelId}` });
|
||||
}
|
||||
const map = this.maps.find((m) => m.id === mapId);
|
||||
if (!map) {
|
||||
@ -400,7 +400,7 @@ class MockClient implements Client {
|
||||
}
|
||||
|
||||
buildPersistenceManager(): PersistenceManager {
|
||||
if (this.persistenceManager){
|
||||
if (this.persistenceManager) {
|
||||
return this.persistenceManager;
|
||||
}
|
||||
const persistence: PersistenceManager = new MockPersistenceManager(exampleMap);
|
||||
|
@ -40,7 +40,7 @@ export default class RestClient implements Client {
|
||||
this.axios.interceptors.response.use((r) => r, (r) => this.checkResponseForSessionExpired(r));
|
||||
}
|
||||
|
||||
private _onSessionExpired : () => void;
|
||||
private _onSessionExpired: () => void;
|
||||
onSessionExpired(callback?: () => void): () => void {
|
||||
if (callback) {
|
||||
this._onSessionExpired = callback;
|
||||
@ -611,13 +611,13 @@ export default class RestClient implements Client {
|
||||
}
|
||||
}
|
||||
|
||||
buildPersistenceManager(): PersistenceManager {
|
||||
if (this.persistenceManager){
|
||||
buildPersistenceManager(isTryMode: boolean): PersistenceManager {
|
||||
if (this.persistenceManager) {
|
||||
return this.persistenceManager;
|
||||
}
|
||||
// TODO: Move globals out, make urls configurable
|
||||
let persistence: PersistenceManager;
|
||||
if (!global.memoryPersistence && !global.readOnly) {
|
||||
if (!isTryMode) {
|
||||
persistence = new RESTPersistenceManager({
|
||||
documentUrl: '/c/restful/maps/{id}/document',
|
||||
revertUrl: '/c/restful/maps/{id}/history/latest',
|
||||
|
@ -24,7 +24,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => {
|
||||
|
||||
useEffect(() => {
|
||||
ReactGA.pageview(window.location.pathname + window.location.search);
|
||||
const persistence = client.buildPersistenceManager();
|
||||
const persistence = client.buildPersistenceManager(isTryMode);
|
||||
setPersistenceManager(persistence);
|
||||
return () => client.removePersistenceManager();
|
||||
}, []);
|
||||
|
Loading…
Reference in New Issue
Block a user