mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
style: use std::find_if instead of raw loop
Address cppcheck useStlAlgorithm warning in HomeActivity.
This commit is contained in:
parent
fea92fd235
commit
1803cdc389
@ -7,6 +7,7 @@
|
||||
#include <ThemeManager.h>
|
||||
#include <Xtc.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
@ -58,19 +59,16 @@ void HomeActivity::onEnter() {
|
||||
cachedProgressPercent = 0;
|
||||
|
||||
// Check if current book is in recent books - use cached data instead of reloading
|
||||
bool foundInRecent = false;
|
||||
for (const auto& book : cachedRecentBooks) {
|
||||
if (book.path == APP_STATE.openEpubPath) {
|
||||
lastBookTitle = book.title;
|
||||
coverBmpPath = book.coverPath;
|
||||
hasCoverImage = !book.coverPath.empty();
|
||||
cachedProgressPercent = book.progressPercent;
|
||||
foundInRecent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const auto& openPath = APP_STATE.openEpubPath;
|
||||
auto it = std::find_if(cachedRecentBooks.begin(), cachedRecentBooks.end(),
|
||||
[&openPath](const CachedBookInfo& book) { return book.path == openPath; });
|
||||
|
||||
if (!foundInRecent) {
|
||||
if (it != cachedRecentBooks.end()) {
|
||||
lastBookTitle = it->title;
|
||||
coverBmpPath = it->coverPath;
|
||||
hasCoverImage = !it->coverPath.empty();
|
||||
cachedProgressPercent = it->progressPercent;
|
||||
} else {
|
||||
// Book not in recent list, need to load it
|
||||
lastBookTitle = APP_STATE.openEpubPath;
|
||||
const size_t lastSlash = lastBookTitle.find_last_of('/');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user