@@ -88,6 +88,9 @@ export default {
|
||||
this.isLoading = true
|
||||
await this.$store.dispatch('fetchComments', { cardId: this.card.id })
|
||||
this.isLoading = false
|
||||
if (this.card.commentsUnread > 0) {
|
||||
await this.$store.dispatch('markCommentsAsRead', this.card.id)
|
||||
}
|
||||
},
|
||||
async createComment(content) {
|
||||
const commentObj = {
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
|
||||
<template>
|
||||
<div class="badges">
|
||||
<div v-if="card.description" class="card-comments icon icon-edit" />
|
||||
<div v-if="card.description" class="icon icon-edit" />
|
||||
|
||||
<div v-if="card.commentsUnread > 0" class="icon icon-comment" />
|
||||
|
||||
|
||||
<div v-if="card.duedate" :class="dueIcon">
|
||||
<span>{{ dueTime }}</span>
|
||||
|
||||
@@ -52,6 +52,7 @@ const commentToObject = (tag) => {
|
||||
actorDisplayName: tag['d:prop']['oc:actorDisplayName']['#text'],
|
||||
creationDateTime: tag['d:prop']['oc:creationDateTime']['#text'],
|
||||
message: tag['d:prop']['oc:message']['#text'],
|
||||
isUnread: tag['d:prop']['oc:isUnread']['#text'] === 'true',
|
||||
mentions: mentions.map((mention) => {
|
||||
return {
|
||||
mentionType: mention['oc:mentionType']['#text'],
|
||||
|
||||
@@ -112,4 +112,21 @@ export class CommentApi {
|
||||
return response.data
|
||||
}
|
||||
|
||||
async markCommentsAsRead(cardId) {
|
||||
const readMarker = (new Date()).toUTCString()
|
||||
const response = await axios({
|
||||
method: 'PROPPATCH',
|
||||
url: this.url(`${cardId}`),
|
||||
data: `<?xml version="1.0"?>
|
||||
<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
|
||||
<d:set>
|
||||
<d:prop>
|
||||
<oc:readMarker>${readMarker}</oc:readMarker>
|
||||
</d:prop>
|
||||
</d:set>
|
||||
</d:propertyupdate>`,
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,11 +68,16 @@ export default {
|
||||
}
|
||||
},
|
||||
deleteComment(state, comment) {
|
||||
const existingIndex = state.comments[comment.cardId].comments.findIndex(_comment => _comment.id === comment.commentId)
|
||||
const existingIndex = state.comments[comment.cardId].comments.findIndex(_comment => _comment.id === comment.id)
|
||||
if (existingIndex !== -1) {
|
||||
state.comments[comment.cardId].comments.splice(existingIndex, 1)
|
||||
}
|
||||
},
|
||||
markCommentsAsRead(state, cardId) {
|
||||
state.comments[cardId].comments.forEach(_comment => {
|
||||
Vue.set(_comment, 'isUnread', false)
|
||||
})
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async fetchComments({ commit }, { cardId, offset }) {
|
||||
@@ -111,5 +116,9 @@ export default {
|
||||
const commentData = await apiClient.fetchComment(data)
|
||||
await commit('updateComment', { cardId: data.cardId, comment: commentData[0] })
|
||||
},
|
||||
async markCommentsAsRead({ commit }, cardId) {
|
||||
await apiClient.markCommentsAsRead(cardId)
|
||||
await commit('markCommentsAsRead', cardId)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user