Remove missing books from recent list

This commit is contained in:
jpirnay
2026-05-15 19:22:58 +02:00
parent 684a96f108
commit 3ed5bc3673
4 changed files with 23 additions and 11 deletions
+10
View File
@@ -30,6 +30,8 @@ void RecentBooksStore::addBook(const std::string& path, const std::string& title
int8_t bionicReadingOverride = -1;
int8_t paragraphAlignmentOverride = -1;
pruneMissing();
// Remove existing entry if present
auto it =
std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; });
@@ -66,6 +68,14 @@ void RecentBooksStore::removeBook(const std::string& path) {
}
}
bool RecentBooksStore::isMissing(const RecentBook& book) { return !Storage.exists(book.path.c_str()); }
bool RecentBooksStore::pruneMissing() {
const size_t before = recentBooks.size();
recentBooks.erase(std::remove_if(recentBooks.begin(), recentBooks.end(), &isMissing), recentBooks.end());
return recentBooks.size() != before;
}
void RecentBooksStore::updateBook(const std::string& path, const std::string& title, const std::string& author,
const std::string& series, const std::string& coverBmpPath) {
auto it =