Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CoreVersion>5.0.0.75</CoreVersion>
<CoreVersion>5.0.0.78</CoreVersion>
<Configurations>Debug;Release;SourceGen Highlighting</Configurations>
<Platforms>AnyCPU</Platforms>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
Expand Down
Binary file modified build-tools/linux-x64/BuildAppSettings
Binary file not shown.
Binary file modified build-tools/linux-x64/BuildAppSettings.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/BuildTemplates
Binary file not shown.
Binary file modified build-tools/linux-x64/BuildTemplates.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/ConsoleDialog
Binary file not shown.
Binary file modified build-tools/linux-x64/ConsoleDialog.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/ESBuild
Binary file not shown.
Binary file modified build-tools/linux-x64/ESBuild.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/ESBuildClearLocks
Binary file not shown.
Binary file modified build-tools/linux-x64/ESBuildClearLocks.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/FetchNuGetVersion
Binary file not shown.
Binary file modified build-tools/linux-x64/FetchNuGetVersion.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/GBTest
Binary file not shown.
Binary file modified build-tools/linux-x64/GBTest.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/RazorCopy
Binary file not shown.
Binary file modified build-tools/linux-x64/RazorCopy.dll
Binary file not shown.
Binary file modified build-tools/linux-x64/Utilities.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/dymaptic.GeoBlazor.Core/Components/Layers/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public async Task UpdateLayer()
_delayedUpdate = false;

// ReSharper disable once RedundantCast
await JsComponentReference!.InvokeAsync<string?>("updateComponent", CancellationTokenSource.Token,
await JsComponentReference.InvokeAsync<string?>("updateComponent", CancellationTokenSource.Token,
(object)this);
}

Expand Down
16 changes: 14 additions & 2 deletions src/dymaptic.GeoBlazor.Core/Components/MapComponent.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Guid? ViewId
/// The Id of the relevant Layer for the MapComponent. Not always applicable to every component type.
/// </summary>
[Parameter]
public Guid? LayerId { get; set; }
public virtual Guid? LayerId { get; set; }

/// <summary>
/// Indicates the visibility of the component. Default value: true.
Expand Down Expand Up @@ -884,6 +884,18 @@ protected override async Task OnInitializedAsync()
}
}

/// <inheritdoc />
protected override void OnParametersSet()
{
base.OnParametersSet();
LayerId ??= Layer?.Id;
Layer ??= Parent?.Layer;
View ??= Parent?.View;
CoreJsModule ??= Parent?.CoreJsModule;
ProJsModule ??= Parent?.ProJsModule;
}


/// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
Expand Down Expand Up @@ -1087,7 +1099,7 @@ private void CopyProperty(PropertyInfo prop, MapComponent deserializedComponent)
/// <param name="visited">
/// Previously updated parent components
/// </param>
protected internal void UpdateGeoBlazorReferences(IJSObjectReference coreJsModule, IJSObjectReference? proJsModule,
protected virtual internal void UpdateGeoBlazorReferences(IJSObjectReference coreJsModule, IJSObjectReference? proJsModule,
MapView? view, MapComponent? parent, Layer? layer, int depth = 0, HashSet<object>? visited = null)
{
visited ??= new HashSet<object>();
Expand Down
49 changes: 31 additions & 18 deletions src/dymaptic.GeoBlazor.Core/Components/Views/MapView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public async Task OnJavascriptError(JavascriptError error)
if (IsDisposed) return;
#if DEBUG
ErrorMessage = error.Message?.Replace("\n", "<br>") ?? error.Stack;
StateHasChanged();
await InvokeAsync(StateHasChanged);
#endif
var exception = new JavascriptException(error);

Expand Down Expand Up @@ -1216,14 +1216,12 @@ public async Task OnJavascriptLayerViewCreateError(LayerViewCreateErrorEvent err
#region Public Methods

/// <inheritdoc />
public override ValueTask Refresh()
public override async ValueTask Refresh()
{
NeedsRender = true;
ExtentSetByCode = false;
ExtentChangedInJs = false;
StateHasChanged();

return ValueTask.CompletedTask;
await InvokeAsync(StateHasChanged);
}

/// <summary>
Expand All @@ -1234,7 +1232,7 @@ public void Load()
{
_renderCalled = true;
NeedsRender = true;
StateHasChanged();
InvokeAsync(StateHasChanged);
}

/// <summary>
Expand Down Expand Up @@ -1525,7 +1523,7 @@ public async Task ClearGraphics()
/// <param name="isBasemapReferenceLayer">
/// If true, adds the layer as a Basemap Reference Layer.
/// </param>
public Task AddLayer(Layer layer, bool isBasemapLayer = false, bool isBasemapReferenceLayer = false)
public async Task AddLayer(Layer layer, bool isBasemapLayer = false, bool isBasemapReferenceLayer = false)
{
if (isBasemapLayer && layer.IsBasemapReferenceLayer != true)
{
Expand Down Expand Up @@ -1553,12 +1551,13 @@ public Task AddLayer(Layer layer, bool isBasemapLayer = false, bool isBasemapRef

layer.View ??= this;

if (CoreJsModule is null || !MapRendered) return Task.CompletedTask;
if (CoreJsModule is null || !MapRendered)
{
return;
}

_newLayers.Add((layer, isBasemapLayer, isBasemapReferenceLayer));
StateHasChanged();

return Task.CompletedTask;
await InvokeAsync(StateHasChanged);
}

/// <summary>
Expand Down Expand Up @@ -2353,20 +2352,21 @@ public void OnJavascriptHitTestResult(Guid eventId, string chunk)
/// <summary>
/// Adds a widget to the view.
/// </summary>
public Task AddWidget(Widget widget)
public async Task AddWidget(Widget widget)
{
if (!_widgets.Contains(widget))
{
_widgets.Add(widget);
widget.UpdateGeoBlazorReferences(CoreJsModule!, ProJsModule, View, this, null);
}

if (CoreJsModule is null || !widget.ArcGISWidget || !MapRendered) return Task.CompletedTask;
if (CoreJsModule is null || !widget.ArcGISWidget || !MapRendered)
{
return;
}

_newWidgets.Add(widget);
StateHasChanged();

return Task.CompletedTask;
await InvokeAsync(StateHasChanged);
}

/// <summary>
Expand Down Expand Up @@ -2538,7 +2538,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
catch (Exception ex)
{
ErrorMessage = ex.Message;
StateHasChanged();
await InvokeAsync(StateHasChanged);

throw;
}
Expand Down Expand Up @@ -2583,7 +2583,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
}

_firstRenderComplete = true;
StateHasChanged();
await InvokeAsync(StateHasChanged);

return;
}
Expand All @@ -2600,6 +2600,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

if (MapRendered)
{
// layers added in code can have race conditions that require another render before adding to the map,
// so we store them in AddLayer and then add them here after the main render
if (_newLayers.Any())
{
(Layer Layer, bool IsBasemapLayer, bool IsBasemapReferenceLayer)[] newLayers = _newLayers.ToArray();
Expand All @@ -2609,6 +2611,17 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
await CoreJsModule!.InvokeVoidAsync("addLayer", CancellationTokenSource.Token,
(object)newLayer, Map?.Id, Id, isBasemapLayer, isBasemapReferenceLayer);

// this updates widgets that were assigned a LayerId instead of a Layer
if (_widgets.Where(w => w.LayerId == newLayer.Id).ToList() is { Count: > 0 } widgetMatches)
{
foreach (Widget widget in widgetMatches)
{
// set layer to null forces widget to update and call JavaScript
widget.Layer = null;
widget.UpdateGeoBlazorReferences(CoreJsModule!, ProJsModule, this, this, newLayer);
}
}
}
}

Expand Down
20 changes: 18 additions & 2 deletions src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,22 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
}
}

/// <inheritdoc />
protected internal override void UpdateGeoBlazorReferences(IJSObjectReference coreJsModule, IJSObjectReference? proJsModule,
MapView? view, MapComponent? parent, Layer? layer, int depth = 0, HashSet<object>? visited = null)
{
bool needsUpdate = false;
if (layer is not null && layer.Id != Layer?.Id)
{
needsUpdate = true;
}
base.UpdateGeoBlazorReferences(coreJsModule, proJsModule, view, parent, layer, depth, visited);
if (needsUpdate)
{
InvokeAsync(UpdateWidget);
}
}

/// <summary>
/// Updates the widget internally. Not intended for public use.
/// </summary>
Expand All @@ -477,7 +493,7 @@ protected async Task UpdateWidget()

try
{
JsComponentReference ??= await CoreJsModule!.InvokeAsync<IJSObjectReference?>(
JsComponentReference ??= await CoreJsModule.InvokeAsync<IJSObjectReference?>(
"getJsComponent", CancellationTokenSource.Token, Id);
}
catch
Expand All @@ -491,7 +507,7 @@ protected async Task UpdateWidget()
}

// ReSharper disable once RedundantCast
await JsComponentReference!.InvokeVoidAsync("updateComponent", CancellationTokenSource.Token, (object)this);
await JsComponentReference.InvokeVoidAsync("updateComponent", CancellationTokenSource.Token, (object)this);
}

private bool _externalWidgetRegistered;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public TestRunnerBase()
var retryStrategyOptions = new RetryStrategyOptions
{
BackoffType = DelayBackoffType.Exponential,
MaxRetryAttempts = 3,
MaxRetryAttempts = 2, // one retry is usually plenty, two just in case
Delay = TimeSpan.FromSeconds(1),
ShouldHandle = new PredicateBuilder().Handle<Exception>(ex =>
!ex.Message.Contains("Invalid GeoBlazor registration key")
Expand All @@ -34,6 +34,10 @@ public TestRunnerBase()
&& !ex.Message.Contains("Map component view is in an invalid state")),
OnRetry = async args =>
{
if (args.Context.OperationKey is null)
{
return;
}
await CleanupTest(args.Context.OperationKey!, true);
_testResults[args.Context.OperationKey!] = $"Attempt {args.AttemptNumber + 1} failed. Retrying...";
}
Expand Down