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

[WIP] fix #247 comment patch and delete addressed #347

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
18 changes: 0 additions & 18 deletions .env.example

This file was deleted.

8 changes: 3 additions & 5 deletions components/Comments/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@
<form class="comment-form" @submit.prevent="patchComment" v-else>
<hc-editor identifier="comment"
editorClass="autowrap"
v-on:input="editorText"
v-model="newContent"
:editorOptions="editorOptions" />
<div class="comment-form-actions">
<hc-button
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 @@ -170,9 +169,7 @@
remove: 'comments/remove',
patch: 'comments/patch'
}),
editorText (newText) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, the editorText method was used to show the confirmation dialog, when a user accidently or intentionally clicked a button to leave the current page. So your latest changes would not be lost. @ionphractal could you confirm?

Actually I would love to see you @Gerald1614 pair-program with a community member. @Gerald1614 did you join our Discord Server already? You can organize a pair-programming with e.g. @ionphractal. He speaks perfect English as far as I know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's the invitation link to our public Discord Server: https://discord.gg/6ub73U3

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I am on discord. i have a very busy week but i will use discord to contact @ionphractal. I will be happy to spend time with him. it will be easier than playign ping pong with chat messages. thanks, Gerald

this.$emit('input', newText)
},

removeComment () {
this.$dialog.confirm({
title: this.$t('component.contribution.commentDelete'),
Expand All @@ -187,6 +184,7 @@
startEdit () {
this.fetchById(this.comment._id)
.then((res) => {
console.log(res.content)
Lulalaby marked this conversation as resolved.
Show resolved Hide resolved
this.newContent = res.content
this.edit = true
this.fullContentShown = false;
Expand Down
5 changes: 1 addition & 4 deletions components/Comments/CommentForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<form class="comment-form" @submit.prevent="submitComment">
<hc-editor identifier="comment"
ref="editor"
v-on:input="editorText"
editorClass="autowrap"
v-model="form.content"
:editorOptions="editorOptions" />
Expand Down Expand Up @@ -77,9 +76,7 @@
}
},
methods: {
editorText (newText) {
this.$emit('input', newText)
},

reply (comment) {
if (!comment) {
return
Expand Down
1 change: 0 additions & 1 deletion components/Comments/Comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</div>
<transition-group v-else-if="comments.length >= 1" name="comment" tag="div">
<comment @reply="onReply"
v-on:input="editorText"
v-for="comment in comments"
:isAuthor="comment.userId === post.userId"
:isOwner="comment.userId === user._id"
Expand Down
16 changes: 14 additions & 2 deletions store/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const mutations = {
clear (state) {
state.comments = []
},
removeComment (state, id) {
const cmt = state.comments[state.comments.findIndex(comment => comment._id === id)]
console.log(cmt)
cmt.deleted = true
},
setContributionId (state, contributionId) {
state.contributionId = contributionId
}
Expand Down Expand Up @@ -111,10 +116,17 @@ export const actions = {
create ({dispatch}, data) {
return this.app.$api.service('comments').create(data)
},
patch ({dispatch}, data) {
patch ({dispatch, commit}, data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove obsolete argument dispatch if possible

return this.app.$api.service('comments').patch(data._id, data)
Lulalaby marked this conversation as resolved.
Show resolved Hide resolved
.then(() => {
commit('set', data.content)
})
},
remove ({dispatch}, id) {
remove ({commit}, id) {
commit('removeComment', id)
return this.app.$api.service('comments').remove(id)
// .then(() => {
// commit('removeComment', id)
// })
Gerald1614 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading