@@ -97,10 +97,10 @@ public partial class Resources : ComponentBase, IComponentWithTelemetry, IAsyncD
97
97
private readonly CancellationTokenSource _watchTaskCancellationTokenSource = new ( ) ;
98
98
private readonly ConcurrentDictionary < string , ResourceViewModel > _resourceByName = new ( StringComparers . ResourceName ) ;
99
99
private readonly HashSet < string > _collapsedResourceNames = new ( StringComparers . ResourceName ) ;
100
+ private readonly TaskCompletionSource _loadingTcs = new ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
100
101
private string _filter = "" ;
101
102
private bool _isFilterPopupVisible ;
102
103
private Task ? _resourceSubscriptionTask ;
103
- private bool _isLoading = true ;
104
104
private string ? _elementIdBeforeDetailsViewOpened ;
105
105
private FluentDataGrid < ResourceGridViewModel > _dataGrid = null ! ;
106
106
private GridColumnManager _manager = null ! ;
@@ -235,7 +235,7 @@ protected override async Task OnInitializedAsync()
235
235
}
236
236
} ) ;
237
237
238
- _isLoading = false ;
238
+ _loadingTcs . SetResult ( ) ;
239
239
240
240
async Task SubscribeResourcesAsync ( )
241
241
{
@@ -522,6 +522,9 @@ protected override async Task OnParametersSetAsync()
522
522
return ;
523
523
}
524
524
525
+ // Wait until the initial data is loaded. This is required so there isn't a race between data loading and using resources here.
526
+ await _loadingTcs . Task ;
527
+
525
528
// If filters were saved in page state, resource filters now need to be recomputed since the URL has changed.
526
529
foreach ( var resourceViewModel in _resourceByName )
527
530
{
@@ -534,6 +537,10 @@ protected override async Task OnParametersSetAsync()
534
537
{
535
538
await ShowResourceDetailsAsync ( selectedResource , buttonId : null ) ;
536
539
}
540
+ else
541
+ {
542
+ Logger . LogDebug ( "Can't navigate to {ResourceName} from URL. Resource not found." , ResourceName ) ;
543
+ }
537
544
538
545
// Navigate to remove ?resource=xxx in the URL.
539
546
NavigationManager . NavigateTo ( DashboardUrls . ResourcesUrl ( ) , new NavigationOptions { ReplaceHistoryEntry = true } ) ;
@@ -598,6 +605,8 @@ private async Task ShowContextMenuAsync(ResourceViewModel resource, int screenWi
598
605
599
606
private async Task ShowResourceDetailsAsync ( ResourceViewModel resource , string ? buttonId )
600
607
{
608
+ Logger . LogDebug ( "Showing details for resource {ResourceName}." , resource . Name ) ;
609
+
601
610
_elementIdBeforeDetailsViewOpened = buttonId ;
602
611
603
612
if ( string . Equals ( SelectedResource ? . Name , resource . Name , StringComparisons . ResourceName ) )
@@ -635,6 +644,8 @@ private async Task ShowResourceDetailsAsync(ResourceViewModel resource, string?
635
644
636
645
private async Task ClearSelectedResourceAsync ( bool causedByUserAction = false )
637
646
{
647
+ Logger . LogDebug ( "Clearing selected resource." ) ;
648
+
638
649
SelectedResource = null ;
639
650
640
651
await InvokeAsync ( StateHasChanged ) ;
@@ -781,7 +792,8 @@ private Task OnTabChangeAsync(FluentTab newTab)
781
792
782
793
if ( id is null
783
794
|| ! Enum . TryParse ( typeof ( ResourceViewKind ) , id , out var o )
784
- || o is not ResourceViewKind viewKind )
795
+ || o is not ResourceViewKind viewKind
796
+ || PageViewModel . SelectedViewKind == viewKind )
785
797
{
786
798
return Task . CompletedTask ;
787
799
}
0 commit comments