Skip to content

[FE-96] Optimistic updates and consistent React Query cache invalidation #1195

Description

@yusuftomilola

Overview

lib/query/keys.ts already defines a well-structured key factory — good foundation. What is missing is consistent invalidation on mutation, so stale data lingers after edits.

Tasks

  • Extend the key factory to cover transfers, notifications, locations, and inventory as those land.
  • Set sensible global defaults (staleTime, retry, refetchOnWindowFocus) in the query provider.
  • Add optimistic updates with rollback for high-frequency mutations: status change, assign, mark notification read, add note.
  • Invalidate every affected key after a mutation — approving a transfer must refresh the transfer list, the asset detail, the asset history, and dashboard counts.
  • Add prefetching on hover for list → detail navigation.
  • Document the conventions so contributors follow them.

Acceptance Criteria

  • Mutations update the UI immediately and roll back cleanly on error.
  • No stale list remains after a create, update, or delete.
  • All query keys come from the factory — no inline key arrays.

Notes for Contributors

Comment below to be assigned.

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