Fixed: UI updates when new author book monitor state set

Fixes #1298
This commit is contained in:
ta264 2021-11-14 21:28:58 +00:00
parent 2983b60026
commit a1c2986af8
2 changed files with 8 additions and 4 deletions

View file

@ -80,7 +80,7 @@ public void should_be_able_to_monitor_all_books()
Subject.SetBookMonitoredStatus(_author, new MonitoringOptions { Monitor = MonitorTypes.All });
Mocker.GetMock<IBookService>()
.Verify(v => v.UpdateMany(It.Is<List<Book>>(l => l.All(e => e.Monitored))));
.Verify(v => v.UpdateBook(It.Is<Book>(l => l.Monitored)), Times.Exactly(_books.Count));
}
[Test]
@ -101,13 +101,13 @@ public void should_be_able_to_monitor_new_books_only()
private void VerifyMonitored(Func<Book, bool> predicate)
{
Mocker.GetMock<IBookService>()
.Verify(v => v.UpdateMany(It.Is<List<Book>>(l => l.Where(predicate).All(e => e.Monitored))));
.Verify(v => v.UpdateBook(It.Is<Book>(b => b.Monitored)), Times.AtLeast(_books.Where(predicate).Count()));
}
private void VerifyNotMonitored(Func<Book, bool> predicate)
{
Mocker.GetMock<IBookService>()
.Verify(v => v.UpdateMany(It.Is<List<Book>>(l => l.Where(predicate).All(e => !e.Monitored))));
.Verify(v => v.UpdateBook(It.Is<Book>(b => !b.Monitored)), Times.AtLeast(_books.Where(predicate).Count()));
}
}
}

View file

@ -86,7 +86,11 @@ public void SetBookMonitoredStatus(Author author, MonitoringOptions monitoringOp
}
}
_bookService.UpdateMany(books);
// Use individual update to ensure updates are sent to frontend
foreach (var book in books)
{
_bookService.UpdateBook(book);
}
}
_authorService.UpdateAuthor(author);