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:
Claude committed 2026-10-03 16:44:03 +00:00
1 parent fb0d8cceae
commit 743418d944
4 files changed
+70 -41

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
using System.Globalization;
using System.Text;
using Titano.Core.Model;
namespace Titano.App.Library;
/// <summary>The Library's "Export list as CSV" (BRIEF §12.2): RFC 4180, UTF-8, invariant numbers and dates.</summary>
public static class LibraryCsv
{
/// <summary>One row per sequence; the header is English because the file is data, not UI.</summary>
public static string Write(IEnumerable<Sequence> sequences)
{
var inv = CultureInfo.InvariantCulture;
var sb = new StringBuilder("title,first_capture,last_capture,camera_make,camera_model,frames,bytes,folder,tags,origin\r\n");
foreach (var s in sequences)
{
sb.Append(Field(s.DisplayTitle)).Append(',')
.Append(s.FirstCapture?.ToString("yyyy-MM-dd HH:mm:ss", inv)).Append(',')
.Append(s.LastCapture?.ToString("yyyy-MM-dd HH:mm:ss", inv)).Append(',')
.Append(Field(s.CameraMake)).Append(',')
.Append(Field(s.CameraModel)).Append(',')
.Append(s.FrameCount.ToString(inv)).Append(',')
.Append(s.TotalBytes.ToString(inv)).Append(',')
.Append(Field(s.Folder)).Append(',')
.Append(Field(string.Join(';', s.Tags))).Append(',')
.Append(s is { Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly } ? "server" : "local").Append("\r\n");
}
return sb.ToString();
}
private static string Field(string? value)
{
if (string.IsNullOrEmpty(value)) return string.Empty;
// Formula-looking values are prefixed so spreadsheets do not execute them.
if (value[0] is '=' or '+' or '-' or '@') value = "'" + value;
return value.IndexOfAny([',', '"', '\r', '\n']) >= 0 ? "\"" + value.Replace("\"", "\"\"", StringComparison.Ordinal) + "\"" : value;
}
}