fix: address release review feedback
This commit is contained in:
@@ -83,9 +83,10 @@ ProgressRange getPageProgressRange(const std::shared_ptr<Epub>& epub, const int
|
||||
return {epub->calculateProgress(spineIndex, start), epub->calculateProgress(spineIndex, end)};
|
||||
}
|
||||
|
||||
bool bookmarkMatchesProgress(const BookmarkEntry& bookmark, const SavedProgressPosition& progress,
|
||||
bool bookmarkMatchesProgress(const BookmarkEntry& bookmark, const int spineIndex, const int page, const int pageCount,
|
||||
const ProgressRange& pageRange) {
|
||||
if (bookmark.xpath == progress.xpath) {
|
||||
if (bookmark.computedSpineIndex == spineIndex && bookmark.computedChapterPageCount == pageCount &&
|
||||
bookmark.computedChapterProgress == page) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1311,10 +1312,12 @@ void EpubReaderActivity::addBookmark() {
|
||||
const ProgressRange pageRange = getPageProgressRange(epub, currentSpineIndex, currentPage, pageCount);
|
||||
|
||||
const size_t bookmarkCountBeforeToggle = cachedBookmarks.size();
|
||||
cachedBookmarks.erase(
|
||||
std::remove_if(cachedBookmarks.begin(), cachedBookmarks.end(),
|
||||
[&](const BookmarkEntry& b) { return bookmarkMatchesProgress(b, progress, pageRange); }),
|
||||
cachedBookmarks.end());
|
||||
cachedBookmarks.erase(std::remove_if(cachedBookmarks.begin(), cachedBookmarks.end(),
|
||||
[&](const BookmarkEntry& b) {
|
||||
return bookmarkMatchesProgress(b, currentSpineIndex, currentPage, pageCount,
|
||||
pageRange);
|
||||
}),
|
||||
cachedBookmarks.end());
|
||||
if (cachedBookmarks.size() != bookmarkCountBeforeToggle) {
|
||||
bookmarkRemoved = true;
|
||||
currentPageBookmarked = false;
|
||||
@@ -1353,12 +1356,7 @@ void EpubReaderActivity::updateBookmarkFlag() {
|
||||
const ProgressRange pageRange =
|
||||
getPageProgressRange(epub, currentSpineIndex, section->currentPage, section->pageCount);
|
||||
currentPageBookmarked = std::any_of(cachedBookmarks.begin(), cachedBookmarks.end(), [&](const BookmarkEntry& b) {
|
||||
if (b.computedSpineIndex == currentSpineIndex && b.computedChapterPageCount == section->pageCount &&
|
||||
b.computedChapterProgress == section->currentPage) {
|
||||
return true;
|
||||
}
|
||||
const float bp = std::clamp(b.percentage, 0.0f, 1.0f);
|
||||
return bp + bookmarkProgressEpsilon >= pageRange.start && bp - bookmarkProgressEpsilon <= pageRange.end;
|
||||
return bookmarkMatchesProgress(b, currentSpineIndex, section->currentPage, section->pageCount, pageRange);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1895,15 +1895,43 @@
|
||||
const fileTable = document.getElementById('file-table');
|
||||
|
||||
const segments = currentPath.split('/').filter(Boolean);
|
||||
const crumbs = ['<a href="/files">🏠 Home</a>'];
|
||||
segments.forEach(function(segment, index) {
|
||||
const path = '/' + segments.slice(0, index + 1).join('/');
|
||||
crumbs.push('<a href="/files?path=' + encodeURIComponent(path) + '">' + escapeHtml(segment) + '</a>');
|
||||
});
|
||||
// The last crumb is the current location: render as plain text, not a link.
|
||||
const lastSegment = segments.length ? escapeHtml(segments[segments.length - 1]) : '🏠 Home';
|
||||
crumbs[crumbs.length - 1] = '<span class="current">' + lastSegment + '</span>';
|
||||
breadcrumbs.innerHTML = crumbs.join('<span class="sep">›</span>');
|
||||
breadcrumbs.replaceChildren();
|
||||
|
||||
const appendSep = function() {
|
||||
const sep = document.createElement('span');
|
||||
sep.className = 'sep';
|
||||
sep.textContent = '›';
|
||||
breadcrumbs.appendChild(sep);
|
||||
};
|
||||
|
||||
const appendLink = function(label, href) {
|
||||
const link = document.createElement('a');
|
||||
link.href = href;
|
||||
link.textContent = label;
|
||||
breadcrumbs.appendChild(link);
|
||||
};
|
||||
|
||||
const appendCurrent = function(label) {
|
||||
const current = document.createElement('span');
|
||||
current.className = 'current';
|
||||
current.textContent = label;
|
||||
breadcrumbs.appendChild(current);
|
||||
};
|
||||
|
||||
if (segments.length === 0) {
|
||||
appendCurrent('🏠 Home');
|
||||
} else {
|
||||
appendLink('🏠 Home', '/files');
|
||||
segments.forEach(function(segment, index) {
|
||||
appendSep();
|
||||
if (index === segments.length - 1) {
|
||||
appendCurrent(segment);
|
||||
} else {
|
||||
const path = '/' + segments.slice(0, index + 1).join('/');
|
||||
appendLink(segment, '/files?path=' + encodeURIComponent(path));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let files = [];
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user