Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG
## COMPASS v1.8.7 (27 May 2025)
## COMPASS v1.8.8 (28 June 2025)

### Fixes
- Fix crashes on commands in context menu when no items are selected.
- Fix potential crash when looking at the change logs in the settings
- Fix a crash when deleting a collection when a file is locked
- Fix an issue where the open collection was copied to the new data location after changing it
## COMPASS v1.8.7 (27 May 2025)

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion Deployment/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "COMPASS"
#define MyAppVersion "1.8.7"
#define MyAppVersion "1.8.8"
#define MyAppPublisher "Paul De Smul"
#define MyAppURL "https://www.compassapp.info"
#define MyAppExeName "COMPASS.exe"
Expand Down
4 changes: 2 additions & 2 deletions src/COMPASS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<PackageReference Include="ScrapySharp" Version="3.0.0" />
<PackageReference Include="Selenium.Support" Version="4.33.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.33.0" />
<PackageReference Include="SharpCompress" Version="0.39.0" />
<PackageReference Include="System.Drawing.Common" Version="9.0.5" />
<PackageReference Include="SharpCompress" Version="0.40.0" />
<PackageReference Include="System.Drawing.Common" Version="9.0.6" />
<PackageReference Include="VirtualizingWrapPanel" Version="2.1.1" />
<PackageReference Include="WpfAnimatedGif" Version="2.0.2" />
<PackageReference Include="ZXing.Net" Version="0.16.10" />
Expand Down
7 changes: 5 additions & 2 deletions src/Models/CodexCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void Save()

try
{
Directory.CreateDirectory(UserFilesPath);
Directory.CreateDirectory(FullDataPath);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -585,6 +585,8 @@ public void DeleteCodex(Codex toDelete)

public void DeleteCodices(IList<Codex> toDelete)
{
if (!toDelete.Any()) return;

Notification deleteWarnNotification = Notification.AreYouSureNotification;
deleteWarnNotification.Body = $"You are about to remove {toDelete.Count} item{(toDelete.Count > 1 ? @"s" : @"")}. " +
$"This cannot be undone. " +
Expand All @@ -604,7 +606,8 @@ public void DeleteCodices(IList<Codex> toDelete)

public void BanishCodices(IList<Codex> toBanish)
{
if (toBanish is null) return;
if (!toBanish.SafeAny()) return;

IEnumerable<string> toBanishPaths = toBanish.Select(codex => codex.Sources.Path);
IEnumerable<string> toBanishURLs = toBanish.Select(codex => codex.Sources.SourceURL);
IEnumerable<string> toBanishStrings = toBanishPaths
Expand Down
2 changes: 1 addition & 1 deletion src/Models/CodexProperties/EnumerableProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override bool HasNewValue(IHasCodexMetadata toEvaluate, IHasCodexMetadata
return true;
}

return !newVal!.SequenceEqual(refVal);
return !newVal.SequenceEqual(refVal);
}
}
}
2 changes: 1 addition & 1 deletion src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// app, or any theme specific resource dictionaries)
)]

[assembly: AssemblyVersion("1.8.7")]
[assembly: AssemblyVersion("1.8.8")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]


2 changes: 2 additions & 0 deletions src/Services/CoverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public static async Task GetCover(Codex codex, ChooseMetaDataViewModel? chooseMe

public static async Task GetCover(List<Codex> codices)
{
if (!codices.Any()) return;

var progressVM = ProgressViewModel.GetInstance();
progressVM.ResetCounter();
progressVM.TotalAmount = codices.Count;
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -172,7 +173,7 @@ public static IEnumerable<T> Flatten<T>(this IEnumerable<T> l, string method = "
}
}

public static bool SafeAny<T>(this IEnumerable<T>? l) => l is not null && l.Any();
public static bool SafeAny<T>([NotNullWhen(true)] this IEnumerable<T>? l) => l is not null && l.Any();
#endregion
}
}
25 changes: 25 additions & 0 deletions src/Tools/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using COMPASS.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace COMPASS.Tools
{
Expand All @@ -16,5 +18,28 @@ public static int GetAvailableID<T>(IEnumerable<T> collection) where T : IHasID
}
return tempID;
}

