From 06f6062dff8d82842414f10d10d89fa658f03894 Mon Sep 17 00:00:00 2001 From: Stickymaddness Date: Sun, 24 Aug 2014 01:46:04 +0200 Subject: [PATCH] Updated forum thread validation, added notification for trade settings save --- POEApi.Model/Settings.cs | 4 +++- Procurement/ViewModel/ForumExportViewModel.cs | 8 ++++---- Procurement/ViewModel/TradeSettingsViewModel.cs | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/POEApi.Model/Settings.cs b/POEApi.Model/Settings.cs index ae4882c5..1f5dd7de 100644 --- a/POEApi.Model/Settings.cs +++ b/POEApi.Model/Settings.cs @@ -194,7 +194,7 @@ private static void updateLists() } } - public static void SaveShopSettings() + public static bool SaveShopSettings() { try { @@ -210,10 +210,12 @@ public static void SaveShopSettings() } settingsFile.Save(SAVE_LOCATION); + return true; } catch (Exception ex) { Logger.Log("Unable to save shop settings: " + ex.ToString()); + return false; } } } diff --git a/Procurement/ViewModel/ForumExportViewModel.cs b/Procurement/ViewModel/ForumExportViewModel.cs index 581cad14..1dfa4572 100644 --- a/Procurement/ViewModel/ForumExportViewModel.cs +++ b/Procurement/ViewModel/ForumExportViewModel.cs @@ -101,7 +101,7 @@ public ForumExportViewModel() private void bumpThread(object obj) { - if (!settingsValid()) + if (!settingsValid(false)) return; var confirmation = MessageBox.Show("Are you sure you want to bump your thread? By clicking yes you grant permission for Procurement to bump your forum thread using the account you logged in with, and confirm that you are only bumping within the allowed time interval as per forum rules.", "Confirm shop update", MessageBoxButton.YesNo, MessageBoxImage.Question); @@ -119,7 +119,7 @@ private void bumpThread(object obj) private void postToThread(object obj) { - if (!settingsValid()) + if (!settingsValid(true)) return; var confirmation = MessageBox.Show("Are you sure you want to update your shop? By clicking yes you grant permission for Procurement to update your forum thread using the account you logged in with.", "Confirm shop update", MessageBoxButton.YesNo, MessageBoxImage.Question); @@ -138,7 +138,7 @@ private void postToThread(object obj) MessageBox.Show("Error updating shop, details logged to debuginfo.log", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } - private bool settingsValid() + private bool settingsValid(bool isUpdate) { if (!Settings.ShopSettings.ContainsKey(ApplicationState.CurrentLeague) || string.IsNullOrEmpty(Settings.ShopSettings[ApplicationState.CurrentLeague].ThreadId) || string.IsNullOrEmpty(Settings.ShopSettings[ApplicationState.CurrentLeague].ThreadTitle)) { @@ -146,7 +146,7 @@ private bool settingsValid() return false; } - if (selected.Count() == 0) + if (isUpdate && selected.Count() == 0) { MessageBox.Show("You need to select at least one tab to update your shop!", "No tabs selected", MessageBoxButton.OK, MessageBoxImage.Warning); return false; diff --git a/Procurement/ViewModel/TradeSettingsViewModel.cs b/Procurement/ViewModel/TradeSettingsViewModel.cs index d1ffc1f9..f9de8f94 100644 --- a/Procurement/ViewModel/TradeSettingsViewModel.cs +++ b/Procurement/ViewModel/TradeSettingsViewModel.cs @@ -110,7 +110,11 @@ private void saveShopSettings(object obj) Settings.ShopSettings[ApplicationState.CurrentLeague].ThreadId = this.threadId; Settings.ShopSettings[ApplicationState.CurrentLeague].ThreadTitle = this.threadTitle; - Settings.SaveShopSettings(); + + if (Settings.SaveShopSettings()) + MessageBox.Show("Shop settings saved", "Settings saved", MessageBoxButton.OK, MessageBoxImage.Information); + else + MessageBox.Show("Unable to save shop settings, error logged to debuginfo.log", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } private DelegateCommand saveCommand;