feat: show loading popup in BookInfo when parsing unopened book
When BookInfo is opened for a book with no existing cache, epub.load(true, true) triggers a 1-2s full parse. Show a "Loading..." popup with progress bar so the device doesn't appear frozen. Popup only appears on the fallback path — cached books load silently. Same pattern for XTC books. Made-with: Cursor
This commit is contained in:
23
chat-summaries/2026-03-09_03-15-summary.md
Normal file
23
chat-summaries/2026-03-09_03-15-summary.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# BookInfo Loading Popup for Unopened Books
|
||||||
|
|
||||||
|
**Date**: 2026-03-09
|
||||||
|
**Task**: Show a progress popup when BookInfo needs to parse an unopened book
|
||||||
|
|
||||||
|
## Changes Made
|
||||||
|
|
||||||
|
### BookInfoActivity.cpp
|
||||||
|
|
||||||
|
Added a "Loading..." progress popup with progress bar to `onEnter()` when the book cache doesn't exist and a full parse is required:
|
||||||
|
|
||||||
|
- **EPUB branch**: `epub.load(false, true)` is tried first (fast, cache-only). If it fails, `GUI.drawPopup(tr(STR_LOADING))` is shown at 10%, `epub.load(true, true)` runs (slow full parse), progress updates to 50%, thumbnail generation runs, then progress hits 100%.
|
||||||
|
- **XTC branch**: Checks `Storage.exists(xtc.getCachePath())` before `xtc.load()`. If cache directory is missing, shows the same popup pattern around load + thumbnail generation.
|
||||||
|
- For books with existing cache, no popup is shown — the fast path completes silently.
|
||||||
|
|
||||||
|
## Build Result
|
||||||
|
|
||||||
|
Build succeeded — 0 errors, 0 linter warnings. RAM: 30.3%, Flash: 95.7%.
|
||||||
|
|
||||||
|
## Follow-up
|
||||||
|
|
||||||
|
- Test on device: open BookInfo for a book that has never been opened, verify popup appears
|
||||||
|
- Verify no popup appears for books that have been previously opened/cached
|
||||||
@@ -63,10 +63,15 @@ void BookInfoActivity::onEnter() {
|
|||||||
|
|
||||||
if (FsHelpers::hasEpubExtension(fileName)) {
|
if (FsHelpers::hasEpubExtension(fileName)) {
|
||||||
Epub epub(filePath, "/.crosspoint");
|
Epub epub(filePath, "/.crosspoint");
|
||||||
if (!epub.load(false, true)) {
|
bool needsBuild = !epub.load(false, true);
|
||||||
|
Rect popupRect{};
|
||||||
|
if (needsBuild) {
|
||||||
|
popupRect = GUI.drawPopup(renderer, tr(STR_LOADING));
|
||||||
|
GUI.fillPopupProgress(renderer, popupRect, 10);
|
||||||
epub.load(true, true);
|
epub.load(true, true);
|
||||||
|
GUI.fillPopupProgress(renderer, popupRect, 50);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
title = epub.getTitle();
|
title = epub.getTitle();
|
||||||
author = epub.getAuthor();
|
author = epub.getAuthor();
|
||||||
series = epub.getSeries();
|
series = epub.getSeries();
|
||||||
@@ -85,10 +90,21 @@ void BookInfoActivity::onEnter() {
|
|||||||
coverBmpPath = placeholderPath;
|
coverBmpPath = placeholderPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (needsBuild) {
|
||||||
|
GUI.fillPopupProgress(renderer, popupRect, 100);
|
||||||
}
|
}
|
||||||
} else if (FsHelpers::hasXtcExtension(fileName)) {
|
} else if (FsHelpers::hasXtcExtension(fileName)) {
|
||||||
Xtc xtc(filePath, "/.crosspoint");
|
Xtc xtc(filePath, "/.crosspoint");
|
||||||
|
bool needsBuild = !Storage.exists(xtc.getCachePath().c_str());
|
||||||
|
Rect popupRect{};
|
||||||
|
if (needsBuild) {
|
||||||
|
popupRect = GUI.drawPopup(renderer, tr(STR_LOADING));
|
||||||
|
GUI.fillPopupProgress(renderer, popupRect, 10);
|
||||||
|
}
|
||||||
if (xtc.load()) {
|
if (xtc.load()) {
|
||||||
|
if (needsBuild) {
|
||||||
|
GUI.fillPopupProgress(renderer, popupRect, 50);
|
||||||
|
}
|
||||||
title = xtc.getTitle();
|
title = xtc.getTitle();
|
||||||
author = xtc.getAuthor();
|
author = xtc.getAuthor();
|
||||||
|
|
||||||
@@ -104,6 +120,9 @@ void BookInfoActivity::onEnter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (needsBuild) {
|
||||||
|
GUI.fillPopupProgress(renderer, popupRect, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title.empty()) {
|
if (title.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user