Provide user feedback when no update was found

This commit is contained in:
Thorsten Sommer 2024-06-30 19:10:12 +02:00
parent 2a7ede0a05
commit b20812d2dd
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 18 additions and 5 deletions

View File

@ -59,7 +59,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver
this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.USER_SEARCH_FOR_UPDATE ]); this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.USER_SEARCH_FOR_UPDATE ]);
// Set the js runtime for the update service: // Set the js runtime for the update service:
UpdateService.SetJsRuntime(this.JsRuntime); UpdateService.SetBlazorDependencies(this.JsRuntime, this.Snackbar);
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }

View File

@ -23,7 +23,7 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
this.settingsManager = settingsManager; this.settingsManager = settingsManager;
this.messageBus = messageBus; this.messageBus = messageBus;
this.rust = rust; this.rust = rust;
this.messageBus.RegisterComponent(this); this.messageBus.RegisterComponent(this);
this.ApplyFilters([], [ Event.USER_SEARCH_FOR_UPDATE ]); this.ApplyFilters([], [ Event.USER_SEARCH_FOR_UPDATE ]);
@ -69,7 +69,7 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
switch (triggeredEvent) switch (triggeredEvent)
{ {
case Event.USER_SEARCH_FOR_UPDATE: case Event.USER_SEARCH_FOR_UPDATE:
await this.CheckForUpdate(); await this.CheckForUpdate(notifyUserWhenNoUpdate: true);
break; break;
} }
} }
@ -86,7 +86,7 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
#endregion #endregion
private async Task CheckForUpdate() private async Task CheckForUpdate(bool notifyUserWhenNoUpdate = false)
{ {
if(!IS_INITIALIZED) if(!IS_INITIALIZED)
return; return;
@ -96,10 +96,23 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
{ {
await this.messageBus.SendMessage(null, Event.UPDATE_AVAILABLE, response); await this.messageBus.SendMessage(null, Event.UPDATE_AVAILABLE, response);
} }
else
{
if (notifyUserWhenNoUpdate)
{
SNACKBAR!.Add("No update found.", Severity.Normal, config =>
{
config.Icon = Icons.Material.Filled.Update;
config.IconSize = Size.Large;
config.IconColor = Color.Primary;
});
}
}
} }
public static void SetJsRuntime(IJSRuntime jsRuntime) public static void SetBlazorDependencies(IJSRuntime jsRuntime, ISnackbar snackbar)
{ {
SNACKBAR = snackbar;
JS_RUNTIME = jsRuntime; JS_RUNTIME = jsRuntime;
IS_INITIALIZED = true; IS_INITIALIZED = true;
} }