Skip to content

Add Optimistic Updates and Offline Mutation Queuing for Expense Creation #384

Description

@Cjay-Cyber-2

Description — what to implement and the why/impact.

Users expect instant feedback when recording shared expenses, even on unstable mobile connections. This issue adds optimistic UI updates and mutation queue handling using TanStack React Query (@tanstack/react-query) so that expense creation appears instantly in the UI while syncing reliably with the backend API.

Context & Requirements — background, constraints, design references, edge cases; grounded in the actual repo (real files, stack, conventions).

Leverage @tanstack/react-query cache manipulation features (setQueryData, cancelQueries, onMutate) to update the group expense list optimistically. Handle rollback scenarios if the API call fails, and display appropriate toast notifications using sonner.

Acceptance Criteria — a checklist ("- [ ] ...") of specific, testable conditions that define "done".

  • Configure optimistic updates in expense creation mutation hooks.
  • Implement rollback logic on mutation failure with descriptive user error feedback via sonner.
  • Ensure cache keys match existing query patterns across group views.
  • Pass npm run typecheck and npm test.

Implementation Guidance — likely files/modules to touch (use real paths from the repo context) and a suggested approach, without over-prescribing.

  • Inspect existing query hooks and API wrapper functions.
  • Update mutation hooks in src/hooks/ or component files where expenses are submitted.

Testing & Validation — how the contributor should prove it works (tests to add/run, manual checks, screenshots for UI).

  • Test optimistic rendering by simulating network latency.
  • Run existing test suites to ensure no regressions.

Submission Guidelines — must open a PR that includes "Closes #"; assignment is required before starting; follow the repo's existing style and conventions.


Wave complexity: Medium

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions