Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity Briefly Enters a Truncated State Before Deletion When Using Vuex-ORM Axios Plugin when i dont add delete option #178

Open
ivan006 opened this issue Aug 15, 2023 · 0 comments

Comments

@ivan006
Copy link

ivan006 commented Aug 15, 2023

Describe the bug

When a delete request is made using the Vuex-ORM Axios plugin, the entity in the Vuex store is first updated to a "truncated" state, with fields set to default or null values, before it is removed from the store. This leads to a jarring and confusing UI experience, where the user sees the entity in this truncated state briefly before it disappears.

Steps to reproduce the bug

  1. Define models

    • Example: User, with fields id, first_name, last_name, etc.
  2. Create data

    • Example: Create a User with id: 5, first_name: 'John', last_name: 'Doe'.
  3. Retrieve data

    • Example: Fetch the user data using User.api().get(...).
  4. Delete data

    • Example: Delete a user using User.api().delete('/api/users/5').
        static Delete(entityId) {
         return this.api().delete(`/users/${entityId}`, {
             baseURL: "http://example.test/api/v4",
             headers: {
                 ...Mixin.methods.DefaultHeaders(),
             },
             /// delete: entityId,
         });
     }
    
  5. See error

    • In the UI, observe that the user data is first set to a truncated state like { "$id": "$uid3", "id": "$uid3", "first_name": "", "last_name": "", ... } before being deleted.

Expected behavior

When a delete request is made, I expect that the entity not deleted (because I didn't add delete: entityId) until the request is complete (which happens) without first transitioning to a truncated state (doesn't happen it does go through this state which is weird). The deletion should happen smoothly without showing an intermediate, confusing state to the users.

Versions

"@vuex-orm/core": "^0.36.3",
"@vuex-orm/plugin-axios": "^0.9.3",
@ivan006 ivan006 changed the title Entity Briefly Enters a Truncated State Before Deletion When Using Vuex-ORM Axios Plugin Entity Briefly Enters a Truncated State Before Deletion When Using Vuex-ORM Axios Plugin when i dont add delete option Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant