Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset cache when a new version is released. Also reset cache when updating the game language. #205

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}

}


Loading