455df18dad
Two bugs were causing chapters to disappear on every relaunch: 1. seedTextbookData used `try? context.save()` (swallowing errors) and returned `inserted > 0`, so a failed save still reported success. Callers then bumped UserDefaults textbookDataVersion and subsequent launches skipped the re-seed entirely — with no rows on disk. 2. refreshTextbookDataIfNeeded wiped chapters via the batch-delete API `context.delete(model: TextbookChapter.self)`, which hits the store directly without clearing the context's .unique-id index. Re-inserting chapters with the same ids could then throw a unique-constraint error on save — also silently eaten by `try?`. Fixes: - seedTextbookData now uses do/catch around save(), returns false on error, and verifies persistence via fetchCount before returning true. - refreshTextbookDataIfNeeded fetches and deletes chapters individually so the context tracks the deletion cleanly; wipe save is also now checked and bails early on failure. - Bumped textbookDataVersion to 11 so devices poisoned by the previous silent-failure path retry on next launch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>