fix(app): store and close the editor before its sequence moves to the trash
Delete first lets the editor of a sequence it moves store its last edit and close (or stops when the user keeps an edit that cannot be stored), and reports a sidecar written by a newer Titano instead of failing. A remote card whose proxy download ended before it was recorded opens at once, as on the Server screen; the Library reads its saved views again on refresh; the CSV writer of the Library and the Archive manager moves into LibraryCsv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
4 files changed
+70
-41
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Shell;
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Data;
|
||||
@@ -27,7 +28,7 @@ public static class SequenceDeletion
|
||||
shell.Notify(Loc.L("Archive.Delete.Nothing"), string.Join(Environment.NewLine, DeletePlans.Blocked(plan, DeletePlans.ListedLines)));
|
||||
return false;
|
||||
}
|
||||
if (!shell.Services.Dialogs.Confirm(request)) return false;
|
||||
if (!shell.Services.Dialogs.Confirm(request) || !await CloseEditorAsync(shell, plan)) return false;
|
||||
var entries = await Task.Run(() => archives.DeleteAsync(plan, Environment.UserName));
|
||||
Log.Info("archive", $"{entries.Count} sequence(s) moved to the trash, {plan.Steps.Count - entries.Count} removed from the index only");
|
||||
await RefreshAsync(shell);
|
||||
@@ -36,8 +37,8 @@ public static class SequenceDeletion
|
||||
entries.Count == 0 ? null : () => _ = RestoreAsync(shell, entries));
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or StaleDeletePlanException or ArgumentException
|
||||
or DatabaseException)
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or StaleDeletePlanException or NewerFormatException
|
||||
or ArgumentException or DatabaseException)
|
||||
{
|
||||
Log.Warning("archive", "Delete failed", ex);
|
||||
shell.Notify(Loc.L("Archive.Delete.Failed"), ex.Message);
|
||||
@@ -69,6 +70,18 @@ public static class SequenceDeletion
|
||||
await RefreshAsync(shell);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The editor of a sequence about to move stores its last edit (so the trash keeps it) and closes; false when that
|
||||
/// edit could not be stored and the user kept it.
|
||||
/// </summary>
|
||||
private static async Task<bool> CloseEditorAsync(ShellViewModel shell, DeletePlan plan)
|
||||
{
|
||||
if (shell.Sequence.Editor is null || shell.CurrentSequenceId is not { } open || plan.Steps.All(s => s.Sequence.Id != open)) return true;
|
||||
if (!await shell.Sequence.ConfirmCloseAsync()) return false;
|
||||
await shell.Sequence.CloseAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static async Task RefreshAsync(ShellViewModel shell)
|
||||
{
|
||||
await shell.Library.RefreshAsync();
|
||||
|
||||
Reference in new issue
Block a user