diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 8827e99..9635952 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -6,6 +6,7 @@ #include "Battery.h" #include "CrossPointSettings.h" +#include "CrossPointState.h" #include "EpubReaderChapterSelectionActivity.h" #include "config.h" @@ -44,6 +45,10 @@ void EpubReaderActivity::onEnter() { f.close(); } + // Save current epub as last opened epub + APP_STATE.openEpubPath = epub->getPath(); + APP_STATE.saveToFile(); + // Trigger first update updateRequired = true; diff --git a/src/activities/reader/ReaderActivity.cpp b/src/activities/reader/ReaderActivity.cpp index 099d7e2..93389fe 100644 --- a/src/activities/reader/ReaderActivity.cpp +++ b/src/activities/reader/ReaderActivity.cpp @@ -2,7 +2,6 @@ #include -#include "CrossPointState.h" #include "Epub.h" #include "EpubReaderActivity.h" #include "FileSelectionActivity.h" @@ -29,8 +28,6 @@ void ReaderActivity::onSelectEpubFile(const std::string& path) { auto epub = loadEpub(path); if (epub) { - APP_STATE.openEpubPath = path; - APP_STATE.saveToFile(); onGoToEpubReader(std::move(epub)); } else { exitActivity(); diff --git a/src/main.cpp b/src/main.cpp index 89d2af4..5dfc25b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -194,7 +194,11 @@ void setup() { if (APP_STATE.openEpubPath.empty()) { onGoHome(); } else { - onGoToReader(APP_STATE.openEpubPath); + // Clear app state to avoid getting into a boot loop if the epub doesn't load + const auto path = APP_STATE.openEpubPath; + APP_STATE.openEpubPath = ""; + APP_STATE.saveToFile(); + onGoToReader(path); } // Ensure we're not still holding the power button before leaving setup