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
@@ -2,7 +2,6 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Archiving;
|
||||
@@ -498,9 +497,10 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
await ReloadAsync();
|
||||
}
|
||||
|
||||
/// <summary>Re-reads filter choices, totals and the server's cards, then the list (after imports, archive changes).</summary>
|
||||
/// <summary>Re-reads saved views, filter choices, totals and the server's cards, then the list (after imports, archive changes).</summary>
|
||||
public async Task RefreshAsync()
|
||||
{
|
||||
await LoadViewsAsync();
|
||||
await RefreshFiltersAsync();
|
||||
await RefreshRemoteAsync(reload: false);
|
||||
await ReloadAsync();
|
||||
@@ -907,13 +907,17 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
}
|
||||
foreach (var item in Items.Where(i => job.TargetIds.Contains(i.Id))) item.IsAnalysing = _analysing.Contains(item.Id);
|
||||
}
|
||||
// A remote card's "Open" waited for this proxy download; it opens if the Library is still in front.
|
||||
var ended = job.State is JobState.Done or JobState.Failed or JobState.Cancelled;
|
||||
if (ended && _openWhenCached.Remove(job.Id, out var remoteId) && job.State == JobState.Done && ReferenceEquals(Shell.Current, this))
|
||||
Shell.OpenSequence(remoteId);
|
||||
OpenWhenCached(job);
|
||||
if (job.State == JobState.Done) _ = RefreshTargetsAsync(job);
|
||||
}
|
||||
|
||||
/// <summary>A remote card's "Open" waited for this proxy download; it opens if the Library is still in front.</summary>
|
||||
private void OpenWhenCached(Job job)
|
||||
{
|
||||
if (job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled) || !_openWhenCached.Remove(job.Id, out var remoteId)) return;
|
||||
if (job.State == JobState.Done && ReferenceEquals(Shell.Current, this)) Shell.OpenSequence(remoteId);
|
||||
}
|
||||
|
||||
/// <summary>A finished job changed some sequences: refresh those rows in place and the totals.</summary>
|
||||
private async Task RefreshTargetsAsync(Job job)
|
||||
{
|
||||
@@ -943,7 +947,10 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
Shell.OpenSequence(item.Id);
|
||||
return;
|
||||
}
|
||||
if (await _actions.OpenRemoteAsync(item.Sequence) is { } job) _openWhenCached[job] = item.Id;
|
||||
if (await _actions.OpenRemoteAsync(item.Sequence) is not { } job) return;
|
||||
_openWhenCached[job] = item.Id;
|
||||
// A download that finished before it was recorded here opens at once.
|
||||
if (_db is not null && await _db.Jobs.GetAsync(job) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } ended) OpenWhenCached(ended);
|
||||
}
|
||||
|
||||
/// <summary>The card's Sync: the transfer or settings exchange its sync row offers; a conflict is settled on the Server screen.</summary>
|
||||
@@ -1064,40 +1071,11 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
var folder = Shell.Services.Dialogs.PickFolder(Loc.L("Library.Export.Title"));
|
||||
if (folder is null) return;
|
||||
var path = Path.Combine(folder, $"Titano sequences {DateTime.Now:yyyy-MM-dd HHmm}.csv");
|
||||
var csv = Csv(chosen);
|
||||
var csv = LibraryCsv.Write(chosen);
|
||||
await Task.Run(() => AtomicFile.WriteAllText(path, csv));
|
||||
Shell.Notify(Loc.L("Library.Export.Done"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
|
||||
}
|
||||
|
||||
/// <summary>RFC 4180 CSV of sequences (header in English: it is a data file).</summary>
|
||||
public static string Csv(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();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Option labels and row texts follow a language switch without reloading.</summary>
|
||||
private void OnCultureChanged(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user