diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index e1407b8d..742aa9fd 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -153,17 +153,7 @@ void EpubReaderActivity::loop() { startActivityForResult( std::make_unique(renderer, mappedInput, epub, epub->getPath(), currentSpineIndex, currentPage, totalPages), - [this](const ActivityResult& result) { - if (!result.isCancelled) { - const auto& sync = std::get(result.data); - if (currentSpineIndex != sync.spineIndex || (section && section->currentPage != sync.page)) { - RenderLock lock(*this); - currentSpineIndex = sync.spineIndex; - nextPageNumber = sync.page; - section.reset(); - } - } - }); + [this](const ActivityResult& result) { handleSyncResult(result); }); return; } @@ -430,28 +420,26 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction } startActivityForResult( std::make_unique(renderer, mappedInput, epub, epub->getPath(), currentSpineIndex, - currentPage, totalPages, paragraphIdx, hasParagraphIdx), - [this](const ActivityResult& result) { - if (!result.isCancelled) { - const auto& sync = std::get(result.data); - if (currentSpineIndex != sync.spineIndex || (section && section->currentPage != sync.page)) { - RenderLock lock(*this); - currentSpineIndex = sync.spineIndex; - nextPageNumber = sync.page; - if (sync.hasParagraphIndex) { - pendingParagraphLookup = true; - pendingParagraphIndex = sync.paragraphIndex; - } - section.reset(); - } - } - }); + currentPage, totalPages), + [this](const ActivityResult& result) { handleSyncResult(result); }); } break; } } } +void EpubReaderActivity::handleSyncResult(const ActivityResult& result) { + if (!result.isCancelled) { + const auto& sync = std::get(result.data); + if (currentSpineIndex != sync.spineIndex || (section && section->currentPage != sync.page)) { + RenderLock lock(*this); + currentSpineIndex = sync.spineIndex; + nextPageNumber = sync.page; + section.reset(); + } + } +} + void EpubReaderActivity::applyOrientation(const uint8_t orientation) { // No-op if the selected orientation matches current settings. if (SETTINGS.orientation == orientation) { diff --git a/src/activities/reader/EpubReaderActivity.h b/src/activities/reader/EpubReaderActivity.h index 5ebddcfe..0f1b3a8f 100644 --- a/src/activities/reader/EpubReaderActivity.h +++ b/src/activities/reader/EpubReaderActivity.h @@ -52,6 +52,7 @@ class EpubReaderActivity final : public Activity { // Jump to a percentage of the book (0-100), mapping it to spine and page. void jumpToPercent(int percent); void onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction action); + void handleSyncResult(const ActivityResult& result); void applyOrientation(uint8_t orientation); void toggleAutoPageTurn(uint8_t selectedPageTurnOption); void applyBookReaderOverrides(int8_t embeddedStyleOverride, int8_t imageRenderingOverride); diff --git a/src/activities/settings/KOReaderSettingsActivity.cpp b/src/activities/settings/KOReaderSettingsActivity.cpp index 50e9be8c..acd57d01 100644 --- a/src/activities/settings/KOReaderSettingsActivity.cpp +++ b/src/activities/settings/KOReaderSettingsActivity.cpp @@ -107,8 +107,9 @@ void KOReaderSettingsActivity::handleSelection() { // Can't authenticate without credentials - just show message briefly return; } - startActivityForResult(std::make_unique(renderer, mappedInput, KOReaderAuthActivity::Mode::LOGIN), - [](const ActivityResult&) {}); + startActivityForResult( + std::make_unique(renderer, mappedInput, KOReaderAuthActivity::Mode::LOGIN), + [](const ActivityResult&) {}); } else if (selectedIndex == 5) { // Register if (!KOREADER_STORE.hasCredentials()) {