vuex-easy-firestore: [Bug] modules with overlapping names batch improperly

      const groupId = 'fooBarBaz';
      await this.$store.dispatch("groups/insert", {
        id: groupId,
      });
      await this.$store.dispatch("usergroups/insert", {
        id: 'tootyFruity',
        groupId,
        userId: this.$store.state.profile.uid,
      });

Running both of those insert statements back to back causes two objects to be inserted into the groups collection rather than one in both:

[vuex-easy-firestore] api call batch:
index.esm.js?34ed:414 Firestore PATH: groups
index.esm.js?34ed:416 updates:  []
index.esm.js?34ed:416 prop deletions:  []
index.esm.js?34ed:416 deletions:  []
index.esm.js?34ed:416 inserts:  (2) [{…}, {…}]

Am I doing something wrong or is this a bug?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@BenAHammond I fixed the issue. Please do npm i vuex-easy-firestore@latest → make sure it’s at least version 1.15.2

about the issue

It was a problem with the state of each module being the same JavaScript object, because I had imported the default state object just as an object.

I was able to fix it by making the default state a function that returns the default state object instead of just an object. This way each module will have a different state object instead of a shared object.

You can see the change on these lines.

@BenAHammond was able to reproduce. Diving in to fix now.

@BenAHammond

Don’t worry, I won’t stop making this library awesome. I won’t give up on Vuex because I believe that VueJS version 3 (which is being worked on) and the next Vuex version are going to be awesome!

@BenAHammond Your code should be alright. Let me quickly try and reproduce this to see if it’s a bug or not. Thanks for the report!