Skip to content

Implement optimistic updates for API operations #98

Description

@romaintb

Now that confirmation dialogs have been removed, the UI feels sluggish waiting for API responses before updating. We need to implement optimistic updates to make the app feel fast and responsive.

Current State:

  • Local database acts as a read-only mirror of the API
  • UI updates only after successful API calls
  • This creates perceived latency even for simple operations

Desired Behavior:

  1. Optimistic updates: Immediately update local DB with expected results when user performs an action
  2. Non-blocking UI: User can continue interacting while API calls happen in background
  3. Rollback on failure: If API call fails, revert local DB to previous state
  4. Error handling: Display error notification/dialog when rollback occurs

Technical Considerations:

  • Need to track pending operations and their rollback data
  • Consider implementing a command/action pattern with undo capability
  • May need to differentiate between optimistic (unconfirmed) and confirmed data in the DB
  • Handle edge cases like multiple rapid actions on the same item
  • Consider conflict resolution if API state has changed since last sync

Activity

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions