feat: Lazy incremental EPUB section indexing (#2452)

Co-authored-by: Uri Tauber <uritaube@gmail.com>
Co-authored-by: Julia Nguyen <julia@uxj.io>
This commit is contained in:
Justin Mitchell
2026-07-04 21:21:24 +03:00
committed by GitHub
co-authored by Uri Tauber Julia Nguyen
parent 79b4d63ee2
commit 685d4e88f9
14 changed files with 1055 additions and 262 deletions
+8
View File
@@ -2,6 +2,7 @@
#include <FsHelpers.h>
#include <HalStorage.h>
#include <I18n.h>
#include <Memory.h>
#include "CrossPointSettings.h"
@@ -14,6 +15,7 @@
#include "XtcReaderActivity.h"
#include "activities/util/BmpViewerActivity.h"
#include "activities/util/FullScreenMessageActivity.h"
#include "components/UITheme.h"
bool ReaderActivity::isXtcFile(const std::string& path) { return FsHelpers::hasXtcExtension(path); }
@@ -35,6 +37,12 @@ std::unique_ptr<Epub> ReaderActivity::loadEpub(const std::string& path) {
LOG_ERR("READER", "Failed to allocate EPUB object");
return nullptr;
}
// First open: building the spine/TOC index (book.bin) takes a couple of seconds. Show the
// indexing popup so it isn't a silent wait on the home screen. The cachePath/hash is known at
// construction, so this check is valid before load(); a cached open loads in a blink -> no popup.
if (!Storage.exists((epub->getCachePath() + "/book.bin").c_str())) {
GUI.drawPopup(renderer, tr(STR_INDEXING));
}
if (epub->load(true, SETTINGS.embeddedStyle == 0)) {
return epub;
}