From 25f0ab84c2b16e484939e772d5ccf1c4f9cc065f Mon Sep 17 00:00:00 2001 From: VINAGHOST Date: Tue, 25 Oct 2022 10:33:14 +0700 Subject: [PATCH 1/5] fix crash with old database file(#179) --- MainCore/Migrations/202210181120_UpgradeTroopMigrations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MainCore/Migrations/202210181120_UpgradeTroopMigrations.cs b/MainCore/Migrations/202210181120_UpgradeTroopMigrations.cs index 37758e7fc..1ad2cbfcf 100644 --- a/MainCore/Migrations/202210181120_UpgradeTroopMigrations.cs +++ b/MainCore/Migrations/202210181120_UpgradeTroopMigrations.cs @@ -16,7 +16,7 @@ public override void Up() { Alter.Table("VillagesSettings") .AddColumn("IsUpgradeTroop").AsBoolean().WithDefaultValue(false) - .AddColumn("UpgradeTroop").AsString(); + .AddColumn("UpgradeTroop").AsString().Nullable(); } } } \ No newline at end of file From ead7da2998ad53de26a805b4e337bc43ff8f3f69 Mon Sep 17 00:00:00 2001 From: VINAGHOST Date: Tue, 25 Oct 2022 10:35:31 +0700 Subject: [PATCH 2/5] change version window ui (#181) --- MainCore/Helper/GithubHelper.cs | 13 --------- WPFUI/ViewModels/VersionViewModel.cs | 41 ++-------------------------- WPFUI/Views/VersionWindow.xaml | 8 ------ WPFUI/Views/VersionWindow.xaml.cs | 2 -- 4 files changed, 3 insertions(+), 61 deletions(-) diff --git a/MainCore/Helper/GithubHelper.cs b/MainCore/Helper/GithubHelper.cs index 4c731a3df..76dc603d1 100644 --- a/MainCore/Helper/GithubHelper.cs +++ b/MainCore/Helper/GithubHelper.cs @@ -30,18 +30,5 @@ public static async Task CheckGitHubLatestVersion() } return null; } - - public static async Task CheckGitHublatestBuild() - { - try - { - var releases = await _client.Repository.Release.GetAll(_username, _repo); - if (releases.Count > 0) return new Version(releases[0].TagName); - } - catch - { - } - return null; - } } } \ No newline at end of file diff --git a/WPFUI/ViewModels/VersionViewModel.cs b/WPFUI/ViewModels/VersionViewModel.cs index 2cc0f7fce..08e10466e 100644 --- a/WPFUI/ViewModels/VersionViewModel.cs +++ b/WPFUI/ViewModels/VersionViewModel.cs @@ -18,16 +18,14 @@ public VersionViewModel() DiscordCommand = ReactiveCommand.Create(DiscordTask); LatestVersionCommand = ReactiveCommand.Create(LatestVersionTask, this.WhenAnyValue(x => x.IsNewVersion)); - LatestBuildCommand = ReactiveCommand.Create(LatestBuildTask, this.WhenAnyValue(x => x.IsNewBuild)); CloseCommand = ReactiveCommand.Create(CloseTask); } public async Task Load() { - var result = await Task.WhenAll(GithubHelper.CheckGitHubLatestVersion(), GithubHelper.CheckGitHublatestBuild()); + var result = await GithubHelper.CheckGitHubLatestVersion(); - LatestVersion = result[0].ToString(); - LatestBuild = result[1].ToString(); + LatestVersion = result.ToString(); } private void DiscordTask() @@ -49,16 +47,6 @@ private void LatestVersionTask() CloseTask(); } - private void LatestBuildTask() - { - Process.Start(new ProcessStartInfo - { - FileName = GithubHelper.GetLink(_latestBuild), - UseShellExecute = true - }); - CloseTask(); - } - private void CloseTask() { CloseWindow?.Invoke(); @@ -68,7 +56,7 @@ private void CloseTask() public string CurrentVersion { - get => $"Current: {_currentVersion}"; + get => $"Current version: {_currentVersion}"; set => this.RaiseAndSetIfChanged(ref _currentVersion, value); } @@ -85,18 +73,6 @@ public string LatestVersion } } - private string _latestBuild; - - public string LatestBuild - { - get => $"Latest build: {_latestBuild}"; - set - { - this.RaiseAndSetIfChanged(ref _latestBuild, value); - this.RaisePropertyChanged(nameof(IsNewBuild)); - } - } - public bool IsNewVersion { get @@ -107,16 +83,6 @@ public bool IsNewVersion } } - public bool IsNewBuild - { - get - { - var current = new Version($"{_currentVersion}.0"); - var last = new Version($"{_latestVersion}.0"); - return current.CompareTo(last) < 0; - } - } - public string Message { get => message[IsNewVersion ? 1 : 0]; @@ -131,7 +97,6 @@ public string Message public ReactiveCommand DiscordCommand { get; } public ReactiveCommand LatestVersionCommand { get; } - public ReactiveCommand LatestBuildCommand { get; } public ReactiveCommand CloseCommand { get; } public event Action CloseWindow; diff --git a/WPFUI/Views/VersionWindow.xaml b/WPFUI/Views/VersionWindow.xaml index a7a145957..43c7d74ea 100644 --- a/WPFUI/Views/VersionWindow.xaml +++ b/WPFUI/Views/VersionWindow.xaml @@ -13,7 +13,6 @@ - @@ -31,15 +30,8 @@ - - - - - -