Review comments

This commit is contained in:
jpirnay
2026-04-17 20:59:49 +02:00
parent d39246ee70
commit e74e52b23a
5 changed files with 51 additions and 17 deletions
@@ -27,6 +27,26 @@ void GlobalBookmarksActivity::onEnter() {
const int first = firstSelectableIndex();
selectorIndex = first >= 0 ? first : 0;
if (restoreHint.target == ReturnTo::GlobalBookmarks) {
const auto& entries = GLOBAL_BOOKMARKS.getEntries();
if (!restoreHint.selectionContext.empty() && restoreHint.selectBookmarkIndex >= 0) {
for (size_t i = 0; i < rows.size(); ++i) {
const auto& row = rows[i];
if (row.isSeparator) continue;
if (row.bookmarkIndex == static_cast<size_t>(restoreHint.selectBookmarkIndex) &&
row.bookIndex < entries.size() && entries[row.bookIndex].sourcePath == restoreHint.selectionContext) {
selectorIndex = static_cast<int>(i);
break;
}
}
}
if (selectorIndex < 0 || selectorIndex >= static_cast<int>(rows.size()) || isSeparatorRow(selectorIndex)) {
const int fallback = firstSelectableIndex();
selectorIndex = fallback >= 0 ? fallback : 0;
}
restoreHint = {};
}
const auto total = static_cast<int>(rows.size());
buttonNavigator.setSelectablePredicate([this](int index) { return !isSeparatorRow(index); }, total);
@@ -126,8 +146,9 @@ void GlobalBookmarksActivity::openSelected() {
LOG_DBG("GBA", "Jumping to bookmark in %s at %u/%u", entry.sourcePath.c_str(), bm.spineIndex, bm.pageNumber);
ReturnHint hint;
hint.target = ReturnTo::Home;
hint.selectName = entry.sourcePath;
hint.target = ReturnTo::GlobalBookmarks;
hint.selectionContext = entry.sourcePath;
hint.selectBookmarkIndex = static_cast<int>(row.bookmarkIndex);
activityManager.replaceWithReader(entry.sourcePath, std::move(hint));
}