diff --git a/lib/Epub/Epub.cpp b/lib/Epub/Epub.cpp index 87033f0f..f5a3cff9 100644 --- a/lib/Epub/Epub.cpp +++ b/lib/Epub/Epub.cpp @@ -570,10 +570,6 @@ bool Epub::generateThumbBmp(int height) const { LOG_ERR("EBP", "Cover image is not a supported format, skipping thumbnail"); } - // Write an empty bmp file to avoid generation attempts in the future - FsFile thumbBmp; - Storage.openFileForWrite("EBP", getThumbBmpPath(height), thumbBmp); - thumbBmp.close(); return false; } diff --git a/src/RecentBooksStore.cpp b/src/RecentBooksStore.cpp index 25092d85..880e11f4 100644 --- a/src/RecentBooksStore.cpp +++ b/src/RecentBooksStore.cpp @@ -38,6 +38,15 @@ void RecentBooksStore::addBook(const std::string& path, const std::string& title saveToFile(); } +void RecentBooksStore::removeBook(const std::string& path) { + auto it = + std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; }); + if (it != recentBooks.end()) { + recentBooks.erase(it); + saveToFile(); + } +} + void RecentBooksStore::updateBook(const std::string& path, const std::string& title, const std::string& author, const std::string& coverBmpPath) { auto it = diff --git a/src/RecentBooksStore.h b/src/RecentBooksStore.h index 8dbf0813..ec81c011 100644 --- a/src/RecentBooksStore.h +++ b/src/RecentBooksStore.h @@ -30,6 +30,9 @@ class RecentBooksStore { void updateBook(const std::string& path, const std::string& title, const std::string& author, const std::string& coverBmpPath); + // Remove a book from the recent list by path + void removeBook(const std::string& path); + // Get the list of recent books (most recent first) const std::vector& getBooks() const { return recentBooks; } diff --git a/src/activities/home/HomeActivity.cpp b/src/activities/home/HomeActivity.cpp index d64f260b..1e42117f 100644 --- a/src/activities/home/HomeActivity.cpp +++ b/src/activities/home/HomeActivity.cpp @@ -88,7 +88,7 @@ void HomeActivity::loadRecentCovers(int coverHeight) { } // Fallback: generate a placeholder thumbnail with title/author - if (!success && !Storage.exists(coverPath.c_str())) { + if (!success) { const int thumbWidth = static_cast(coverHeight * 0.6); PlaceholderCoverGenerator::generate(coverPath, book.title, book.author, thumbWidth, coverHeight); } diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 36687b65..610330e2 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -745,6 +745,9 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction epub->setupCacheDir(); saveProgress(backupSpine, backupPage, backupPageCount); + + // 5. Remove from recent books so the home screen doesn't show a stale/placeholder cover + RECENT_BOOKS.removeBook(epub->getPath()); } xSemaphoreGive(renderingMutex); // Defer go home to avoid race condition with display task