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 "CrossPointSettings.h"
|
||||||
#include "EpubReaderChapterSelectionActivity.h"
|
#include "EpubReaderChapterSelectionActivity.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "CrossPointState.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr int pagesPerRefresh = 15;
|
constexpr int pagesPerRefresh = 15;
|
||||||
@ -44,6 +45,10 @@ void EpubReaderActivity::onEnter() {
|
|||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save current epub as last opened epub
|
||||||
|
APP_STATE.openEpubPath = epub->getPath();
|
||||||
|
APP_STATE.saveToFile();
|
||||||
|
|
||||||
// Trigger first update
|
// Trigger first update
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
|
|
||||||
#include "CrossPointState.h"
|
|
||||||
#include "Epub.h"
|
#include "Epub.h"
|
||||||
#include "EpubReaderActivity.h"
|
#include "EpubReaderActivity.h"
|
||||||
#include "FileSelectionActivity.h"
|
#include "FileSelectionActivity.h"
|
||||||
@ -29,8 +28,6 @@ void ReaderActivity::onSelectEpubFile(const std::string& path) {
|
|||||||
|
|
||||||
auto epub = loadEpub(path);
|
auto epub = loadEpub(path);
|
||||||
if (epub) {
|
if (epub) {
|
||||||
APP_STATE.openEpubPath = path;
|
|
||||||
APP_STATE.saveToFile();
|
|
||||||
onGoToEpubReader(std::move(epub));
|
onGoToEpubReader(std::move(epub));
|
||||||
} else {
|
} else {
|
||||||
exitActivity();
|
exitActivity();
|
||||||
|
|||||||
@ -194,7 +194,11 @@ void setup() {
|
|||||||
if (APP_STATE.openEpubPath.empty()) {
|
if (APP_STATE.openEpubPath.empty()) {
|
||||||
onGoHome();
|
onGoHome();
|
||||||
} else {
|
} 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
|
// Ensure we're not still holding the power button before leaving setup
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user