From 7f296401b55ff993ee319256f0436c104c0d3cc0 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 4 Apr 2025 23:02:16 +0200 Subject: [PATCH] Changed the update notification to use the default notification system --- .../Layout/MainLayout.razor | 13 ----- .../Layout/MainLayout.razor.cs | 49 ++++++------------- .../wwwroot/changelog/v0.9.39.md | 1 + 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/app/MindWork AI Studio/Layout/MainLayout.razor b/app/MindWork AI Studio/Layout/MainLayout.razor index 434bad1d..96ebb50a 100644 --- a/app/MindWork AI Studio/Layout/MainLayout.razor +++ b/app/MindWork AI Studio/Layout/MainLayout.razor @@ -45,19 +45,6 @@ - @if (!this.performingUpdate && this.IsUpdateAlertVisible) - { - -
- - An update to version @this.updateToVersion is available. - - Show details - -
-
- } - @if (!this.performingUpdate) { @this.Body diff --git a/app/MindWork AI Studio/Layout/MainLayout.razor.cs b/app/MindWork AI Studio/Layout/MainLayout.razor.cs index 20c5664d..08e963cb 100644 --- a/app/MindWork AI Studio/Layout/MainLayout.razor.cs +++ b/app/MindWork AI Studio/Layout/MainLayout.razor.cs @@ -37,8 +37,6 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis [Inject] private MudTheme ColorTheme { get; init; } = null!; - - public string AdditionalHeight { get; private set; } = "0em"; private string PaddingLeft => this.navBarOpen ? $"padding-left: {NAVBAR_EXPANDED_WIDTH_INT - NAVBAR_COLLAPSED_WIDTH_INT}em;" : "padding-left: 0em;"; @@ -48,10 +46,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis private static readonly string NAVBAR_EXPANDED_WIDTH = $"{NAVBAR_EXPANDED_WIDTH_INT}em"; private bool navBarOpen; - private bool isUpdateAvailable; private bool performingUpdate; - private bool userDismissedUpdate; - private string updateToVersion = string.Empty; private UpdateResponse? currentUpdateResponse; private MudThemeProvider themeProvider = null!; private bool useDarkMode; @@ -107,7 +102,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis // Register this component with the message bus: this.MessageBus.RegisterComponent(this); - this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.USER_SEARCH_FOR_UPDATE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR ]); + this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR ]); // Set the snackbar for the update service: UpdateService.SetBlazorDependencies(this.Snackbar); @@ -142,19 +137,24 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis { switch (triggeredEvent) { - case Event.USER_SEARCH_FOR_UPDATE: - this.userDismissedUpdate = false; - break; - case Event.UPDATE_AVAILABLE: if (data is UpdateResponse updateResponse) { this.currentUpdateResponse = updateResponse; - this.isUpdateAvailable = updateResponse.UpdateIsAvailable; - this.updateToVersion = updateResponse.NewVersion; - - await this.InvokeAsync(this.StateHasChanged); - await this.SendMessage(Event.STATE_HAS_CHANGED); + this.Snackbar.Add($"An update to version {updateResponse.NewVersion} is available.", Severity.Info, config => + { + config.Icon = Icons.Material.Filled.Update; + config.IconSize = Size.Large; + config.HideTransitionDuration = 600; + config.VisibleStateDuration = 32_000; + config.OnClick = async _ => + { + await this.ShowUpdateDialog(); + }; + config.Action = "Show details"; + config.ActionVariant = Variant.Filled; + config.ActionColor = Color.Dark; + }); } break; @@ -207,25 +207,6 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis yield return new("About", Icons.Material.Filled.Info, palette.DarkLighten, palette.GrayLight, Routes.ABOUT, false); yield return new("Settings", Icons.Material.Filled.Settings, palette.DarkLighten, palette.GrayLight, Routes.SETTINGS, false); } - - private async Task DismissUpdate() - { - this.userDismissedUpdate = true; - this.AdditionalHeight = "0em"; - - await this.SendMessage(Event.STATE_HAS_CHANGED); - } - - private bool IsUpdateAlertVisible - { - get - { - var state = this.isUpdateAvailable && !this.userDismissedUpdate; - this.AdditionalHeight = state ? "3em" : "0em"; - - return state; - } - } private async Task ShowUpdateDialog() { diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.39.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.39.md index c3b306c2..cf523eb1 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.39.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.39.md @@ -5,6 +5,7 @@ - Added the plugin overview page. This page shows all installed plugins and allows you to enable or disable them. It is only available when the plugin preview feature is enabled. - Added hot reloading for plugins. When any plugin is changed, the app will automatically reload the plugin without needing to restart the app. - Added an API for streaming arbitrary local files to the embedding process. Thanks Nils `nilskruthoff` for this great contribution. +- Changed the update notification to use the default notification system at the bottom instead of the custom alert bar at the top. - Fixed the preview tooltip component not showing the correct position when used inside a scrollable container. - Upgraded to Rust v1.86.0 - Upgraded to MudBlazor v8.5.1 \ No newline at end of file