Skip to content

Commit

Permalink
Removed LoadAsync call to Basemap before loading MapView. (#582)
Browse files Browse the repository at this point in the history
Refactor async methods to sync in BasemapGallery.
  • Loading branch information
prathameshnarkhede committed Jun 26, 2024
1 parent d7dd108 commit ae34e71
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void HandleAvailableBasemapsChanged()
AvailableBasemaps?.ToList()?.ForEach(bmgi => bmgi.NotifySpatialReferenceChanged(GeoModel));

// Update selection.
_ = UpdateSelectionForGeoModelBasemap();
UpdateSelectionForGeoModelBasemap();
}
finally
{
Expand All @@ -160,25 +160,25 @@ private void HandleAvailableBasemapsCollectionChanged(object? sender, NotifyColl
case NotifyCollectionChangedAction.Replace:
case NotifyCollectionChangedAction.Reset:
e.NewItems?.OfType<BasemapGalleryItem>().ToList().ForEach(bmgi => bmgi.NotifySpatialReferenceChanged(GeoModel));
_ = UpdateSelectionForGeoModelBasemap();
UpdateSelectionForGeoModelBasemap();
break;
case NotifyCollectionChangedAction.Remove:
_ = UpdateSelectionForGeoModelBasemap();
UpdateSelectionForGeoModelBasemap();
break;
}
}

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))
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -270,9 +270,8 @@ private async Task UpdateSelectionForGeoModelBasemap()
/// <summary>
/// Maps and scenes start with an empty basemap that should not be shown in the UI.
/// </summary>
private static async Task<bool> BasemapIsActuallyNotABasemap(Basemap input)
private static bool BasemapIsActuallyNotABasemap(Basemap input)
{
await input.LoadAsync();
if (!input.BaseLayers.Any() && !input.ReferenceLayers.Any())
{
return true;
Expand Down

0 comments on commit ae34e71

Please sign in to comment.