@@ -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