Fix some issues with plugin updating

This commit is contained in:
Ceikry 2025-06-06 17:32:09 -05:00
parent e88ac062d1
commit 656c4727cf
3 changed files with 27 additions and 6 deletions

View file

@ -153,9 +153,8 @@ namespace Saradomin.Infrastructure.Services
if (isUpdateCheck && updatedInfo.Version != info.Version)
{
if (writePersistentUpdateFlag)
await File.WriteAllTextAsync(filePath, fileContent + "\r\nUPDATEAVAILABLE=1");
info.UpdateAvailable = true;
if (writePersistentUpdateFlag) WritePluginInfoToFile(info, pluginFolder);
}
info.Installed = File.Exists(Path.Combine(pluginFolder, "plugin.class"));
@ -170,6 +169,7 @@ namespace Saradomin.Infrastructure.Services
foreach (var lineInfo in lines.Select(t => t.Split("=")))
{
if (parsedData.ContainsKey(lineInfo[0])) continue;
if (lineInfo.Length > 1)
{
parsedData.Add (lineInfo[0], lineInfo[1].Trim('\'').Trim());
@ -203,5 +203,18 @@ namespace Saradomin.Infrastructure.Services
return info;
}
public static void WritePluginInfoToFile(PluginInfo info, string pluginFolder)
{
var content = $"NAME={info.Name}\r\n" +
$"AUTHOR={info.Author}\r\n" +
$"DESCRIPTION={info.Description.Replace(System.Environment.NewLine, "\\\r\n")}\r\n" +
$"VERSION={info.Version}";
if (info.UpdateAvailable)
content += "\r\nUPDATEAVAILABLE=1";
File.WriteAllText(Path.Combine(pluginFolder, "plugin.properties"), content);
}
}
}

View file

@ -83,6 +83,7 @@
BorderThickness="1"
Classes="OutsideNavigator"
Command="{Binding $parent[local:PluginManagerView].DataContext.UpdateLocalPlugin}"
CommandParameter="{Binding}"
VerticalAlignment="Top"
Content="Update"
IsVisible="{Binding CanUpdate}" />
@ -100,8 +101,14 @@
Command="{Binding $parent[local:PluginManagerView].DataContext.UninstallLocalPlugin}"
CommandParameter="{Binding}"
VerticalAlignment="Top"
Content="Uninstall"
IsVisible="{Binding Installed}" />
Content="Uninstall">
<Button.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="!CanUpdate" />
<Binding Path="Installed" />
</MultiBinding>
</Button.IsVisible>
</Button>
</Grid>
</Grid>
</DataTemplate>

View file

@ -4,12 +4,13 @@
xmlns:glitonea="clr-namespace:Glitonea.Controls;assembly=Glitonea"
xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea"
xmlns:windows="clr-namespace:Saradomin.ViewModel.Windows"
xmlns:windows1="clr-namespace:Saradomin.View.Windows"
Title="{Binding Title}"
Height="120"
MaxWidth="400"
Background="{StaticResource WindowBackgroundBrush}"
CanResize="False"
DataContext="{Binding #NotificationBox}"
DataContext="{mvvm:DataContextSource windows1:NotificationBox}"
ShowActivated="True"
ShowInTaskbar="False"
SizeToContent="WidthAndHeight"
@ -25,7 +26,7 @@
FontSize="14"
FontWeight="Light"
Foreground="{StaticResource AccentBrush}"
Text="{Binding #NotificationBox.Title}"
Text="{Binding Title}"
TextAlignment="Center">
</TextBlock>
</Grid>