diff --git a/.env.example b/.env.example deleted file mode 100644 index 0a3085cb..00000000 --- a/.env.example +++ /dev/null @@ -1,18 +0,0 @@ -# WEBAPP -WEBAPP_HOST = localhost -WEBAPP_PORT = 3000 -WEBAPP_BASE_URL = http://localhost:3000 - -# API -API_HOST = localhost -API_PORT = 3030 - -# METAAPI -EMBED_API_URL = http://localhost:3050 - -# 3rd party integrations -SENTRY_DNS_PUBLIC = -MAPBOX_TOKEN = pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ - -# MAINTENANCE -MAINTENANCE = diff --git a/components/Comments/Comment.vue b/components/Comments/Comment.vue index 92f38c6c..4e2a234d 100644 --- a/components/Comments/Comment.vue +++ b/components/Comments/Comment.vue @@ -50,7 +50,7 @@ class="button is-hidden-mobile" color="light" :disabled="isLoading" - @click="cancelEdit"> + @click.prevent="cancelEdit"> {{ $t('button.cancel') }} { - this.newContent = res.content + this.newContent = this.fetchById(this.comment._id).contentExcerpt this.edit = true this.fullContentShown = false; - }) }, cancelEdit () { this.edit = false diff --git a/store/comments.js b/store/comments.js index 76ea3e90..a2024ff5 100644 --- a/store/comments.js +++ b/store/comments.js @@ -28,6 +28,13 @@ export const mutations = { }, setContributionId (state, contributionId) { state.contributionId = contributionId + }, + updateComment (state, data) { + state.comments[state.comments.findIndex(comment => comment._id === data._id)].contentExcerpt = data.content + }, + removeComment (state, id) { + const cmt = state.comments[state.comments.findIndex(comment => comment._id === id)] + cmt.deleted = true } } @@ -43,6 +50,9 @@ export const getters = { }, count (state) { return state.commentCount + }, + fetchById: (state) => (id) => { + return state.comments.find(comment => comment._id === id) } } @@ -96,9 +106,9 @@ export const actions = { commit('isLoading', false) }) }, - fetchById ({commit}, id) { - return this.app.$api.service('comments').get(id) - }, + // fetchById ({commit}, id) { + // return this.app.$api.service('comments').get(id) + // }, upvote ({dispatch}, comment) { return this.app.$api.service('comments').patch(comment._id, { $inc: { @@ -111,10 +121,16 @@ export const actions = { create ({dispatch}, data) { return this.app.$api.service('comments').create(data) }, - patch ({dispatch}, data) { + patch ({commit}, data) { return this.app.$api.service('comments').patch(data._id, data) + .then(() => { + commit('updateComment', data) + }) }, - remove ({dispatch}, id) { + remove ({commit}, id) { return this.app.$api.service('comments').remove(id) + .then(() => { + commit('removeComment', id) + }) } }