Skip to content

Commit

Permalink
Break plugin manifest compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
KimihikoAkayasaki committed Nov 16, 2024
1 parent 2d27aec commit c6de6fe
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Amethyst/Classes/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ namespace Amethyst.Classes;
public class AppSettings : INotifyPropertyChanged
{
// Disabled (by the user) plugins set
public readonly SortedSet<string> DisabledPluginsGuidSet = [];
public readonly SortedSet<string> DisabledPluginsGuidSet =
[
"K2VRTEAM-AME2-APII-SNDP-SENDPTOVREMU"
];

// App sounds' volume and *nice* is the default
private uint _appSoundsVolume = 69; // Always 0<x<100
Expand Down
2 changes: 1 addition & 1 deletion Amethyst/MVVM/PluginHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public async Task CheckUpdates()

// Parse the received manifest
var remoteVersion = new Version(manifest["version"]?.ToString() ?? Version.ToString());
UpdateData = (Version.CompareTo(remoteVersion) < 0, manifest["download"]?.ToString(),
UpdateData = (Version.CompareTo(remoteVersion) < 0, manifest["download_"]?.ToString(),
remoteVersion, manifest["changelog"]?.ToString());

// Try downloading the update if found
Expand Down
2 changes: 1 addition & 1 deletion Amethyst/MVVM/StorePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public async void FetchPluginData()
DisplayName = manifest["display_name"]?.ToString(),

Download = release["assets"]?.Children().FirstOrDefault(
x => x["name"]?.ToString() == manifest["download"]?.ToString(), null)?
x => x["name"]?.ToString() == manifest["download_"]?.ToString(), null)?
["browser_download_url"]?.ToString()
};

Expand Down
32 changes: 29 additions & 3 deletions Amethyst/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private async Task SetupMainWindow()
// Chad Windows 11
Shared.Main.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
Shared.Main.AppWindow.TitleBar.SetDragRectangles([
new(0, 0, 10000000, 30)
new RectInt32(0, 0, 10000000, 30)
]);

Shared.Main.AppWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent;
Expand Down Expand Up @@ -282,7 +282,8 @@ private async Task SetupMainWindow()

// Check the plugin GUID against others loaded, INVALID and null
if (string.IsNullOrEmpty(plugin.Metadata.Guid) || plugin.Metadata.Guid == "INVALID" ||
AppPlugins.TrackingDevicesList.ContainsKey(plugin.Metadata.Guid))
(AppPlugins.TrackingDevicesList.TryGetValue(plugin.Metadata.Guid, out var alreadyExistingDevice) &&
alreadyExistingDevice.Version >= new Version(plugin.Metadata.Version)))
{
// Add the device to the 'attempted' list, mark as duplicate
AppPlugins.LoadAttemptedPluginsList.Add(new LoadAttemptedPlugin
Expand Down Expand Up @@ -397,6 +398,18 @@ private async Task SetupMainWindow()
// Add the device to the global device list, add the plugin folder path
Logger.Info($"Adding ({plugin.Metadata.Name}, {plugin.Metadata.Guid}) " +
"to the global tracking device plugins list (AppPlugins)...");

if (AppPlugins.TrackingDevicesList.TryGetValue(plugin.Metadata.Guid, out var existingDevice) &&
existingDevice.Version < new Version(plugin.Metadata.Version))
{
Logger.Info($"There is a ({plugin.Metadata.Name}, {plugin.Metadata.Guid}) " +
$"loaded from \"{existingDevice.Location}\"" +
"already in the tracking device plugins list (AppPlugins)! " +
"However, it's version is lower - replacing it with the newer one...");

AppPlugins.TrackingDevicesList.Remove(plugin.Metadata.Guid); // Remove
}

AppPlugins.TrackingDevicesList.Add(plugin.Metadata.Guid, new TrackingDevice(
plugin.Metadata.Name, plugin.Metadata.Guid, pluginLocation,
new Version(plugin.Metadata.Version), plugin.Value)
Expand Down Expand Up @@ -503,7 +516,8 @@ private async Task SetupMainWindow()

// Check the plugin GUID against others loaded, INVALID and null
if (string.IsNullOrEmpty(plugin.Metadata.Guid) || plugin.Metadata.Guid == "INVALID" ||
AppPlugins.ServiceEndpointsList.ContainsKey(plugin.Metadata.Guid))
(AppPlugins.ServiceEndpointsList.TryGetValue(plugin.Metadata.Guid, out var alreadyExistingService) &&
alreadyExistingService.Version >= new Version(plugin.Metadata.Version)))
{
// Add the device to the 'attempted' list, mark as duplicate
AppPlugins.LoadAttemptedPluginsList.Add(new LoadAttemptedPlugin
Expand Down Expand Up @@ -602,6 +616,18 @@ private async Task SetupMainWindow()
// Add the device to the global device list, add the plugin folder path
Logger.Info($"Adding ({plugin.Metadata.Name}, {plugin.Metadata.Guid}) " +
"to the global service endpoints plugins list (AppPlugins)...");

if (AppPlugins.ServiceEndpointsList.TryGetValue(plugin.Metadata.Guid, out var existingDevice) &&
existingDevice.Version < new Version(plugin.Metadata.Version))
{
Logger.Info($"There is a ({plugin.Metadata.Name}, {plugin.Metadata.Guid}) " +
$"loaded from \"{existingDevice.Location}\"" +
"already in the service endpoints plugins list (AppPlugins)! " +
"However, it's version is lower - replacing it with the newer one...");

AppPlugins.ServiceEndpointsList.Remove(plugin.Metadata.Guid); // Remove
}

AppPlugins.ServiceEndpointsList.Add(plugin.Metadata.Guid, new ServiceEndpoint(
plugin.Metadata.Name, plugin.Metadata.Guid, pluginLocation,
new Version(plugin.Metadata.Version), plugin.Value)
Expand Down

0 comments on commit c6de6fe

Please sign in to comment.