Skip to content

Commit

Permalink
Updated forum thread validation, added notification for trade setting…
Browse files Browse the repository at this point in the history
…s save
  • Loading branch information
Stickymaddness committed Aug 23, 2014
1 parent 9dc7f50 commit 06f6062
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion POEApi.Model/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static void updateLists()
}
}

public static void SaveShopSettings()
public static bool SaveShopSettings()
{
try
{
Expand All @@ -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;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Procurement/ViewModel/ForumExportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -138,15 +138,15 @@ 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))
{
MessageBox.Show("No shop settings found for current league, please configure your ThreadId and ThreadTitle under the TradeSettings tab", "Settings not found!", MessageBoxButton.OK, MessageBoxImage.Error);
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;
Expand Down
6 changes: 5 additions & 1 deletion Procurement/ViewModel/TradeSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 06f6062

Please sign in to comment.