Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .env.example

This file was deleted.

11 changes: 4 additions & 7 deletions components/Comments/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
class="button is-hidden-mobile"
color="light"
:disabled="isLoading"
@click="cancelEdit">
@click.prevent="cancelEdit">
{{ $t('button.cancel') }}
</hc-button>
<hc-button
Expand Down Expand Up @@ -140,7 +140,8 @@
computed: {
...mapGetters({
showComment: 'comments/showComment',
user: 'auth/user'
user: 'auth/user',
fetchById: 'comments/fetchById',
}),
getText () {
return (this.fullContentShown && this.content)
Expand All @@ -166,7 +167,6 @@
},
methods: {
...mapActions({
fetchById: 'comments/fetchById',
remove: 'comments/remove',
patch: 'comments/patch'
}),
Expand All @@ -185,12 +185,9 @@
})
},
startEdit () {
this.fetchById(this.comment._id)
.then((res) => {
this.newContent = res.content
this.newContent = this.fetchById(this.comment._id).contentExcerpt
this.edit = true
this.fullContentShown = false;
})
},
cancelEdit () {
this.edit = false
Expand Down
26 changes: 21 additions & 5 deletions store/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -43,6 +50,9 @@ export const getters = {
},
count (state) {
return state.commentCount
},
fetchById: (state) => (id) => {
return state.comments.find(comment => comment._id === id)
}
}

Expand Down Expand Up @@ -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: {
Expand All @@ -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)
})
}
}