Aymkdn / v-snackbars

Display the `v-snackbar` (from Vuetify) with a stack display

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vuex

nadar opened this issue · comments

commented

We are storing the message in vuex to retrieve them later, this give us RANDOMLY the following exception:

v-snackbars.vue?6bee:216 Uncaught TypeError: Cannot read property '0' of undefined
    at VueComponent.removeMessage (v-snackbars.vue?6bee:216)
    at eval (v-snackbars.vue?6bee:183)

In this line:

// skip waiting if key does not exist
if(!this.$refs['v-snackbars-'+this.identifier][idx]) return
  1. Maybe we can check whether the index exists? at least to prevent this error.
  2. Could you make an example of how to integrate with vuex? I guess using a getter and setter is the most obvious solution:
computed: {
    snackbar: {
      get() {
        return this.$store.state.snackbar.items;
      },
      set(value) {
        this.$store.commit('snackbar/cleanup', value)
      }
    }
  }

We are really not sure how this error encounters, maybe when someone is closing the browser before last message i disapearing, maybe because vuex has contains still messages when loading the page. But when the error appears, the whole notification system broken, which is due to the above message. so we could just check whether the item exists in the index

Did you check this: #13 ?

And I'll add another check that the $refs exist. I'll probably do it tomorrow.

commented

I can do a PR if you like?

That's OK I'll change the code tomorrow. It's not complicated :) I'm not home today,, and I'll have to publish the changes to NPM, create a new release and so on. It's why I'll do it tomorrow.

commented

All right, thank you very much. Looking forward. Great library!

I've just published the new version that should solve this issue.

commented

Thanks @Aymkdn