/simplify pass: code-quality + efficiency batch #15

Merged
eliott merged 1 commit from develop into main 2026-05-15 11:49:28 +02:00
Owner

Summary

Batch from a /simplify pass across the Expo / React Native app.

  • constants/routes.ts replaces 12+ raw expo-router string literals
  • New ControlledInput / ControlledPasswordInput primitives collapse ~250 lines of <Controller>+<FormControl> duplication across 5 forms
  • RespirationExerciseModal converted from hand-rolled FormErrors to react-hook-form; new DurationStepper extracted from three repeated minus/value/plus blocks
  • Module-level in-memory access token in hooks/api.tsx removes the SecureStore round-trip on every authenticated request. Module-level (not useAuth) to avoid a circular useAuth↔useApi cycle — AuthProvider itself calls apiFetch for /user/login
  • InformationPageList and RelaxationActivityList migrated to FlatList; cards React.memo'd on (id, isFavorite)
  • AuthContext login-error mapping replaced with a status→row lookup table
  • Stress-diagnostic detail parallelizes its two independent fetches with Promise.all
  • types/api.ts switched to a discriminated ApiSuccess<T> | ApiError union; _apiFetchImpl drops the as unknown as cast

Test plan

  • pnpm exec tsc --noEmit — clean
  • Cold-start, log in, verify in-memory token shortcut on subsequent requests
  • Scroll activities / info-pages lists — confirm FlatList virtualization
  • Submit each migrated form (register, login, update email/info/password, respiration exercise)
  • Trigger 401 mid-session and confirm AuthContext error map + logout

🤖 Generated with Claude Code

## Summary Batch from a /simplify pass across the Expo / React Native app. - `constants/routes.ts` replaces 12+ raw expo-router string literals - New `ControlledInput` / `ControlledPasswordInput` primitives collapse ~250 lines of `<Controller>+<FormControl>` duplication across 5 forms - `RespirationExerciseModal` converted from hand-rolled `FormErrors` to `react-hook-form`; new `DurationStepper` extracted from three repeated minus/value/plus blocks - Module-level in-memory access token in `hooks/api.tsx` removes the SecureStore round-trip on every authenticated request. Module-level (not `useAuth`) to avoid a circular `useAuth`↔`useApi` cycle — AuthProvider itself calls `apiFetch` for `/user/login` - `InformationPageList` and `RelaxationActivityList` migrated to `FlatList`; cards `React.memo`'d on `(id, isFavorite)` - AuthContext login-error mapping replaced with a status→row lookup table - Stress-diagnostic detail parallelizes its two independent fetches with `Promise.all` - `types/api.ts` switched to a discriminated `ApiSuccess<T> | ApiError` union; `_apiFetchImpl` drops the `as unknown as` cast ## Test plan - [ ] `pnpm exec tsc --noEmit` — clean - [ ] Cold-start, log in, verify in-memory token shortcut on subsequent requests - [ ] Scroll activities / info-pages lists — confirm `FlatList` virtualization - [ ] Submit each migrated form (register, login, update email/info/password, respiration exercise) - [ ] Trigger 401 mid-session and confirm AuthContext error map + logout 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- constants/routes.ts replaces 12+ raw expo-router string literals
- New ControlledInput / ControlledPasswordInput primitives collapse ~250 lines of <Controller>+<FormControl> duplication across 5 forms
- RespirationExerciseModal converted to react-hook-form; new DurationStepper extracted from three repeated inline blocks
- Module-level in-memory access token in hooks/api.tsx eliminates the SecureStore round-trip on every authenticated request (kept module-level to avoid a circular useAuth/useApi hook cycle)
- InformationPageList and RelaxationActivityList migrated to FlatList; cards now React.memo'd with (id, isFavorite) comparator
- Home screen's latest-pages section wrapped in a memoized component to prevent unrelated re-renders
- AuthContext login error mapping replaced with a status->row lookup table
- Stress-diagnostic detail parallelizes its two independent fetches with Promise.all
- types/api.ts switched to a discriminated ApiSuccess<T>|ApiError union so _apiFetchImpl drops the `as unknown as` cast

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eliott merged commit 2cb7151ffa into main 2026-05-15 11:49:28 +02:00
Commenting is not possible because the repository is archived.
No reviewers
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bloc-cesi/cesizen-mobile!15
No description provided.