Skip to content

Commit 1717a7f

Browse files
committed
More cleanups
1 parent 87b5b04 commit 1717a7f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Components/Components/src/PersistentComponentState.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics;
45
using System.Diagnostics.CodeAnalysis;
56
using System.Text.Json;
67
using static Microsoft.AspNetCore.Internal.LinkerFlags;
@@ -81,7 +82,8 @@ public PersistingComponentStateSubscription RegisterOnPersisting(Func<Task> call
8182
/// <returns>A subscription that can be used to unregister the callback when disposed.</returns>
8283
public RestoringComponentStateSubscription RegisterOnRestoring(Action callback, RestoreOptions options)
8384
{
84-
if (_currentContext!.ShouldRestore(options))
85+
Debug.Assert(_currentContext != null);
86+
if (_currentContext.ShouldRestore(options))
8587
{
8688
callback();
8789
}

src/Components/Components/src/PersistentState/ComponentStatePersistenceManager.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ public async Task RestoreStateAsync(IPersistentComponentStateStore store, Restor
8282
_stateIsInitialized = true;
8383
}
8484

85-
foreach (var registration in _registeredRestoringCallbacks)
85+
if (context == RestoreContext.ValueUpdate)
8686
{
87-
//if (scenario == null || registration.Filter == null ||
88-
// (registration.Filter.SupportsScenario(scenario) && registration.Filter.ShouldRestore(scenario)) ||
89-
// (!registration.Filter.SupportsScenario(scenario) && !scenario.IsRecurring))
90-
//{
91-
registration.Callback();
92-
//}
87+
foreach (var registration in _registeredRestoringCallbacks)
88+
{
89+
registration.Callback();
90+
}
91+
return;
9392
}
9493
}
9594

0 commit comments

Comments
 (0)