From fe0548432de75f8ad1d6fa6fd817bb529d557022 Mon Sep 17 00:00:00 2001 From: Casper S Date: Wed, 21 Dec 2022 20:09:57 +0100 Subject: [PATCH] Fixed issue #1, slightly simplified IsUpdateCheckEnabled, removed unnecessary replace --- App.config | 6 ++--- Properties/AssemblyInfo.cs | 4 +-- Properties/Resources.Designer.cs | 44 +++++++++++++------------------- Properties/Settings.Designer.cs | 22 +++++++--------- TidalRPC.csproj | 5 +++- UpdateManager.cs | 29 ++++++++++++--------- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/App.config b/App.config index 56efbc7..4bfa005 100644 --- a/App.config +++ b/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 9f0f991..3cf7ab1 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.2.3")] -[assembly: AssemblyFileVersion("1.1.2.3")] +[assembly: AssemblyVersion("1.1.3.4")] +[assembly: AssemblyFileVersion("1.1.3.4")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 4f6a484..d7a68a6 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace TidalRPC.Properties -{ - - +namespace TidalRPC.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,51 +19,43 @@ namespace TidalRPC.Properties // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TidalRPC.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 33ce7d5..1f3fd60 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace TidalRPC.Properties -{ - - +namespace TidalRPC.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/TidalRPC.csproj b/TidalRPC.csproj index ee6f1a6..9ff45ce 100644 --- a/TidalRPC.csproj +++ b/TidalRPC.csproj @@ -8,7 +8,7 @@ WinExe TidalRPC TidalRPC - v4.7.2 + v4.8 512 true true @@ -27,6 +27,8 @@ 1.0.0.%2a false true + + latest AnyCPU @@ -85,6 +87,7 @@ True Resources.resx + True diff --git a/UpdateManager.cs b/UpdateManager.cs index 62cdadc..70b9618 100644 --- a/UpdateManager.cs +++ b/UpdateManager.cs @@ -11,7 +11,8 @@ namespace TidalRPC { public static class UpdateManager { - static bool updateDenied = false; + private static bool updateDenied = false; + private static bool updatePrompted = false; // Method for checking if update checking is enabled public static bool IsUpdateCheckEnabled() @@ -19,16 +20,15 @@ public static bool IsUpdateCheckEnabled() string keyName = "SOFTWARE\\TidalRPC\\Settings"; string valueName = "CheckForUpdates"; - using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName)) - { - if (key == null) - { - ToggleUpdateCheck(true); - return true; - } + using RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName); - return (int)key.GetValue(valueName, 0) != 0; + if (key == null) + { + ToggleUpdateCheck(true); + return true; } + + return (int)key.GetValue(valueName, 0) != 0; } // Method for toggling update checking @@ -58,7 +58,7 @@ public static async Task CheckForUpdates() while (!updateDenied) { - if (!IsUpdateCheckEnabled()) return; + if (!IsUpdateCheckEnabled() || updatePrompted) return; // Fetch the latest release information from the GitHub API HttpResponseMessage response = await client.GetAsync("https://api.github.com/repos/BitesizedLion/TidalRPC/releases/latest"); @@ -66,8 +66,9 @@ public static async Task CheckForUpdates() if (response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); - dynamic release = JsonConvert.DeserializeObject(json); - Version latestVersion = new Version(((string)release.tag_name).Replace("v", "")); + dynamic release = JsonConvert.DeserializeObject(json); // i know this is bad, it will be improved later + + Version latestVersion = new Version(((string)release.tag_name)); // Compare the version numbers if (latestVersion > currentVersion) @@ -75,14 +76,18 @@ public static async Task CheckForUpdates() // Prompt the user to update DialogResult result = MessageBox.Show("A new version of the software is available. Do you want to download it?", "Update Available", MessageBoxButtons.YesNo); + updatePrompted = true; + switch (result) { case DialogResult.Yes: Process.Start((string)release.html_url); // Open the download URL in the default web browser + updatePrompted = false; break; case DialogResult.No: updateDenied = true; + updatePrompted = false; break; }