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

vuex #21

Closed
nadar opened this issue May 29, 2021 · 6 comments
Closed

vuex #21

nadar opened this issue May 29, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@nadar
Copy link

nadar commented May 29, 2021

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

@Aymkdn
Copy link
Owner

Aymkdn commented May 29, 2021

Did you check this: #13 ?

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

@Aymkdn Aymkdn added the enhancement New feature or request label May 29, 2021
@nadar
Copy link
Author

nadar commented May 29, 2021

I can do a PR if you like?

@Aymkdn
Copy link
Owner

Aymkdn commented May 29, 2021

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.

@nadar
Copy link
Author

nadar commented May 29, 2021

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

Aymkdn added a commit that referenced this issue May 30, 2021
@Aymkdn
Copy link
Owner

Aymkdn commented May 30, 2021

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

@Aymkdn Aymkdn closed this as completed May 30, 2021
@nadar
Copy link
Author

nadar commented May 30, 2021

Thanks @Aymkdn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants