[#50]: Build Prepare for Offline chapter selection#175
Open
mattrace-gloo wants to merge 2 commits into
Open
Conversation
Add project picker, chapter selection accordion with per-book grids, and a dedicated prepare-offline query module to avoid conflicts with in-flight recording PRs.
Sync role-filtered chapter assignments from the web My Work endpoint, auto-repair stale local data on launch, and show a cloud indicator when download sync is needed. Refactors Prepare for Offline components and Settings/header layout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Implements Prepare for Offline chapter selection (#50) and fixes My Work showing empty after sync by pulling role-filtered assignments from the same endpoint the web app uses. Adds a cloud icon state and auto-sync when local assignment data is incomplete.
Reviewer checklist
Closes #NNNwhen this PR completes it)AGENTS.md)Details
Closes #50
Prepare for Offline (#50): Project picker when opened from Settings, collapsible chapter accordion grouped by book, per-book select-all, and a 5-column chapter grid. Assigned users get pre-selected assigned chapters with a collapsed accordion; unassigned users start with an empty selection and expanded accordion. Optional
{ projectId, projectName }route params for future #39 trigger.My Work sync fix: Mobile previously synced only
GET /users/:id/chapter-assignments/all, which returns project chapters without assignee fields populated. Web My Work usesGET /users/:id/chapter-assignments(role-filtered). Sync now calls both endpoints;userNeedsAssigneeRepair()forces a full re-sync when local chapters exist but no assignee/checker is set. My Work filter includesnot_startedanddraftstages for assignees.Cloud sync UX: New
online_needs_syncstatus shows an amber refresh overlay on the cloud icon when download sync is needed. Home auto-triggers sync once per session when incomplete local data is detected while online.UI polish: Settings screen OFFLINE section layout, shared header safe-area padding, status-bar/header fixes on stack screens.
Type of change:
Technical changes
src/db/queries.prepareOffline.ts— project chapters withassigned_user_idsrc/hooks/usePrepareOfflineSelection.ts— selection state, assigned/unassigned init, accordion defaultssrc/app/prepare-offline/—ProjectPickerStep,ChapterSelectionAccordion,BookChapterSection,BookSectionHeader,ChapterSelectorGrid,SelectionCheckboxsrc/services/sync.ts—syncUserChapterWork(), assignee repair on stale local datasrc/services/api.ts—getUserChapterAssignments()src/db/repository.ts—userNeedsAssigneeRepair()src/hooks/useLocalSyncHealth.ts— detects incomplete local assignment datasrc/utils/syncStatusState.ts—online_needs_syncstatussrc/components/ui/CloudSyncStatusIcon.tsx— amber refresh glyph for updates availablesrc/app/screens/HomeScreen.tsx— auto-sync when local data needs repairLines changed: ~1,500 | Files modified: 42
Testing
npm run format:check— passnpm run lint— passnpm run typecheck— passnpm test -- --ci— 179 passedNew tests:
groupChaptersByBook.test.ts,usePrepareOfflineSelection.test.ts,ChapterSelectorGrid.test.tsx,PrepareForOfflineScreen.test.tsx,useLocalSyncHealth.test.ts,syncStatusState.test.ts(needs-sync cases),mapChapterAssignment.test.tsHow to verify
npm run format:check && npm run lint && npm run typecheck && npm test -- --cimrace+t@gloo.uson dev) → confirm My Work populates without manually tapping sync; cloud icon briefly shows amber then syncsExpected: My Work shows assigned chapters after launch sync; cloud icon reflects stale data; chapter selection UI matches #50 scope. No download button or resource tiers (#51 deferred).
Follow-ups
{ projectId, projectName }route params; picker skipped when params present