Update read marker

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-01-31 13:22:43 +01:00
parent 1731cbd5ee
commit 41d286986b
5 changed files with 35 additions and 2 deletions

View File

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

View File

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

View File

@@ -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'],

View File

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

View File

@@ -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)
}
},
}