Skip to content

Commit

Permalink
fix: additional tag creation, when selecting from the suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Jun 18, 2020
1 parent 5e7b299 commit c60efb0
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/renderer/components/snippets/SnippetView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,22 @@ export default {
},
async onAddTag (e) {
const { tag, addTag } = e
const newTag = await this.$store.dispatch('tags/addTag', {
name: tag.text.trim()
})
if (
!tag.tiClasses.includes('ti-duplicate') ||
!tag.tiClasses.includes('ti-invalid')
) {
if (newTag) {
addTag()
const payload = {
snippetId: this.selected._id,
tagId: newTag._id
}
track('tags/new')
this.$store.dispatch('snippets/addTag', payload)
addTag()
const newTag = await this.$store.dispatch('tags/addTag', {
name: tag.text.trim()
})
const payload = {
snippetId: this.selected._id,
tagId: newTag._id
}
track('tags/new')
this.$store.dispatch('snippets/addTag', payload)
track('tags/new-snippet-tag')
}
},
Expand All @@ -337,11 +336,13 @@ export default {
}
},
onAddTagFromAutocomplete (e) {
const payload = {
snippetId: this.selected._id,
tagId: e._id
if (e._id) {
const payload = {
snippetId: this.selected._id,
tagId: e._id
}
this.$store.dispatch('snippets/addTag', payload)
}
this.$store.dispatch('snippets/addTag', payload)
},
onChangeLayout (e) {
const { width } = e
Expand Down

0 comments on commit c60efb0

Please sign in to comment.