fix(app): Library and Archive delete, quick actions and toolbar after review
Delete… runs in an in-window dialog shared by the Library and the Archive manager: the dry run and the move into the trash report progress and stop on Cancel, the toast counts only what really moved, and its Undo reports failures. The confirmation names at most six moves and three refusals in the UI font. Delete… stands apart at the far right of both bars and last in the tab order. The toolbar's filters wrap instead of pushing out the right-hand group at 1200 px. Card and row quick actions show while selected or focused, so Tab reaches them; Analyse and Render are disabled with a reason when nothing can run them, and say so in a toast if the session drops. Remote cards get their own card, Analyse and Render tooltips; the details panel's Folder and the saved-view menu say why they are disabled. Status offers Rendered, Not rendered and Synced. Remote cards count in the Year and Camera choices and the timeline. The trash dialog shows one sentence when empty. --capture adds archive-trash and library-viewname. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
29 files changed
+602
-170
No files matched your search
@@ -63,6 +63,7 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
private IReadOnlyList<Sequence> _remote = [];
|
||||
private Dictionary<Guid, SyncEntry> _entries = [];
|
||||
private Dictionary<Guid, SequenceDto> _listing = [];
|
||||
private ArchiveStats? _localStats;
|
||||
private LibraryTimeline _timeline = LibraryTimeline.Empty;
|
||||
private IReadOnlyList<ChartRow> _timelineBands = [];
|
||||
private (int Year, int Month)? _timelineMonth;
|
||||
@@ -124,7 +125,7 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
MoveCommand = Mass(MassAction.Move, OpenMoveAsync);
|
||||
UploadCommand = Mass(MassAction.Upload, _ => TransferAsync(MassAction.Upload));
|
||||
DownloadCommand = Mass(MassAction.Download, _ => TransferAsync(MassAction.Download));
|
||||
DeleteCommand = Mass(MassAction.Delete, t => SequenceDeletion.RunAsync(Shell, [.. t.Select(s => s.Id)]));
|
||||
DeleteCommand = Mass(MassAction.Delete, t => DeleteAsync([.. t.Select(s => s.Id)]));
|
||||
ExportListCommand = Mass(MassAction.ExportList, ExportListAsync);
|
||||
ClearSelectionCommand = new RelayCommand(ClearSelection, () => SelectionCount > 0);
|
||||
|
||||
@@ -135,13 +136,16 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
else if (p is string name && Enum.TryParse<SequenceSort>(name, out var parsed)) SelectedSort = Sorts.First(o => o.Value == parsed);
|
||||
});
|
||||
OpenItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? OpenAsync(item) : Task.CompletedTask);
|
||||
AnalyseItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? _actions.AnalyseAsync([item.Sequence]) : Task.CompletedTask);
|
||||
RenderItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? _actions.RenderAsync(item.Sequence) : Task.CompletedTask);
|
||||
AnalyseItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? _actions.AnalyseAsync([item.Sequence]) : Task.CompletedTask,
|
||||
p => p is SequenceItem { CanRunQuick: true });
|
||||
RenderItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? _actions.RenderAsync(item.Sequence) : Task.CompletedTask,
|
||||
p => p is SequenceItem { CanRunQuick: true });
|
||||
SyncItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? SyncItemAsync(item) : Task.CompletedTask, p => p is SequenceItem { CanSync: true });
|
||||
|
||||
SaveViewCommand = new RelayCommand(() => OpenViewName(rename: false), () => _viewStore is not null);
|
||||
RenameViewCommand = new RelayCommand(() => OpenViewName(rename: true), () => ActiveView is not null);
|
||||
DeleteViewCommand = new AsyncRelayCommand(DeleteViewAsync, () => ActiveView is not null);
|
||||
UndoDeleteViewCommand = new AsyncRelayCommand((p, _) => p is SavedView view ? UndoDeleteViewAsync(view) : Task.CompletedTask);
|
||||
|
||||
ImportCardCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import));
|
||||
AdoptFolderCommand = new AsyncRelayCommand(AdoptFolderAsync);
|
||||
@@ -182,6 +186,9 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
public ICommand SaveViewCommand { get; }
|
||||
public ICommand RenameViewCommand { get; }
|
||||
public ICommand DeleteViewCommand { get; }
|
||||
|
||||
/// <summary>The Undo of a deleted view's toast (parameter: the view); a failure is reported like any command's.</summary>
|
||||
public ICommand UndoDeleteViewCommand { get; }
|
||||
public ICommand ImportCardCommand { get; }
|
||||
public ICommand AdoptFolderCommand { get; }
|
||||
public ICommand ConnectCommand { get; }
|
||||
@@ -260,10 +267,27 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
set => SetFilter(ref _tag, value ?? Tags[0], nameof(IsTagFiltered));
|
||||
}
|
||||
|
||||
/// <summary>The origin also decides which sequences the Year and Camera choices and the timeline count.</summary>
|
||||
public FilterOption<OriginFilter> SelectedOrigin
|
||||
{
|
||||
get => _origin;
|
||||
set => SetFilter(ref _origin, value ?? Origins[0], nameof(IsOriginFiltered));
|
||||
set
|
||||
{
|
||||
var suppressed = _suppressReload;
|
||||
_suppressReload = true;
|
||||
try
|
||||
{
|
||||
if (!Set(ref _origin, value ?? Origins[0])) return;
|
||||
ApplyFacets();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_suppressReload = suppressed;
|
||||
}
|
||||
OnPropertyChanged(nameof(IsOriginFiltered));
|
||||
RaiseViews();
|
||||
Reload();
|
||||
}
|
||||
}
|
||||
|
||||
public FilterOption<SequenceSort> SelectedSort
|
||||
@@ -332,6 +356,18 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
/// <summary>"Saved views · Night, 4K" or what the menu does.</summary>
|
||||
public string ViewsToolTip => ActiveView is { } active ? Loc.L("Tooltips.Library.ViewsActive", active.Name) : Loc.L("Tooltips.Library.Views");
|
||||
|
||||
/// <summary>"Show view": what it does, or that no view is saved yet.</summary>
|
||||
public string ViewsApplyToolTip => HasViews ? Loc.L("Tooltips.Library.ViewsApply") : Loc.L("Library.Blocked.NoViews");
|
||||
|
||||
/// <summary>"Save view…": what it does, or that the index is not open.</summary>
|
||||
public string ViewSaveToolTip => _viewStore is null ? Loc.L("Library.Blocked.NoIndex") : Loc.L("Tooltips.Library.ViewSave");
|
||||
|
||||
/// <summary>"Rename view…": what it does, or that no saved view is in use.</summary>
|
||||
public string ViewRenameToolTip => IsViewActive ? Loc.L("Tooltips.Library.ViewRename") : Loc.L("Library.Blocked.NoActiveView");
|
||||
|
||||
/// <summary>"Delete view": what it does, or that no saved view is in use.</summary>
|
||||
public string ViewDeleteToolTip => IsViewActive ? Loc.L("Tooltips.Library.ViewDelete") : Loc.L("Library.Blocked.NoActiveView");
|
||||
|
||||
// ---------------- Timeline ----------------
|
||||
|
||||
/// <summary>One band per capture year, newest first: photos per month.</summary>
|
||||
@@ -398,9 +434,15 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
public SequenceItem? Selected
|
||||
{
|
||||
get => _selected;
|
||||
private set => Set(ref _selected, value);
|
||||
private set
|
||||
{
|
||||
if (Set(ref _selected, value)) OnPropertyChanged(nameof(RevealToolTip));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The details panel's "Folder": what it does, or why a remote card has no folder here.</summary>
|
||||
public string RevealToolTip => _selected is { IsRemote: true } ? Loc.L("Library.Blocked.ServerOnly") : Loc.L("Tooltips.Library.Folder");
|
||||
|
||||
public int SelectionCount
|
||||
{
|
||||
get => _selectionCount;
|
||||
@@ -458,7 +500,7 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
|
||||
// ---------------- Dialogs ----------------
|
||||
|
||||
/// <summary>The open in-window dialog (tags, move, view name); null when none.</summary>
|
||||
/// <summary>The open in-window dialog (tags, move, view name, delete); null when none.</summary>
|
||||
public ArchiveDialogViewModel? Dialog
|
||||
{
|
||||
get => _dialog;
|
||||
@@ -542,6 +584,20 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
/// <summary>Opens Tags on the selection (capture, tests).</summary>
|
||||
public void OpenRetag() => OpenRetag(Targets(MassAction.Tag));
|
||||
|
||||
/// <summary>Opens "Save view" on the filters on screen (capture, tests).</summary>
|
||||
public void OpenSaveView() => OpenViewName(rename: false);
|
||||
|
||||
/// <summary>
|
||||
/// Delete…: the archive engine's dry run, the typed confirmation and the move into the trash, in an in-window dialog
|
||||
/// that says how far it is and stops on Cancel. True when something left the Library.
|
||||
/// </summary>
|
||||
public async Task<bool> DeleteAsync(IReadOnlyList<Guid> sequenceIds)
|
||||
{
|
||||
var dialog = new DeleteDialogViewModel(Shell, sequenceIds, CloseDialog);
|
||||
OpenDialog(dialog);
|
||||
return await dialog.RunAsync();
|
||||
}
|
||||
|
||||
private void Reload()
|
||||
{
|
||||
if (_suppressReload) return;
|
||||
@@ -643,27 +699,13 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
var tags = await _db.Tags.ListAsync();
|
||||
_hasArchive = (await _db.Archives.ListAsync()).Count > 0;
|
||||
Shell.SetLibraryTotals(stats.Sequences, stats.Photos, stats.Bytes);
|
||||
_timeline = LibraryTimeline.From(stats, DateTime.Today);
|
||||
_localStats = stats;
|
||||
|
||||
_suppressReload = true;
|
||||
var year = _year.Value;
|
||||
var camera = _camera.Value;
|
||||
var tag = _tag.Value;
|
||||
Years = [AnyYear(), .. stats.ByYear.OrderByDescending(y => y.Year).Select(y => new FilterOption<int?>(y.Year, YearText(y.Year), YearText(y.Year)))];
|
||||
Cameras =
|
||||
[
|
||||
AnyCamera(),
|
||||
.. stats.ByCamera.Where(c => !string.IsNullOrWhiteSpace(c.Model))
|
||||
.GroupBy(c => c.Model!, StringComparer.Ordinal)
|
||||
.Select(g => (Model: g.Key, Name: Core.Naming.PathTemplate.CameraName(g.First().Make, g.Key)))
|
||||
.OrderBy(c => c.Name, StringComparer.CurrentCultureIgnoreCase)
|
||||
.Select(c => new FilterOption<string?>(c.Model, c.Name, c.Name)),
|
||||
];
|
||||
Tags = [AnyTag(), .. tags.OrderBy(t => t.Name, StringComparer.CurrentCultureIgnoreCase).Select(t => new FilterOption<string?>(t.Name, t.Name, t.Name))];
|
||||
SelectedYear = Years.FirstOrDefault(o => o.Value == year) ?? Years[0];
|
||||
SelectedCamera = Cameras.FirstOrDefault(o => o.Value == camera) ?? Cameras[0];
|
||||
SelectedTag = Tags.FirstOrDefault(o => o.Value == tag) ?? Tags[0];
|
||||
TimelineBands = [.. _timeline.Bands.Select(b => new ChartRow(b.Label, b.Values, b.ToolTips))];
|
||||
ApplyFacets();
|
||||
}
|
||||
catch (DatabaseException ex)
|
||||
{
|
||||
@@ -675,6 +717,48 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Year and Camera choices and the timeline bands of the origins in view (BRIEF §4.4 mixed mode): the index's
|
||||
/// figures and the remote cards'. A chosen year or camera that no sequence in view has stays chosen.
|
||||
/// </summary>
|
||||
private void ApplyFacets()
|
||||
{
|
||||
if (_localStats is not { } local) return;
|
||||
var suppressed = _suppressReload;
|
||||
_suppressReload = true;
|
||||
try
|
||||
{
|
||||
var stats = LibraryFacets.Of(local, _remote, _origin.Value);
|
||||
_timeline = LibraryTimeline.From(stats, DateTime.Today);
|
||||
var year = _year.Value;
|
||||
var camera = _camera.Value;
|
||||
Years = WithChosen([AnyYear(), .. stats.ByYear.OrderByDescending(y => y.Year).Select(y => new FilterOption<int?>(y.Year, YearText(y.Year), YearText(y.Year)))],
|
||||
year, YearText);
|
||||
Cameras = WithChosen(
|
||||
[
|
||||
AnyCamera(),
|
||||
.. stats.ByCamera.Where(c => !string.IsNullOrWhiteSpace(c.Model))
|
||||
.GroupBy(c => c.Model!, StringComparer.Ordinal)
|
||||
.Select(g => (Model: g.Key, Name: Core.Naming.PathTemplate.CameraName(g.First().Make, g.Key)))
|
||||
.OrderBy(c => c.Name, StringComparer.CurrentCultureIgnoreCase)
|
||||
.Select(c => new FilterOption<string?>(c.Model, c.Name, c.Name)),
|
||||
], camera, c => c ?? string.Empty);
|
||||
SelectedYear = Years.First(o => o.Value == year);
|
||||
SelectedCamera = Cameras.First(o => o.Value == camera);
|
||||
TimelineBands = [.. _timeline.Bands.Select(b => new ChartRow(b.Label, b.Values, b.ToolTips))];
|
||||
OnPropertyChanged(nameof(TimelineBand));
|
||||
OnPropertyChanged(nameof(TimelineSlot));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_suppressReload = suppressed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><paramref name="options"/>, plus the chosen value when they lack it, so a filter never changes by itself.</summary>
|
||||
private static IReadOnlyList<FilterOption<T>> WithChosen<T>(IReadOnlyList<FilterOption<T>> options, T chosen, Func<T, string> text) =>
|
||||
chosen is null || options.Any(o => EqualityComparer<T>.Default.Equals(o.Value, chosen)) ? options : [.. options, Option(options, chosen, text)];
|
||||
|
||||
/// <summary>
|
||||
/// Reads the sync table of the signed-in server: the server's sequences without a copy here become remote cards
|
||||
/// (with the server's listing when a new one appears), and every card learns what its Sync quick action does.
|
||||
@@ -710,6 +794,7 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
_entries = entries;
|
||||
var changed = !SameCards(_remote, remote);
|
||||
_remote = remote;
|
||||
if (changed) ApplyFacets();
|
||||
foreach (var item in Items) ApplySync(item);
|
||||
OnPropertyChanged(nameof(ShowsOrigin));
|
||||
RaiseMass();
|
||||
@@ -719,12 +804,15 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
private static bool SameCards(IReadOnlyList<Sequence> a, IReadOnlyList<Sequence> b) =>
|
||||
a.Count == b.Count && a.Zip(b).All(p => p.First.Id == p.Second.Id && p.First.UpdatedAt == p.Second.UpdatedAt && p.First.FrameCount == p.Second.FrameCount);
|
||||
|
||||
/// <summary>The card's sync row and what its Sync quick action does now.</summary>
|
||||
/// <summary>The card's sync row, what its Sync quick action does now, and whether Analyse and Render can start.</summary>
|
||||
private void ApplySync(SequenceItem item)
|
||||
{
|
||||
var entry = _entries.GetValueOrDefault(item.Id);
|
||||
var action = MassActions.QuickSync(new SelectedSequence(item.Sequence, entry), Context, out var blocker);
|
||||
item.SetSync(entry, action is not null, action is { } a ? Loc.L("Tooltips.Library.QuickSync." + a) : blocker ?? string.Empty);
|
||||
item.SetQuickBlocker(item.IsRemote
|
||||
? _actions.CanPost ? null : Loc.L("Library.Blocked.NotConnected")
|
||||
: Context.HasEngine ? null : Loc.L("Library.Blocked.NoIndex"));
|
||||
}
|
||||
|
||||
private SelectionContext Context => new(_db is not null && Shell.Services.Engine is not null, Shell.Services.Sync.Server is not null, _actions.Rights);
|
||||
@@ -821,11 +909,12 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
await store.DeleteAsync(view.Id);
|
||||
await LoadViewsAsync();
|
||||
Shell.Notify(Loc.L("Library.Views.Deleted", view.Name), actionText: Loc.L("Library.Views.Undo"), actionToolTip: Loc.L("Tooltips.Library.ViewUndo"),
|
||||
action: () => _ = UndoDeleteAsync(store, view));
|
||||
action: () => UndoDeleteViewCommand.Execute(view));
|
||||
}
|
||||
|
||||
private async Task UndoDeleteAsync(SavedViewStore store, SavedView view)
|
||||
private async Task UndoDeleteViewAsync(SavedView view)
|
||||
{
|
||||
if (_viewStore is not { } store) return;
|
||||
await store.SaveAsync(view);
|
||||
await LoadViewsAsync();
|
||||
}
|
||||
@@ -864,6 +953,10 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
OnPropertyChanged(nameof(ActiveView));
|
||||
OnPropertyChanged(nameof(IsViewActive));
|
||||
OnPropertyChanged(nameof(ViewsToolTip));
|
||||
OnPropertyChanged(nameof(ViewsApplyToolTip));
|
||||
OnPropertyChanged(nameof(ViewSaveToolTip));
|
||||
OnPropertyChanged(nameof(ViewRenameToolTip));
|
||||
OnPropertyChanged(nameof(ViewDeleteToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user