Skip to content

Commit df36415

Browse files
theohollgrnd-alt
authored andcommitted
Merge API wrappers into store actions
Signed-off-by: Theo <36564257+theoholl@users.noreply.github.com>
1 parent ad27be6 commit df36415

3 files changed

Lines changed: 10 additions & 20 deletions

File tree

src/components/card/CardSidebarTabComments.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default {
126126
await this.commentStore.fetchComments({ cardId: this.card.id })
127127
this.isLoading = false
128128
if (this.card.commentsUnread > 0) {
129-
await this.commentStore.apiMarkCommentsAsRead(this.card.id)
129+
await this.commentStore.markCommentsAsRead(this.card.id)
130130
}
131131
} catch (e) {
132132
this.isLoading = false

src/components/card/CommentItem.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,18 @@ export default {
196196
},
197197
async updateComment() {
198198
const data = {
199-
comment: this.commentMsg,
199+
comment: { id: this.comment.id, message: this.commentMsg },
200200
cardId: this.comment.objectId,
201-
id: this.comment.id,
202201
}
203-
await this.commentStore.apiUpdateComment(data)
202+
await this.commentStore.updateComment(data)
204203
this.hideUpdateForm()
205204
},
206205
deleteComment() {
207206
const data = {
208207
id: this.comment.id,
209208
cardId: this.comment.objectId,
210209
}
211-
this.commentStore.apiDeleteComment(data)
210+
this.commentStore.deleteComment(data)
212211
},
213212
},
214213
}

src/stores/comment.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,22 @@ export const useCommentStore = defineStore('comment', {
4646
this.comments[cardId].comments.push(...newComments)
4747
}
4848
},
49-
updateComment({ cardId, comment }) {
49+
async updateComment({ cardId, comment }) {
50+
const updatedComment = await apiClient.updateComment({ cardId, id: comment.id, comment: comment.message })
5051
const existingIndex = this.comments[cardId].comments.findIndex(c => c.id === comment.id)
5152
if (existingIndex !== -1) {
5253
Object.assign(this.comments[cardId].comments[existingIndex], comment)
5354
}
5455
},
55-
deleteComment(comment) {
56+
async deleteComment(comment) {
57+
await apiClient.deleteComment(comment)
5658
const existingIndex = this.comments[comment.cardId].comments.findIndex(_comment => _comment.id === comment.id)
5759
if (existingIndex !== -1) {
5860
this.comments[comment.cardId].comments.splice(existingIndex, 1)
5961
}
6062
},
61-
markCommentsAsRead(cardId) {
63+
async markCommentsAsRead(cardId) {
64+
await apiClient.markCommentsAsRead(cardId)
6265
this.comments[cardId].comments.forEach(_comment => {
6366
Vue.set(_comment, 'isUnread', false)
6467
})
@@ -88,17 +91,5 @@ export const useCommentStore = defineStore('comment', {
8891
await apiClient.createComment({ cardId, comment, replyTo: this.replyTo })
8992
await this.fetchComments({ cardId })
9093
},
91-
async apiDeleteComment(data) {
92-
await apiClient.deleteComment(data)
93-
this.deleteComment(data)
94-
},
95-
async apiUpdateComment(data) {
96-
const comment = await apiClient.updateComment(data)
97-
this.updateComment({ cardId: data.cardId, comment })
98-
},
99-
async apiMarkCommentsAsRead(cardId) {
100-
await apiClient.markCommentsAsRead(cardId)
101-
this.markCommentsAsRead(cardId)
102-
},
10394
},
10495
})

0 commit comments

Comments
 (0)