From eb12d6cc9400b2fb536e097feac58c050ae669b4 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 21 Nov 2022 19:37:16 -0800 Subject: [PATCH] Fix export in mindmap list. --- .../src/components/editor-page/PersistenceManagerUtils.ts | 6 +++--- .../maps-page/action-dispatcher/export-dialog/index.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/webapp/src/components/editor-page/PersistenceManagerUtils.ts b/packages/webapp/src/components/editor-page/PersistenceManagerUtils.ts index c8e7cb27..ee2fc406 100644 --- a/packages/webapp/src/components/editor-page/PersistenceManagerUtils.ts +++ b/packages/webapp/src/components/editor-page/PersistenceManagerUtils.ts @@ -38,11 +38,11 @@ export const buildPersistenceManagerForEditor = (mode: string): PersistenceManag return persistenceManager; }; -export const getMindmapFromPersistence = (mapId: string): Mindmap => { +export const fetchMindmap = async (mapId: number): Promise => { let mindmap: Mindmap; if (AppConfig.isRestClient()) { const persistence = new LocalStorageManager(`/c/restful/maps/{id}/document/xml`, true); - mindmap = persistence.load(String(mapId)); + mindmap = await persistence.load(String(mapId)); } else { const parser = new DOMParser(); const xmlDoc = parser.parseFromString( @@ -55,7 +55,7 @@ export const getMindmapFromPersistence = (mapId: string): Mindmap => { ); const serializer = XMLSerializerFactory.getSerializer('tango'); - mindmap = serializer.loadFromDom(xmlDoc, String(mapId)); + mindmap = Promise.resolve(serializer.loadFromDom(xmlDoc, String(mapId))); } return mindmap; }; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx index b42cf3df..6f3e6f46 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx @@ -18,7 +18,7 @@ import { Mindmap, SizeType, } from '@wisemapping/editor'; -import { getMindmapFromPersistence } from '../../../editor-page/PersistenceManagerUtils'; +import { fetchMindmap } from '../../../editor-page/PersistenceManagerUtils'; import Checkbox from '@mui/material/Checkbox'; @@ -87,7 +87,7 @@ const ExportDialog = ({ setZoomToFit(!zoomToFit); }; - const exporter = (formatType: ExportFormat): Promise => { + const exporter = async (formatType: ExportFormat): Promise => { let svgElement: Element | null = null; let size: SizeType; let mindmap: Mindmap; @@ -103,7 +103,7 @@ const ExportDialog = ({ } // exporting from map list else { - mindmap = getMindmapFromPersistence(String(mapId)); + mindmap = await fetchMindmap(mapId); } let exporter: Exporter;