diff --git a/Components/Layout/MainLayout.razor b/Components/Layout/MainLayout.razor index add1d0e..14a000d 100644 --- a/Components/Layout/MainLayout.razor +++ b/Components/Layout/MainLayout.razor @@ -1,12 +1,15 @@ @inherits LayoutComponentBase +@implements IDisposable @inject IUserSessionService Session @inject IUserContextAccessor UserContext @inject ISessionCredentialStore CredStore @inject ISessionManager SessionManager @inject NavigationManager Nav +@inject IJSRuntime JS @inject SharepointToolbox.Web.Services.OAuth.IOAuthFlowCache OAuthCache @using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.WebUtilities +@using Microsoft.JSInterop @using SharepointToolbox.Web.Core.Models @using SharepointToolbox.Web.Services.Session @@ -160,6 +163,9 @@ { if (!firstRender) return; + // Apply persisted theme preference + await ApplyThemeAsync(); + // Pick up token_key from OAuth callback redirect before checking credential state await HandleOAuthCallbackAsync(); await RefreshCredentialState(); @@ -172,7 +178,8 @@ Nav.NavigateTo(uri.GetLeftPart(UriPartial.Path), replace: true); if (_credModal is not null) { - await _credModal.ShowAsync(); + // Surface the failure reason instead of silently reopening the modal + await _credModal.ShowAsync(err!); } } @@ -234,6 +241,15 @@ }); } + private async Task ApplyThemeAsync() + { + try + { + await JS.InvokeVoidAsync("sptb.setTheme", Session.Settings.Theme); + } + catch (JSException) { /* best-effort; JS not yet available */ } + } + private void ToggleSidebar() => _sidebarCollapsed = !_sidebarCollapsed; private static string RoleChipClass(UserRole role) => role switch diff --git a/Components/Pages/Home.razor b/Components/Pages/Home.razor index 2af34ac..7d90778 100644 --- a/Components/Pages/Home.razor +++ b/Components/Pages/Home.razor @@ -29,8 +29,8 @@ else