Skip to content

Commit

Permalink
Fix attachment panel on on settings bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
edgett committed Dec 13, 2023
1 parent 16958f7 commit 180883b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion PalmHill.BlazorChat/Client/Components/Chat/ChatInput.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<FluentFooter Class="w-100" Style="position:fixed; bottom:15px;">
<FluentStack Class="chat-messages input-area">
<div class="file-input-area" @onclick="Controller!.ShowAttachments">
<div class="file-input-area" @onclick="Controller!.ToggleAttachmentsVisible">
<FluentCounterBadge Count="Controller?.UploadedFiles.Count ?? 0"
ShowZero="true"
BottomPosition="-10">
Expand Down
13 changes: 0 additions & 13 deletions PalmHill.BlazorChat/Client/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,3 @@
<FluentTooltipProvider />
<FluentMessageBarProvider />

@code {
private bool darkMode = false;
public static bool Expanded { get; set; } = true;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{

await ThemeControl.ChangeTheme(darkMode);
StateHasChanged();
}
}
}
2 changes: 2 additions & 0 deletions PalmHill.BlazorChat/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/"
@inject ChatService Controller;
@inject LocalStorageService LocalStorage;

<FluentHeader Class="chat-header">
<FluentButton
Expand Down Expand Up @@ -32,6 +33,7 @@
protected override async Task OnInitializedAsync()
{
attachControllerEvents();
await LocalStorage.SyncTheme();
await Controller.StartChat();
}

Expand Down
4 changes: 2 additions & 2 deletions PalmHill.BlazorChat/Client/Services/ChatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ BlazorChatApi blazorChatApi
/// <summary>
/// Show the attachment panel.
/// </summary>
public bool AttachmentsVisible { get; private set; } = false;
public bool AttachmentsVisible { get; set; } = false;
/// <summary>
/// The list of files that have been selected for Chat. This is non-functional for now.
/// </summary>
Expand Down Expand Up @@ -213,7 +213,7 @@ public async Task ShowSettings()
if (dialogResult?.Cancelled == true)
{
//Reset the theme if cancel.
await _themeControl.ChangeTheme(LocalStorageSettings.DarkMode);
await _localStorageService.SyncTheme();
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion PalmHill.BlazorChat/Client/Services/LocalStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ public LocalStorageService(ILocalStorageService localStorage, ThemeService theme
public async Task<LocalStorageSettings> GetSettings()
{
LocalStorageSettings = await _getMigratedSettings();
await _themeControl.ChangeTheme(LocalStorageSettings.DarkMode);
return LocalStorageSettings;
}

public async Task SyncTheme()
{
await _themeControl.ChangeTheme(LocalStorageSettings.DarkMode);
}

/// <summary>
/// Save the settings to local storage.
/// </summary>
Expand Down

0 comments on commit 180883b

Please sign in to comment.