@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user