From 473711f619d22207dcf0bab3da6f11b960aad7a5 Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 27 Jun 2024 05:59:10 +0800 Subject: [PATCH] D ui3 299 arc gis not opening saved model cards (#3532) * resurrect DocumentStore subscriptions * read metadata from existing map * don't break DI if Map is still not loaded --- .../Utils/ArcGisDocumentStore.cs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs index db0df3550f..eb420af874 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Utils/ArcGisDocumentStore.cs @@ -18,17 +18,31 @@ ITopLevelExceptionHandler topLevelExceptionHandler ) : base(serializerOption, true) { - ActiveMapViewChangedEvent.Subscribe(a => topLevelExceptionHandler.CatchUnhandled(() => OnMapViewChanged(a))); - ProjectSavingEvent.Subscribe(_ => - { - topLevelExceptionHandler.CatchUnhandled(OnProjectSaving); - return Task.CompletedTask; - }); - ProjectClosingEvent.Subscribe(_ => + ActiveMapViewChangedEvent.Subscribe(a => topLevelExceptionHandler.CatchUnhandled(() => OnMapViewChanged(a)), true); + ProjectSavingEvent.Subscribe( + _ => + { + topLevelExceptionHandler.CatchUnhandled(OnProjectSaving); + return Task.CompletedTask; + }, + true + ); + ProjectClosingEvent.Subscribe( + _ => + { + topLevelExceptionHandler.CatchUnhandled(OnProjectClosing); + return Task.CompletedTask; + }, + true + ); + + // in case plugin was loaded into already opened Map, read metadata from the current Map + if (IsDocumentInit == false && MapView.Active != null) { - topLevelExceptionHandler.CatchUnhandled(OnProjectClosing); - return Task.CompletedTask; - }); + IsDocumentInit = true; + ReadFromFile(); + OnDocumentChanged(); + } } private void OnProjectClosing()