From 170466686cde0d208b8a333558b2dfd4e8ded388 Mon Sep 17 00:00:00 2001 From: jliddev Date: Sat, 19 Sep 2020 09:14:29 -0500 Subject: [PATCH] Add auto update default settings to all the clients. #50 #19 --- WowUp.WPF/Assets/changelog.json | 2 +- WowUp.WPF/Constants.cs | 1 + WowUp.WPF/Services/AddonService.cs | 3 +- WowUp.WPF/Services/Contracts/IWowUpService.cs | 3 + WowUp.WPF/Services/WowUpService.cs | 26 +++++++ WowUp.WPF/ViewModels/OptionsViewModel.cs | 61 +++++++++++++++++ WowUp.WPF/Views/OptionsView.xaml | 67 ++++++++++++++++--- WowUp.WPF/WowUp.WPF.csproj | 2 +- 8 files changed, 154 insertions(+), 11 deletions(-) diff --git a/WowUp.WPF/Assets/changelog.json b/WowUp.WPF/Assets/changelog.json index 09ed95e9..085128b0 100644 --- a/WowUp.WPF/Assets/changelog.json +++ b/WowUp.WPF/Assets/changelog.json @@ -2,7 +2,7 @@ "ChangeLogs": [ { "Version": "1.16.1", - "Description": "Default addon channel can now be set separately per World of Warcraft client.\nAttempt to make updating safer with rollback ability.\nContext information added to the bottom screen bar.\nSmall indicator for auto updated addons.\nWhen closing WowUp maximized it should start back up maximized.\nUI updates.\nBug Fixes." + "Description": "Default addon channel can now be set separately per World of Warcraft client.\nAddons can now be set to auto update by default per World of Warcraft client.\nAttempt to make updating safer with rollback ability.\nContext information added to the bottom screen bar.\nSmall indicator for auto updated addons.\nWhen closing WowUp maximized it should start back up maximized.\nUI updates.\nBug Fixes." }, { "Version": "1.16.0", diff --git a/WowUp.WPF/Constants.cs b/WowUp.WPF/Constants.cs index c15e15d5..455c5c86 100644 --- a/WowUp.WPF/Constants.cs +++ b/WowUp.WPF/Constants.cs @@ -5,6 +5,7 @@ public static class Preferences { public const string ClientDefaultAddonChannelSuffix = "_default_addon_channel"; + public const string ClientDefaultAutoUpdateSuffix = "_default_auto_update"; public const string WowUpReleaseChannelKey = "wowup_release_channel"; public const string CollapseToTrayKey = "collapse_to_tray"; public const string LastSelectedClientTypeKey = "last_selected_client_type"; diff --git a/WowUp.WPF/Services/AddonService.cs b/WowUp.WPF/Services/AddonService.cs index 74467aae..ce789a01 100644 --- a/WowUp.WPF/Services/AddonService.cs +++ b/WowUp.WPF/Services/AddonService.cs @@ -577,7 +577,8 @@ namespace WowUp.WPF.Services DownloadUrl = latestFile.DownloadUrl, ExternalUrl = searchResult.ExternalUrl, ProviderName = searchResult.ProviderName, - ChannelType = channelType ?? _wowUpService.GetClientAddonChannelType(clientType) + ChannelType = channelType ?? _wowUpService.GetClientAddonChannelType(clientType), + AutoUpdateEnabled = _wowUpService.GetClientDefaultAutoUpdate(clientType) }; } } diff --git a/WowUp.WPF/Services/Contracts/IWowUpService.cs b/WowUp.WPF/Services/Contracts/IWowUpService.cs index a602e936..e7f017eb 100644 --- a/WowUp.WPF/Services/Contracts/IWowUpService.cs +++ b/WowUp.WPF/Services/Contracts/IWowUpService.cs @@ -38,5 +38,8 @@ namespace WowUp.WPF.Services.Contracts AddonChannelType GetClientAddonChannelType(WowClientType clientType); void SetClientAddonChannelType(WowClientType clientType, AddonChannelType channelType); + + bool GetClientDefaultAutoUpdate(WowClientType clientType); + void SetClientDefaultAutoUpdate(WowClientType clientType, bool autoUpdate); } } diff --git a/WowUp.WPF/Services/WowUpService.cs b/WowUp.WPF/Services/WowUpService.cs index 930c147b..80255806 100644 --- a/WowUp.WPF/Services/WowUpService.cs +++ b/WowUp.WPF/Services/WowUpService.cs @@ -130,6 +130,20 @@ namespace WowUp.WPF.Services SetPreference(Constants.Preferences.LastSelectedClientTypeKey, clientType.ToString()); } + public void SetClientDefaultAutoUpdate(WowClientType clientType, bool autoUpdate) + { + var preferenceKey = GetClientDefaultAutoUpdateKey(clientType); + SetPreference(preferenceKey, autoUpdate.ToString()); + _analyticsService.TrackUserAction("WowUp", $"ClientDefaultAutoUpdate|{clientType}", autoUpdate.ToString()); + } + + public bool GetClientDefaultAutoUpdate(WowClientType clientType) + { + var preferenceKey = GetClientDefaultAutoUpdateKey(clientType); + var preference = _preferenceRepository.FindByKey(preferenceKey); + return bool.Parse(preference.Value); + } + public void SetClientAddonChannelType(WowClientType clientType, AddonChannelType channelType) { var preferenceKey = GetClientDefaultAddonChannelKey(clientType); @@ -345,6 +359,11 @@ namespace WowUp.WPF.Services return $"{clientType}{Constants.Preferences.ClientDefaultAddonChannelSuffix}".ToLower(); } + private string GetClientDefaultAutoUpdateKey(WowClientType clientType) + { + return $"{clientType}{Constants.Preferences.ClientDefaultAutoUpdateSuffix}".ToLower(); + } + private void SetDefaultPreferences() { var pref = _preferenceRepository.FindByKey(Constants.Preferences.CollapseToTrayKey); @@ -377,6 +396,13 @@ namespace WowUp.WPF.Services { SetClientAddonChannelType(clientType, AddonChannelType.Stable); } + + preferenceKey = GetClientDefaultAutoUpdateKey(clientType); + preference = _preferenceRepository.FindByKey(preferenceKey); + if (preference == null) + { + SetClientDefaultAutoUpdate(clientType, false); + } } } diff --git a/WowUp.WPF/ViewModels/OptionsViewModel.cs b/WowUp.WPF/ViewModels/OptionsViewModel.cs index b7695190..93ed9ec2 100644 --- a/WowUp.WPF/ViewModels/OptionsViewModel.cs +++ b/WowUp.WPF/ViewModels/OptionsViewModel.cs @@ -107,6 +107,41 @@ namespace WowUp.WPF.ViewModels set { SetProperty(ref _selectedWowUpReleaseChannelType, value); } } + private bool _retailAutoUpdateAddons; + public bool RetailAutoUpdateAddons + { + get => _retailAutoUpdateAddons; + set { SetProperty(ref _retailAutoUpdateAddons, value); } + } + + private bool _retailPtrAutoUpdateAddons; + public bool RetailPtrAutoUpdateAddons + { + get => _retailPtrAutoUpdateAddons; + set { SetProperty(ref _retailPtrAutoUpdateAddons, value); } + } + + private bool _classicAutoUpdateAddons; + public bool ClassicAutoUpdateAddons + { + get => _classicAutoUpdateAddons; + set { SetProperty(ref _classicAutoUpdateAddons, value); } + } + + private bool _classicPtrAutoUpdateAddons; + public bool ClassicPtrAutoUpdateAddons + { + get => _classicPtrAutoUpdateAddons; + set { SetProperty(ref _classicPtrAutoUpdateAddons, value); } + } + + private bool _betaAutoUpdateAddons; + public bool BetaAutoUpdateAddons + { + get => _betaAutoUpdateAddons; + set { SetProperty(ref _betaAutoUpdateAddons, value); } + } + public Command ShowLogsCommand { get; set; } public Command TelemetryCheckCommand { get; set; } public Command CollapseToTrayCheckCommand { get; set; } @@ -117,12 +152,21 @@ namespace WowUp.WPF.ViewModels public Command RescanFoldersCommand { get; set; } public Command WowUpReleaseChannelChangedCommand { get; set; } public Command DumpDebugDataCommand { get; set; } + + // DEFAULT ADDON CHANNELS public Command RetailAddonChannelChangeCommand { get; set; } public Command RetailPtrAddonChannelChangeCommand { get; set; } public Command ClassicAddonChannelChangeCommand { get; set; } public Command ClassicPtrAddonChannelChangeCommand { get; set; } public Command BetaAddonChannelChangeCommand { get; set; } + // AUTO UPDATE DEFAULTS + public Command RetailAutoUpdateChangeCommand { get; set; } + public Command RetailPtrAutoUpdateChangeCommand { get; set; } + public Command ClassicAutoUpdateChangeCommand { get; set; } + public Command ClassicPtrAutoUpdateChangeCommand { get; set; } + public Command BetaAutoUpdateChangeCommand { get; set; } + public ObservableCollection AddonChannelNames { get; set; } public ObservableCollection WowUpChannelNames { get; set; } @@ -154,6 +198,12 @@ namespace WowUp.WPF.ViewModels ClassicPtrAddonChannelChangeCommand = new Command(() => OnAddonChannelChange(WowClientType.ClassicPtr, SelectedClassicPtrAddonChannelType)); BetaAddonChannelChangeCommand = new Command(() => OnAddonChannelChange(WowClientType.Beta, SelectedBetaAddonChannelType)); + RetailAutoUpdateChangeCommand = new Command(() => OnAddonAutoUpdateChange(WowClientType.Retail, RetailAutoUpdateAddons)); ; + RetailPtrAutoUpdateChangeCommand = new Command(() => OnAddonAutoUpdateChange(WowClientType.RetailPtr, RetailPtrAutoUpdateAddons)); ; + ClassicAutoUpdateChangeCommand = new Command(() => OnAddonAutoUpdateChange(WowClientType.Classic, ClassicAutoUpdateAddons)); ; + ClassicPtrAutoUpdateChangeCommand = new Command(() => OnAddonAutoUpdateChange(WowClientType.ClassicPtr, ClassicPtrAutoUpdateAddons)); ; + BetaAutoUpdateChangeCommand = new Command(() => OnAddonAutoUpdateChange(WowClientType.Beta, BetaAutoUpdateAddons)); ; + AddonChannelNames = new ObservableCollection { AddonChannelType.Stable, @@ -182,6 +232,12 @@ namespace WowUp.WPF.ViewModels SelectedClassicPtrAddonChannelType = _wowUpService.GetClientAddonChannelType(WowClientType.ClassicPtr); SelectedBetaAddonChannelType = _wowUpService.GetClientAddonChannelType(WowClientType.Beta); + RetailAutoUpdateAddons = _wowUpService.GetClientDefaultAutoUpdate(WowClientType.Retail); + RetailPtrAutoUpdateAddons = _wowUpService.GetClientDefaultAutoUpdate(WowClientType.RetailPtr); + ClassicAutoUpdateAddons = _wowUpService.GetClientDefaultAutoUpdate(WowClientType.Classic); + ClassicPtrAutoUpdateAddons = _wowUpService.GetClientDefaultAutoUpdate(WowClientType.ClassicPtr); + BetaAutoUpdateAddons = _wowUpService.GetClientDefaultAutoUpdate(WowClientType.Beta); + WowRetailLocation = _warcraftService.GetClientLocation(WowClientType.Retail); WowRetailPtrLocation = _warcraftService.GetClientLocation(WowClientType.RetailPtr); WowClassicLocation = _warcraftService.GetClientLocation(WowClientType.Classic); @@ -236,6 +292,11 @@ namespace WowUp.WPF.ViewModels _wowUpService.SetClientAddonChannelType(clientType, addonChannelType); } + private void OnAddonAutoUpdateChange(WowClientType clientType, bool autoUpdate) + { + _wowUpService.SetClientDefaultAutoUpdate(clientType, autoUpdate); + } + private void OnWowUpReleaseChannelChange(WowUpReleaseChannelType type) { _wowUpService.SetWowUpReleaseChannel(type); diff --git a/WowUp.WPF/Views/OptionsView.xaml b/WowUp.WPF/Views/OptionsView.xaml index 8d594209..83c1db5b 100644 --- a/WowUp.WPF/Views/OptionsView.xaml +++ b/WowUp.WPF/Views/OptionsView.xaml @@ -35,6 +35,7 @@ + @@ -68,10 +69,11 @@ + - + + + + + + + + @@ -111,10 +122,11 @@ + - + + + + + + + + @@ -154,10 +175,11 @@ + - + + + + + + + + @@ -197,10 +228,11 @@ + - + + + + + + + + @@ -239,10 +280,11 @@ + - + + + + + + + + @@ -276,7 +327,7 @@ - + - + Help improve WowUp by sending anonymous install data and/or errors. - + WowUp Jliddev WowUp - 1.16.1-beta.8 + 1.16.1-beta.9 wowup_logo_512np_RRT_icon.ico jliddev https://wowup.io