fix(reorganize): Apply on the first click, one offer per toast, no open dialog replaced
Review of owner review 2, phase 4a (R7): the Reorganize dialogs of the desktop and the web panel. Desktop - Clicking Apply first takes the focus from the template field, which committed it and started a dry run identical to the one on screen: Apply turned off under the click. A commit now plans only when the templates differ from the shown plan (or the last dry run failed). - The Settings toast's Reorganize… disposed whatever dialog the Archive screen had open, so a running Delete stopped without being asked. An open dialog now stays and its archive is not switched; Reorganize says it waits and opens once that dialog closes, with the archive's templates read again and every part the toasts offered meanwhile. - Each Settings toast takes its own archive's offer (one pending offer per archive), and a toast gone early (dismissed, pushed out) lets the next change of that archive raise its own toast: Toast.Closed now says when a toast leaves the screen. Web panel - The Library sends the selected ids up to a thousand. all:true is used only above that, when the selection is exactly what Select all fetched without a filter and the archive has not grown since, so a sequence unticked or added later is never reorganized; otherwise the toast asks to select again. - The preview's "before" of an untitled sequence is its old name, not the new title twice. - A dry run of the same request answering during the confirmation no longer drops the confirmed apply; a plan that really changed is shown and said (Admin.Reorganize.PlanChanged). - Enter in a template plans at once (the form never submitted on Enter). - The confirm tooltip and the module header no longer say the moves are verified: moves and renames are not hashed. Strings in en and it; the reworded key exists in no other culture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit bed718fb5af2ef69943fd348690c689259872a34)
This commit is contained in:
1 parent
9ae773aa5a
commit
59ee982e4d
14 files changed
+301
-49
No files matched your search
@@ -98,7 +98,7 @@ public sealed class ReorganizeDialogViewModel : ArchiveDialogViewModel
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => ApplyBlocker is null);
|
||||
|
||||
ReorganizeTemplate Template(ReorganizeParts part, string text, string toolTip) =>
|
||||
new(part, text, enabled.HasFlag(part), toolTip, OnTyped, () => _ = PlanAsync(), () => _ = PlanAsync());
|
||||
new(part, text, enabled.HasFlag(part), toolTip, OnTyped, () => _ = PlanAsync(), OnCommitted);
|
||||
}
|
||||
|
||||
public ReorganizeTemplate Folders { get; }
|
||||
@@ -182,6 +182,23 @@ public sealed class ReorganizeDialogViewModel : ArchiveDialogViewModel
|
||||
_delay.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enter, or the focus leaving a field, plans at once, unless the dry run on screen or the one under way is already of
|
||||
/// these templates: a click on Apply takes the focus from the field first, and an identical dry run started then
|
||||
/// would turn Apply off under the click.
|
||||
/// </summary>
|
||||
private void OnCommitted()
|
||||
{
|
||||
if (IsPlanned()) _delay.Stop();
|
||||
else _ = PlanAsync();
|
||||
}
|
||||
|
||||
/// <summary>The templates on screen have their plan, or a dry run of them is under way; false after a failed one.</summary>
|
||||
private bool IsPlanned()
|
||||
{
|
||||
lock (_gate) return _run.For is { } templates && templates == Current() && (_run.Plan is not null || _planning is not null);
|
||||
}
|
||||
|
||||
private async Task DryRunAsync()
|
||||
{
|
||||
var templates = Current();
|
||||
|
||||
@@ -112,33 +112,45 @@ public static class ReorganizePlans
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What Settings › Archive offers to reorganize after its templates changed (owner review 2, R7): the archive and every
|
||||
/// template changed since the offer was last taken. A change while the toast is still up joins the offer on screen
|
||||
/// instead of raising another toast; a change in another archive raises its own.
|
||||
/// What Settings › Archive offers to reorganize after its templates changed (owner review 2, R7): per archive, every
|
||||
/// template changed since its offer was last taken. A change while that archive's toast is still up joins the offer on
|
||||
/// screen instead of raising another toast; a change in another archive raises its own, and each toast takes only its
|
||||
/// archive's offer.
|
||||
/// </summary>
|
||||
/// <param name="toastTime">How long a toast stays up.</param>
|
||||
public sealed class ReorganizeOffer(TimeSpan toastTime)
|
||||
{
|
||||
private (Core.Model.Archive Archive, ReorganizeParts Parts)? _pending;
|
||||
private DateTime _raised;
|
||||
private readonly Dictionary<Guid, Pending> _pending = [];
|
||||
|
||||
/// <summary>Records that <paramref name="part"/> of <paramref name="archive"/> changed at <paramref name="now"/>; true when a toast should offer it.</summary>
|
||||
/// <summary>
|
||||
/// Records that <paramref name="part"/> of <paramref name="archive"/> changed at <paramref name="now"/>; true when a
|
||||
/// toast should offer it (none of that archive is up), raised at <paramref name="now"/>.
|
||||
/// </summary>
|
||||
public bool Add(Core.Model.Archive archive, ReorganizeParts part, DateTime now)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(archive);
|
||||
var same = _pending is { } pending && pending.Archive.Id == archive.Id;
|
||||
_pending = same ? (archive, _pending!.Value.Parts | part) : (archive, part);
|
||||
if (same && now - _raised < toastTime) return false;
|
||||
_raised = now;
|
||||
return true;
|
||||
var known = _pending.TryGetValue(archive.Id, out var pending);
|
||||
var shown = known && pending!.Raised is { } raised && now - raised < toastTime;
|
||||
_pending[archive.Id] = new Pending(archive, (known ? pending!.Parts : ReorganizeParts.None) | part, shown ? pending!.Raised : now);
|
||||
return !shown;
|
||||
}
|
||||
|
||||
/// <summary>The offer when a toast's action runs: the archive as it was last saved and every template changed; null when taken already.</summary>
|
||||
public (Core.Model.Archive Archive, ReorganizeParts Parts)? Take()
|
||||
/// <summary>
|
||||
/// The toast of <paramref name="archiveId"/> raised at <paramref name="raised"/> left the screen (dismissed, timed out,
|
||||
/// pushed out by newer ones): the next change raises a new one. A toast older than the one up now changes nothing.
|
||||
/// </summary>
|
||||
public void Closed(Guid archiveId, DateTime raised)
|
||||
{
|
||||
var pending = _pending;
|
||||
_pending = null;
|
||||
_raised = default;
|
||||
return pending;
|
||||
if (_pending.TryGetValue(archiveId, out var pending) && pending.Raised == raised) _pending[archiveId] = pending with { Raised = null };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The offer of <paramref name="archiveId"/> when its toast's action runs: the archive as it was last saved and every
|
||||
/// template changed; null when taken already. Other archives' offers stay.
|
||||
/// </summary>
|
||||
public (Core.Model.Archive Archive, ReorganizeParts Parts)? Take(Guid archiveId) =>
|
||||
_pending.Remove(archiveId, out var pending) ? (pending.Archive, pending.Parts) : null;
|
||||
|
||||
/// <param name="Raised">When the toast on screen was raised; null once it left.</param>
|
||||
private sealed record Pending(Core.Model.Archive Archive, ReorganizeParts Parts, DateTime? Raised);
|
||||
}
|
||||
Reference in new issue
Block a user