Unset openEpubPath on boot and set once epub fully loaded
This commit is contained in:
parent
2a27c6d068
commit
41e6fa17a5
@ -8,6 +8,7 @@
|
||||
#include "CrossPointSettings.h"
|
||||
#include "EpubReaderChapterSelectionActivity.h"
|
||||
#include "config.h"
|
||||
#include "CrossPointState.h"
|
||||
|
||||
namespace {
|
||||
constexpr int pagesPerRefresh = 15;
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
#include <SD.h>
|
||||
|
||||
#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();
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user