First attempt

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
jpirnay
2026-04-27 15:30:43 +02:00
co-authored by Copilot
parent 291898bb7f
commit aed297b2b1
11 changed files with 213 additions and 17 deletions
+33
View File
@@ -11,6 +11,7 @@
#include "CrossPointState.h"
#include "Epub.h"
#include "EpubReaderActivity.h"
#include "KOReaderCredentialStore.h"
#include "MdReaderActivity.h"
#include "Txt.h"
#include "TxtReaderActivity.h"
@@ -110,6 +111,38 @@ void ReaderActivity::goToLibrary(const std::string& fromBookPath) {
void ReaderActivity::onGoToEpubReader(std::unique_ptr<Epub> epub) {
const auto epubPath = epub->getPath();
currentBookPath = epubPath;
// Long-press Confirm on RecentBooks/FileBrowser sets autoPullOnOpen so the user can ask
// for KOReader sync at open time. Route into the sync activity instead of creating the
// reader; sync's resumeReader() will create the reader once the remote position is applied.
// Pull-only mode does not need accurate local reader state, so we hand off zeros for spine/page.
auto& sync = APP_STATE.koReaderSyncSession;
if (sync.autoPullOnOpen && KOREADER_STORE.hasCredentials()) {
LOG_DBG("READER", "AUTO_PULL on open: %s", epubPath.c_str());
sync.autoPullOnOpen = false; // consume the flag
sync.active = true;
sync.epubPath = epubPath;
sync.spineIndex = 0;
sync.page = 0;
sync.totalPagesInSpine = 0;
sync.paragraphIndex = 0;
sync.hasParagraphIndex = false;
sync.xhtmlSeekHint = 0;
sync.intent = KOReaderSyncIntentState::AUTO_PULL;
sync.outcome = KOReaderSyncOutcomeState::PENDING;
sync.resultSpineIndex = 0;
sync.resultPage = 0;
sync.resultParagraphIndex = 0;
sync.resultHasParagraphIndex = false;
sync.exitToHomeAfterSync = false;
APP_STATE.saveToFile();
// Drop the loaded Epub before TLS — sync activity will reload it for remote-position
// mapping. Holding it here would needlessly inflate the heap during WiFi/TLS work.
epub.reset();
activityManager.goToKOReaderSync();
return;
}
logReaderLaunchMemSnapshot("before_replace_epub_reader");
activityManager.replaceActivity(std::make_unique<EpubReaderActivity>(renderer, mappedInput, std::move(epub)));
}