diff --git a/DbFirst.BlazorWebApp/Services/BandLayoutService.cs b/DbFirst.BlazorWebApp/Services/BandLayoutService.cs index 4e1ae96..0082f80 100644 --- a/DbFirst.BlazorWebApp/Services/BandLayoutService.cs +++ b/DbFirst.BlazorWebApp/Services/BandLayoutService.cs @@ -9,16 +9,22 @@ namespace DbFirst.BlazorWebApp.Services { private const string LayoutUserStorageKey = "layoutUser"; private readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web); + private string? _cachedLayoutUser; public async Task EnsureLayoutUserAsync() { + if (!string.IsNullOrWhiteSpace(_cachedLayoutUser)) + return _cachedLayoutUser; + var layoutUser = await jsRuntime.InvokeAsync("localStorage.getItem", LayoutUserStorageKey); if (string.IsNullOrWhiteSpace(layoutUser)) { layoutUser = Guid.NewGuid().ToString("N"); await jsRuntime.InvokeVoidAsync("localStorage.setItem", LayoutUserStorageKey, layoutUser); } - return layoutUser; + + _cachedLayoutUser = layoutUser; + return _cachedLayoutUser; } public async Task LoadBandLayoutAsync(