From 7bb246ea0bcc04af50c578e6c9c57e99f3166c30 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 25 Jun 2020 19:46:27 +0200 Subject: [PATCH] Snackbar - Tweaked parameters Plugins - Show exception message in snackbar --- src/Artemis.UI.Shared/Ninject/SharedUIModule.cs | 2 +- src/Artemis.UI/Screens/RootView.xaml | 2 +- .../Tabs/Plugins/PluginSettingsView.xaml | 13 +++++++++---- .../Tabs/Plugins/PluginSettingsViewModel.cs | 17 +++++++++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Artemis.UI.Shared/Ninject/SharedUIModule.cs b/src/Artemis.UI.Shared/Ninject/SharedUIModule.cs index 9e80aea2f..4621065a0 100644 --- a/src/Artemis.UI.Shared/Ninject/SharedUIModule.cs +++ b/src/Artemis.UI.Shared/Ninject/SharedUIModule.cs @@ -34,7 +34,7 @@ namespace Artemis.UI.Shared.Ninject .Configure(c => c.InSingletonScope()); }); - Kernel.Bind().ToConstant(new SnackbarMessageQueue()).InSingletonScope(); + Kernel.Bind().ToConstant(new SnackbarMessageQueue(TimeSpan.FromSeconds(5))).InSingletonScope(); } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/RootView.xaml b/src/Artemis.UI/Screens/RootView.xaml index 72bb1b592..592a434e3 100644 --- a/src/Artemis.UI/Screens/RootView.xaml +++ b/src/Artemis.UI/Screens/RootView.xaml @@ -70,7 +70,7 @@ - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsView.xaml b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsView.xaml index 21cf53303..660c10170 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsView.xaml +++ b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsView.xaml @@ -36,7 +36,7 @@ - + @@ -45,9 +45,14 @@ - - + + LOAD FAILED diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs index 36f3571a0..d4d90bd48 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs @@ -47,6 +47,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins public bool Enabling { get; set; } + public bool DisplayLoadFailed => !Enabling && !PluginInfo.LastEnableSuccessful; + public async Task OpenSettings() { try @@ -106,7 +108,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins { if (PluginInfo.Enabled == enable) { - NotifyOfPropertyChange(() => IsEnabled); + NotifyOfPropertyChange(nameof(IsEnabled)); return; } @@ -118,7 +120,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins ); if (!confirm) { - NotifyOfPropertyChange(() => IsEnabled); + NotifyOfPropertyChange(nameof(IsEnabled)); return; } } @@ -126,25 +128,28 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins if (enable) { Enabling = true; + NotifyOfPropertyChange(nameof(DisplayLoadFailed)); + try { _pluginService.EnablePlugin(Plugin); _snackbarMessageQueue.Enqueue($"Enabled plugin {PluginInfo.Name}"); } - catch (Exception) + catch (Exception e) { - _snackbarMessageQueue.Enqueue($"Failed to enable plugin {PluginInfo.Name}", "VIEW LOGS", async () => await ShowLogsFolder()); + _snackbarMessageQueue.Enqueue($"Failed to enable plugin {PluginInfo.Name}\r\n{e.Message}", "VIEW LOGS", async () => await ShowLogsFolder()); } finally { Enabling = false; - NotifyOfPropertyChange(() => IsEnabled); + NotifyOfPropertyChange(nameof(IsEnabled)); + NotifyOfPropertyChange(nameof(DisplayLoadFailed)); } } else _pluginService.DisablePlugin(Plugin); - NotifyOfPropertyChange(() => IsEnabled); + NotifyOfPropertyChange(nameof(IsEnabled)); } } } \ No newline at end of file