Skip to content

Commit

Permalink
Reset cache when a new version is released. Also reset cache when upd…
Browse files Browse the repository at this point in the history
…ating the game language.
  • Loading branch information
leMicin committed Jul 28, 2024
1 parent c78cafa commit 12b7e9f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/Sidekick.Common.Blazor/Initialization/Initialization.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Sidekick.Common.Browser;
using Sidekick.Common.Cache;
using Sidekick.Common.Initialization;
using Sidekick.Common.Keybinds;
using Sidekick.Common.Platform;
Expand Down Expand Up @@ -38,6 +39,9 @@ public partial class Initialization : SidekickView
[Inject]
private ISettingsService SettingsService { get; set; } = null!;

[Inject]
private ICacheProvider CacheProvider { get; set; } = null!;

private int Count { get; set; }

private int Completed { get; set; }
Expand Down Expand Up @@ -72,6 +76,13 @@ public async Task Handle()
{
Completed = 0;
Count = Configuration.Value.InitializableServices.Count + 1;
var version = GetVersion();
var perviousVersion = await SettingsService.GetString(SettingKeys.Version);
if (version != perviousVersion)
{
CacheProvider.Clear();
await SettingsService.Set(SettingKeys.Version, version);
}

// Report initial progress
await ReportProgress();
Expand Down Expand Up @@ -158,19 +169,22 @@ private Task ReportProgress()
});
}

private string? GetVersion()
{
return FileVersionInfo.GetVersionInfo(
GetType()
.Assembly.Location)
.ProductVersion;
}

private void InitializeTray()
{
var menuItems = new List<TrayMenuItem>();

menuItems.AddRange(
new List<TrayMenuItem>()
{
new(
label: "Sidekick - "
+ FileVersionInfo.GetVersionInfo(
GetType()
.Assembly.Location)
.ProductVersion),
new(label: "Sidekick - " + GetVersion()),
new(
label: "Open Website",
onClick: () =>
Expand Down
2 changes: 2 additions & 0 deletions src/Sidekick.Common/Settings/SettingKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ namespace Sidekick.Common.Settings;

public static class SettingKeys
{
public const string Version = nameof(Version);

public const string CurrentDirectory = nameof(CurrentDirectory);

public const string BearerToken = nameof(BearerToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@inject SettingsResources Resources
@inject IGameLanguageProvider GameLanguageProvider
@inject ISettingsService SettingsService
@inject NavigationManager NavigationManager

@code {

Expand Down Expand Up @@ -38,6 +39,9 @@
{
Language = value;
await SettingsService.Set(SettingKeys.LanguageParser, value);
NavigationManager.NavigateTo("/initialize");
}

}


0 comments on commit 12b7e9f

Please sign in to comment.