Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
jpirnay
2026-04-27 18:45:16 +02:00
co-authored by Copilot
parent aed297b2b1
commit 066ec3d56b
6 changed files with 30 additions and 17 deletions
+2 -2
View File
@@ -187,9 +187,9 @@ void FileBrowserActivity::loop() {
std::string fullPath = basepath;
if (fullPath.back() != '/') fullPath += "/";
fullPath += entry;
if (longPress && KOREADER_STORE.hasCredentials()) {
if (longPress && KOREADER_STORE.hasCredentials() && FsHelpers::hasEpubExtension(fullPath)) {
auto& sync = APP_STATE.koReaderSyncSession;
sync.autoPullOnOpen = true;
sync.autoPullEpubPath = fullPath;
sync.exitToHomeAfterSync = false;
APP_STATE.saveToFile();
}
+8 -5
View File
@@ -56,13 +56,16 @@ void RecentBooksActivity::loop() {
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) && !recentBooks.empty() &&
selectorIndex < static_cast<int>(recentBooks.size())) {
// Long-press Confirm signals "open with KOReader sync": the reader will perform an
// AUTO_PULL before rendering its first page. Short-press is the unchanged direct open.
// Long-press Confirm signals "open with KOReader sync" only for EPUBs.
// Short-press is unchanged direct open.
const bool longPress = mappedInput.getHeldTime() >= ReaderUtils::GO_HOME_MS && KOREADER_STORE.hasCredentials();
LOG_DBG("RBA", "Selected recent book: %s (sync=%d)", recentBooks[selectorIndex].path.c_str(), longPress ? 1 : 0);
if (longPress) {
const std::string& selectedPath = recentBooks[selectorIndex].path;
const bool isEpubBook = FsHelpers::hasEpubExtension(selectedPath);
LOG_DBG("RBA", "Selected recent book: %s (sync=%d epub=%d)", selectedPath.c_str(), longPress ? 1 : 0,
isEpubBook ? 1 : 0);
if (longPress && isEpubBook) {
auto& sync = APP_STATE.koReaderSyncSession;
sync.autoPullOnOpen = true;
sync.autoPullEpubPath = selectedPath;
sync.exitToHomeAfterSync = false;
APP_STATE.saveToFile();
}
@@ -898,6 +898,14 @@ bool EpubReaderActivity::tryAutoPushOnClose() {
if (!epub) {
return false;
}
const int spineCount = epub->getSpineItemsCount();
if (spineCount == 0 || currentSpineIndex >= spineCount || !section) {
LOG_DBG("ERS", "Skipping AUTO_PUSH on end-of-book sentinel: spine=%d section=%s", currentSpineIndex,
section ? "present" : "null");
return false;
}
// exitToHomeAfterSync flag is set inside launchKOReaderSync for AUTO_PUSH mode.
launchKOReaderSync(SyncLaunchMode::AUTO_PUSH);
return true;
+4 -4
View File
@@ -112,14 +112,14 @@ 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
// Long-press Confirm on RecentBooks/FileBrowser sets autoPullEpubPath 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()) {
if (!sync.autoPullEpubPath.empty() && sync.autoPullEpubPath == epubPath && KOREADER_STORE.hasCredentials()) {
LOG_DBG("READER", "AUTO_PULL on open: %s", epubPath.c_str());
sync.autoPullOnOpen = false; // consume the flag
sync.autoPullEpubPath.clear(); // consume the flag
sync.active = true;
sync.epubPath = epubPath;
sync.spineIndex = 0;