mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-13 22:27:19 -04:00
Report the abort on the book the user answered for
With several books in flight, the book whose dialog was answered showed "Cancelled" while some unrelated book showed "Error, Abort". Tearing the queue down is claimed by whichever book finishes first, and the books genuinely are interchangeable for that. The status left on a row is not: it is read afterwards by someone who remembers which book they were asked about. The two jobs are now separate. ShowRetryDialogAsync records the answering book as BadBookSessionContext.AbortOriginator, written before Override so that a book reading Override and racing ahead to the queue loop cannot find the originator still unset and conclude there was none. The loop gives the abort to that book and Cancelled to every book that inherited the answer. ClaimAbort is unchanged and still decides the teardown. With no dialog in play - Bad Book set to Abort in settings - nobody answered anything, there is no originator, and the book that claimed the teardown keeps the abort as before.
This commit is contained in:
1 parent
5e1ac3f9cc
commit
76e036fb42
4 files changed
+82
-6
No files matched your search
@@ -29,6 +29,13 @@ public class ProcessQueueViewModel : ReactiveObject
|
||||
public ObservableCollection<LogEntry> LogEntries { get; } = new();
|
||||
public TrackedQueue<ProcessBookViewModel> Queue { get; } = new();
|
||||
private readonly BadBookSessionContext _badBookSession = new();
|
||||
|
||||
/// <summary>
|
||||
/// Internal rather than private so a test can stand in for a user having answered the bad book
|
||||
/// dialog, which the dispatch tests otherwise never reach - their books finish on command instead
|
||||
/// of failing their way into it.
|
||||
/// </summary>
|
||||
internal BadBookSessionContext BadBookSession => _badBookSession;
|
||||
public Task? QueueRunner { get; private set; }
|
||||
public bool Running => !QueueRunner?.IsCompleted ?? false;
|
||||
|
||||
@@ -756,10 +763,21 @@ public class ProcessQueueViewModel : ReactiveObject
|
||||
{
|
||||
if (tearsDownTheQueue)
|
||||
await CancelAllAsync(book);
|
||||
else
|
||||
|
||||
// Tearing the queue down and reporting the abort are separate jobs, and only the
|
||||
// first one is indifferent to which book does it. The status left on a row is read
|
||||
// afterwards by someone who remembers which book they were asked about, so the
|
||||
// abort belongs to the book they answered for - not to whichever book happened to
|
||||
// reach the teardown first, which put "Cancelled" on the row they aborted and
|
||||
// "Error, Abort" on an unrelated one. With no dialog in play (Bad Book set to
|
||||
// Abort in settings) nobody answered anything, and the book that claimed the
|
||||
// teardown keeps the abort as before.
|
||||
var originator = _badBookSession.AbortOriginator;
|
||||
var reportsTheAbort = originator is null ? tearsDownTheQueue : ReferenceEquals(originator, book);
|
||||
|
||||
if (!reportsTheAbort)
|
||||
{
|
||||
// Inherited the abort rather than triggering the teardown. It was cancelled by
|
||||
// the book that did, and that is what it should report.
|
||||
// Cancelled by the abort rather than the cause of it.
|
||||
book.Result = ProcessBookResult.Cancelled;
|
||||
book.Status = ProcessBookStatus.Cancelled;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user