diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index d1ac257b..e87c54bd 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -183,10 +183,9 @@ void SleepActivity::onEnter() { } void SleepActivity::renderCustomSleepScreen() const { - const BookOverlayInfo overlayInfo = - (SETTINGS.sleepCoverOverlay != 0 && APP_STATE.lastSleepFromReader && !APP_STATE.openEpubPath.empty()) - ? getBookOverlayInfo(APP_STATE.openEpubPath) - : BookOverlayInfo{}; + const BookOverlayInfo overlayInfo{}; + const bool shouldLoadOverlayInfo = + SETTINGS.sleepCoverOverlay != 0 && APP_STATE.lastSleepFromReader && !APP_STATE.openEpubPath.empty(); // Check if we have a /.sleep (preferred) or /sleep directory const char* sleepDir = nullptr; @@ -248,7 +247,9 @@ void SleepActivity::renderCustomSleepScreen() const { delay(100); Bitmap bitmap(file, true); if (bitmap.parseHeaders() == BmpReaderError::Ok) { - renderBitmapSleepScreen(bitmap, overlayInfo); + const BookOverlayInfo resolvedOverlayInfo = + shouldLoadOverlayInfo ? getBookOverlayInfo(APP_STATE.openEpubPath) : overlayInfo; + renderBitmapSleepScreen(bitmap, resolvedOverlayInfo); file.close(); dir.close(); return; @@ -266,7 +267,9 @@ void SleepActivity::renderCustomSleepScreen() const { Bitmap bitmap(file, true); if (bitmap.parseHeaders() == BmpReaderError::Ok) { LOG_DBG("SLP", "Loading: /sleep.bmp"); - renderBitmapSleepScreen(bitmap, overlayInfo); + const BookOverlayInfo resolvedOverlayInfo = + shouldLoadOverlayInfo ? getBookOverlayInfo(APP_STATE.openEpubPath) : overlayInfo; + renderBitmapSleepScreen(bitmap, resolvedOverlayInfo); file.close(); return; }