Skip to content

Commit

Permalink
Update TryRestoringState to return bool in page strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriyDurov committed Sep 15, 2024
1 parent 895df93 commit a9135b7
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal override void BuildRenderTree(RenderTreeBuilder builder)
builder.CloseComponent();
}

protected override async Task TryRestoringStateAsync()
protected override async Task<bool> TryRestoringStateAsync()
{
var js = ServiceProvider.GetRequiredService<IJSRuntime>();
var stateBase64 = await js.InvokeAsync<string?>("getInnerText", [PageStateElementId]);
Expand All @@ -79,14 +79,14 @@ protected override async Task TryRestoringStateAsync()
ServiceProvider.GetRequiredService<ILogger<PersistentPageRenderStrategy>>()
.LogWarning("State container was not found on page. Initializing state as a fallback. Ignore this warning if prerendering is disabled for this page.");

await InitializeStateAsync();
return;
return false;
}

PageState = RestoreBase64State(stateBase64);
StateInitialized = true;

PersistentComponent.NotifyStateRestored();
return true;
}

private PersistentPageState RestoreBase64State(string base64State)
Expand Down

0 comments on commit a9135b7

Please sign in to comment.