From ae34e71ba4bf81ff6c57d178c26cf53dd89bf8a9 Mon Sep 17 00:00:00 2001 From: Prathamesh Narkhede <55591622+prathameshnarkhede@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:44:19 -0700 Subject: [PATCH] Removed LoadAsync call to Basemap before loading MapView. (#582) Refactor async methods to sync in BasemapGallery. --- .../BasemapGallery/BasemapGalleryController.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Toolkit/Toolkit/UI/Controls/BasemapGallery/BasemapGalleryController.cs b/src/Toolkit/Toolkit/UI/Controls/BasemapGallery/BasemapGalleryController.cs index 6d47a1e5b..1a2cdd1e7 100644 --- a/src/Toolkit/Toolkit/UI/Controls/BasemapGallery/BasemapGalleryController.cs +++ b/src/Toolkit/Toolkit/UI/Controls/BasemapGallery/BasemapGalleryController.cs @@ -143,7 +143,7 @@ private void HandleAvailableBasemapsChanged() AvailableBasemaps?.ToList()?.ForEach(bmgi => bmgi.NotifySpatialReferenceChanged(GeoModel)); // Update selection. - _ = UpdateSelectionForGeoModelBasemap(); + UpdateSelectionForGeoModelBasemap(); } finally { @@ -160,10 +160,10 @@ private void HandleAvailableBasemapsCollectionChanged(object? sender, NotifyColl case NotifyCollectionChangedAction.Replace: case NotifyCollectionChangedAction.Reset: e.NewItems?.OfType().ToList().ForEach(bmgi => bmgi.NotifySpatialReferenceChanged(GeoModel)); - _ = UpdateSelectionForGeoModelBasemap(); + UpdateSelectionForGeoModelBasemap(); break; case NotifyCollectionChangedAction.Remove: - _ = UpdateSelectionForGeoModelBasemap(); + UpdateSelectionForGeoModelBasemap(); break; } } @@ -171,14 +171,14 @@ private void HandleAvailableBasemapsCollectionChanged(object? sender, NotifyColl private void HandleGeoModelChanged() { AvailableBasemaps?.ToList().ForEach(item => item.NotifySpatialReferenceChanged(GeoModel)); - _ = UpdateSelectionForGeoModelBasemap(); + UpdateSelectionForGeoModelBasemap(); } private void HandleGeoModelPropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(GeoModel.Basemap) && !_ignoreEventsFlag) { - _ = UpdateSelectionForGeoModelBasemap(); + UpdateSelectionForGeoModelBasemap(); } else if (e.PropertyName == nameof(GeoModel.SpatialReference)) { @@ -244,11 +244,11 @@ public async Task LoadFromDefaultPortal() } } - private async Task UpdateSelectionForGeoModelBasemap() + private void UpdateSelectionForGeoModelBasemap() { if (GeoModel?.Basemap is Basemap inputBasemap) { - if (await BasemapIsActuallyNotABasemap(inputBasemap)) + if (BasemapIsActuallyNotABasemap(inputBasemap)) { SelectedBasemap = null; } @@ -270,9 +270,8 @@ private async Task UpdateSelectionForGeoModelBasemap() /// /// Maps and scenes start with an empty basemap that should not be shown in the UI. /// - private static async Task BasemapIsActuallyNotABasemap(Basemap input) + private static bool BasemapIsActuallyNotABasemap(Basemap input) { - await input.LoadAsync(); if (!input.BaseLayers.Any() && !input.ReferenceLayers.Any()) { return true;