public static void Retry(int maxAttempts, Action action, int retryDelayMs = 1000, Action<Exception>? onFailedAttempt = null) =>
Retry<Exception>(maxAttempts, action, retryDelayMs, onFailedAttempt);
public static void Retry<T>(int maxAttempts, Action action, int retryDelayMs = 1000, Action<Exception>? onFailedAttempt = null) where T : Exception
{
for (int i = 0; i < maxAttempts; i++)
{
try
{
action();
return;
}
catch (T e) when (i < maxAttempts - 1) //failure in last attempt will not be caught by design
{
onFailedAttempt?.Invoke(e);
if (retryDelayMs > 0)
{
Thread.Sleep(retryDelayMs);
}
}
}
}

}
}
15 changes: 12 additions & 3 deletions src/ViewModels/CodexViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static bool CanOpenCodexOnline(Codex? toOpen)
public RelayCommand<IList> OpenSelectedCodicesCommand => _openSelectedCodicesCommand ??= new(l => OpenSelectedCodices(l?.Cast<Codex>().ToList()));
public static bool OpenSelectedCodices(IList<Codex>? toOpen)
{
if (toOpen is null) return false;
if (!toOpen.SafeAny()) return false;

if (toOpen.Count == 1)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ public static void EditCodex(Codex? toEdit)
public static void EditCodices(IList? toEdit)
{
List<Codex>? toEditList = toEdit?.Cast<Codex>().ToList();
if (toEditList is null) return;
if (!toEditList.SafeAny()) return;

if (toEditList.Count == 1)
{
Expand Down Expand Up @@ -186,7 +186,8 @@ public static void FavoriteCodex(Codex? toFavorite)
private static void FavoriteCodices(IList? toFavorite)
{
List<Codex>? toFavoriteList = toFavorite?.Cast<Codex>().ToList();
if (toFavoriteList is null) return;
if (!toFavoriteList.SafeAny()) return;

if (toFavoriteList.Count == 1)
{
FavoriteCodex(toFavoriteList.First());
Expand Down Expand Up @@ -247,6 +248,8 @@ public void MoveToCollection(object[]? par)
/// <param name="toMoveList"></param>
public static void MoveToCollection(CodexCollection targetCollection, List<Codex> toMoveList)
{
if (!toMoveList.Any()) return;

//Check if target Collection is valid
if (targetCollection.DirectoryName == MainViewModel.CollectionVM.CurrentCollection.DirectoryName)
{
Expand Down Expand Up @@ -324,6 +327,8 @@ public static void DeleteCodex(Codex? toDelete)
public RelayCommand<IList> DeleteCodicesCommand => _deleteCodicesCommand ??= new(DeleteCodices);
public static void DeleteCodices(IList? toDelete)
{
if (toDelete == null || toDelete.Count == 0) return;

MainViewModel.CollectionVM.CurrentCollection.DeleteCodices(toDelete?.Cast<Codex>().ToList() ?? new());
MainViewModel.CollectionVM.FilterVM.ReFilter();
}
Expand All @@ -341,6 +346,8 @@ public static void DeleteCodices(IList? toDelete)
public RelayCommand<IList> BanishCodicesCommand => _banishCodicesCommand ??= new(BanishCodices);
public static void BanishCodices(IList? toBanish)
{
if (toBanish == null || toBanish.Count == 0) return;

MainViewModel.CollectionVM.CurrentCollection.BanishCodices(toBanish?.Cast<Codex>().ToList() ?? new());
DeleteCodices(toBanish);
}
Expand All @@ -362,6 +369,8 @@ public static async Task StartGetMetaDataProcess(Codex? codex)
}
public static async Task StartGetMetaDataProcess(IList<Codex> codices)
{
if (!codices.Any()) return;

var progressVM = ProgressViewModel.GetInstance();
progressVM.ResetCounter();
progressVM.Text = "Getting MetaData";
Expand Down
15 changes: 13 additions & 2 deletions src/ViewModels/CollectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,20 @@ public void DeleteCollection(CodexCollection toDelete)

//if Dir name of toDelete is empty, it will delete the entire collections folder
if (String.IsNullOrEmpty(toDelete.DirectoryName)) return;
if (Directory.Exists(toDelete.FullDataPath)) //does not exist if collection was never saved

//possible that folder does not exist if collection was never saved
if (!Directory.Exists(toDelete.FullDataPath)) return;

try
{
//sometimes delete fails because a file is locked, retry could help with that
Utils.Retry<IOException>(3, () => Directory.Delete(toDelete.FullDataPath, true),
onFailedAttempt: (ex) => Logger.Warn($"Failed to delete collection {toDelete.DirectoryName}, retrying...", ex)
);
}
catch (Exception ex)
{
Directory.Delete(toDelete.FullDataPath, true);
Logger.Error($"Failed to delete collection {toDelete.DirectoryName}", ex);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ private void InitConnectionTimer()

#region Properties

public static bool SaveOnClose { get; set; } = true;

private bool _isOnline;
public bool IsOnline
{
Expand Down
6 changes: 6 additions & 0 deletions src/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,19 @@ private async Task CopyToNewDataPath()
/// </summary>
public void ChangeToNewDataPath()
{
//save stuff in old location
MainViewModel.CollectionVM?.CurrentCollection.Save();
PreferencesService.GetInstance().SavePreferences();

//change location
CompassDataPath = NewDataPath;

Notification changeSuccessful = new("Data path changed succesfully", $"Data path was successfully changed to {CompassDataPath}. COMPASS will now restart.");
App.Container.ResolveKeyed<INotificationService>(NotificationDisplayType.Windowed).Show(changeSuccessful);

//Now that datapath has been changed, don't save on close because it would save to new location
MainViewModel.SaveOnClose = false;

//Restart COMPASS
var currentExecutablePath = Environment.ProcessPath;
var args = Environment.GetCommandLineArgs();
Expand Down
7 changes: 5 additions & 2 deletions src/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ public MainWindow()
private void Window_Closing(object sender, CancelEventArgs e)
{
ProgressViewModel.GetInstance().CancelBackgroundTask();
MainViewModel.CollectionVM?.CurrentCollection.Save();
PreferencesService.GetInstance().SavePreferences();
if (MainViewModel.SaveOnClose)
{
MainViewModel.CollectionVM?.CurrentCollection.Save();
PreferencesService.GetInstance().SavePreferences();
}
}

#region Window management
Expand Down
34 changes: 22 additions & 12 deletions src/Windows/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using COMPASS.Models;
using COMPASS.Services;
using COMPASS.Tools;
using COMPASS.ViewModels;
using Microsoft.Web.WebView2.Core;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -47,19 +49,27 @@ private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.

public async void LoadChangeLog()
{
string sHTML = "<!DOCTYPE html>" +
"<html>" +
"<head>" +
"<meta charset=\"utf-8\" />" +
"<title>Changelog</title>" +
"</head>" +
"<body>" +
"<script src=\"https://emgithub.com/embed-v2.js?target=https%3A%2F%2Fgithub.com%2FDSPaul%2FCOMPASS%2Fblob%2Fmaster%2FChangelog.md&style=a11y-dark&type=markdown&showFullPath=on\"></script>" +
"</body>" +
"</html>";
try
{
string sHTML = "<!DOCTYPE html>" +
"<html>" +
"<head>" +
"<meta charset=\"utf-8\" />" +
"<title>Changelog</title>" +
"</head>" +
"<body>" +
"<script src=\"https://emgithub.com/embed-v2.js?target=https%3A%2F%2Fgithub.com%2FDSPaul%2FCOMPASS%2Fblob%2Fmaster%2FChangelog.md&style=a11y-dark&type=markdown&showFullPath=on\"></script>" +
"</body>" +
"</html>";

await ChangelogWebView.EnsureCoreWebView2Async(await CoreWebView2Environment.CreateAsync(userDataFolder: VM.WebViewDataDir));
ChangelogWebView.NavigateToString(sHTML);
var environment = await CoreWebView2Environment.CreateAsync(userDataFolder: VM.WebViewDataDir);
await ChangelogWebView.EnsureCoreWebView2Async(environment);
ChangelogWebView.NavigateToString(sHTML);
}
catch (Exception ex)
{
Logger.Error("failed to load changelog", ex);
}
}

private void SelectFolderForFolderTagPairButton_Click(object sender, RoutedEventArgs e) => NewFolderTagPairTextBox.Text = IOService.PickFolder();
Expand Down
4 changes: 2 additions & 2 deletions versionInfo.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.8.7</version>
<url>https://github.com/DSPAUL/COMPASS/releases/download/v1.8.7/COMPASS_Setup_1.8.7.exe</url>
<version>1.8.8</version>
<url>https://github.com/DSPAUL/COMPASS/releases/download/v1.8.8/COMPASS_Setup_1.8.8.exe</url>
<mandatory>false</mandatory>
</item>