Fix try page removing global variables.

This commit is contained in:
Paulo Gustavo Veiga 2022-02-22 15:54:57 -08:00
parent 935a529bf4
commit a75962373c
5 changed files with 21 additions and 21 deletions

View File

@ -130,8 +130,8 @@ class CacheDecoratorClient implements Client {
return this.client.revertHistory(id, cid); return this.client.revertHistory(id, cid);
} }
buildPersistenceManager(): PersistenceManager { buildPersistenceManager(isTryMode: boolean): PersistenceManager {
return this.client.buildPersistenceManager(); return this.client.buildPersistenceManager(isTryMode);
} }
removePersistenceManager(): void { removePersistenceManager(): void {

View File

@ -109,7 +109,7 @@ interface Client {
fetchMindmap(id: number): Mindmap; fetchMindmap(id: number): Mindmap;
buildPersistenceManager(): PersistenceManager; buildPersistenceManager(isTryMode: boolean): PersistenceManager;
removePersistenceManager(): void; removePersistenceManager(): void;
onSessionExpired(callback?: () => void): () => void; onSessionExpired(callback?: () => void): () => void;

View File

@ -611,13 +611,13 @@ export default class RestClient implements Client {
} }
} }
buildPersistenceManager(): PersistenceManager { buildPersistenceManager(isTryMode: boolean): PersistenceManager {
if (this.persistenceManager) { if (this.persistenceManager) {
return this.persistenceManager; return this.persistenceManager;
} }
// TODO: Move globals out, make urls configurable // TODO: Move globals out, make urls configurable
let persistence: PersistenceManager; let persistence: PersistenceManager;
if (!global.memoryPersistence && !global.readOnly) { if (!isTryMode) {
persistence = new RESTPersistenceManager({ persistence = new RESTPersistenceManager({
documentUrl: '/c/restful/maps/{id}/document', documentUrl: '/c/restful/maps/{id}/document',
revertUrl: '/c/restful/maps/{id}/history/latest', revertUrl: '/c/restful/maps/{id}/history/latest',

View File

@ -24,7 +24,7 @@ const EditorPage = ({ isTryMode }: EditorPropsType): React.ReactElement => {
useEffect(() => { useEffect(() => {
ReactGA.pageview(window.location.pathname + window.location.search); ReactGA.pageview(window.location.pathname + window.location.search);
const persistence = client.buildPersistenceManager(); const persistence = client.buildPersistenceManager(isTryMode);
setPersistenceManager(persistence); setPersistenceManager(persistence);
return () => client.removePersistenceManager(); return () => client.removePersistenceManager();
}, []); }, []);