Skip to content

useProofSubmit creates full submission state tree at HomeScreen level unnecessarily #56

Description

@cybermax4200

Why this matters now: HomeScreen.tsx:52 calls useProofSubmit(), which instantiates isSubmitting, progress, error, pendingCount, and the full submit/syncPendingProofs callback tree. HomeScreen only uses pendingCount, isSubmitting (for the sync banner), and syncPendingProofs. The submit function, progress, and error state are wasted allocations on the most-rendered screen in the app.

Problem / What: src/screens/HomeScreen.tsx:52const { pendingCount, isSubmitting, syncPendingProofs } = useProofSubmit() — but useProofSubmit() creates useState for isSubmitting, progress, error, pendingCount on every mount, plus two useCallback wrappers.

Key Challenges:

  • Split useProofSubmit into two hooks: usePendingProofs() (returns pendingCount, isSyncing, syncPendingProofs) and useProofSubmit() (returns submit, progress, error, isSubmitting).
  • usePendingProofs only manages the queue count and sync; useProofSubmit manages the full submission flow.
  • HomeScreen uses usePendingProofs; SubmitProofScreen uses useProofSubmit.
  • Both hooks share the same proofQueue module but don't share React state.
  • The split must not break the proofSyncStore interaction.

Acceptance Criteria:

  • HomeScreen only instantiates pending-proof state, not full submission state.
  • SubmitProofScreen uses the full useProofSubmit hook.
  • No behavioral change — proof submission, queuing, and sync work identically.
  • HomeScreen renders fewer state updates when proof state changes.
  • Tests for both hooks independently.

Relevant files/functions:

  • src/hooks/useProofSubmit.ts (split into two hooks)
  • src/screens/HomeScreen.tsx:52
  • src/screens/SubmitProofScreen.tsx:42
  • src/__tests__/ (new tests for split hooks)

Out of scope: Global proof state management via Zustand (future optimization).

Labels: architecture, intermediate, performance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions