Skip to content

Implement optimistic UI updates for admin role assignment #243

Description

@Lakes41

Difficulty: Advanced | Type: Feature / Performance

Background: POST /v1/members/:address/roles assigns a role to a member from the admin dashboard.

Problem: Without optimistic updates, the admin sees no immediate feedback in the member list/detail view until the round-trip completes, which feels sluggish especially over a real network in live mode.

Expected Outcome: The UI immediately reflects the intended role change optimistically, then reconciles with the server response — rolling back cleanly and showing an error toast (from #20) if the mutation actually fails.

Suggested Implementation: Use React Query's useMutation onMutate/onError/onSettled lifecycle to snapshot and optimistically update the relevant cached member record, rolling back to the snapshot on failure, building on the query-key strategy from #22.

Acceptance Criteria:

  • Role change appears instantly in the UI on submit.
  • A simulated failure (mock mode error scenario) correctly rolls back the optimistic change and shows an error.
  • No duplicate/ghost roles appear after a slow-but-successful mutation.

Likely Affected Files/Directories: app/admin/*, lib/api/

Labels: feature, performance, GrantFox OSS, Maybe Rewarded, Official Campaign | FWC26

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsfeatureNew feature, enhancement, or functional additionperformancePerformance optimization or latency/throughput improvement work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions