mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Plugins - Don't load incompatible plugins
This commit is contained in:
1 parent
dc17253518
commit
73a80ef476
4 files changed
+23
-11
No files matched your search
@@ -13,7 +13,7 @@ namespace Artemis.UI.Screens.Plugins;
|
||||
|
||||
public class PluginSettingsViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private readonly Plugin _plugin;
|
||||
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly INotificationService _notificationService;
|
||||
@@ -41,10 +41,13 @@ public class PluginSettingsViewModel : ActivatableViewModelBase
|
||||
bool wasEnabled = _plugin.IsEnabled;
|
||||
await Task.Run(() => _pluginManagementService.UnloadPlugin(_plugin));
|
||||
|
||||
_plugin = _pluginManagementService.LoadPlugin(_plugin.Directory);
|
||||
if (wasEnabled)
|
||||
await Task.Run(() => _pluginManagementService.EnablePlugin(_plugin, true, true));
|
||||
|
||||
_notificationService.CreateNotification().WithTitle("Reloaded plugin.").Show();
|
||||
Plugin? plugin = _pluginManagementService.LoadPlugin(_plugin.Directory);
|
||||
if (plugin != null && wasEnabled)
|
||||
{
|
||||
await Task.Run(() => _pluginManagementService.EnablePlugin(plugin, true, true));
|
||||
_notificationService.CreateNotification().WithTitle("Reloaded plugin.").Show();
|
||||
}
|
||||
else if (plugin == null)
|
||||
_notificationService.CreateNotification().WithTitle("Failed to load plugin after unloading it.").Show();
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,13 @@ namespace Artemis.UI.Screens.Settings
|
||||
|
||||
try
|
||||
{
|
||||
Plugin plugin = _pluginManagementService.ImportPlugin(files[0]);
|
||||
Plugin? plugin = _pluginManagementService.ImportPlugin(files[0]);
|
||||
if (plugin == null)
|
||||
{
|
||||
await _windowService.ShowConfirmContentDialog("Failed to import plugin", "Make sure it is compatible with the current platform.", "Close", null);
|
||||
return;
|
||||
}
|
||||
|
||||
SearchPluginInput = plugin.Info.Name;
|
||||
|
||||
// Wait for the VM to be created asynchronously (it would be better to respond to some event here)
|
||||
|
||||
Reference in new issue
Block a user