From c60efb0c807820aaee0c3944746322aa285bcefe Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Thu, 18 Jun 2020 15:16:12 +0300 Subject: [PATCH] fix: additional tag creation, when selecting from the suggestion --- .../components/snippets/SnippetView.vue | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/renderer/components/snippets/SnippetView.vue b/src/renderer/components/snippets/SnippetView.vue index 5469e8b..e9331f5 100644 --- a/src/renderer/components/snippets/SnippetView.vue +++ b/src/renderer/components/snippets/SnippetView.vue @@ -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') } }, @@ -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