diff --git a/css/icons.scss b/css/icons.scss index c782f125d..6f2f35167 100644 --- a/css/icons.scss +++ b/css/icons.scss @@ -22,7 +22,9 @@ .icon-activity { @include icon-color('activity-dark', 'activity', $color-black); } - +.icon-comment--unread { + @include icon-color('comment', 'actions', $color-primary, 1, true); +} .avatardiv.circles { background: var(--color-primary); diff --git a/lib/Db/Card.php b/lib/Db/Card.php index 4168c7fe2..af2c665c5 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -49,6 +49,7 @@ class Card extends RelationalEntity { protected $notified = false; protected $deletedAt = 0; protected $commentsUnread = 0; + protected $commentsCount = 0; protected $relatedStack = null; protected $relatedBoard = null; @@ -75,6 +76,7 @@ class Card extends RelationalEntity { $this->addRelation('attachmentCount'); $this->addRelation('participants'); $this->addRelation('commentsUnread'); + $this->addRelation('commentsCount'); $this->addResolvable('owner'); $this->addRelation('relatedStack'); diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 629185e21..0cb733c54 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -105,8 +105,10 @@ class CardService { $card->setAttachmentCount($this->attachmentService->count($cardId)); $user = $this->userManager->get($this->currentUser); $lastRead = $this->commentsManager->getReadMark('deckCard', (string)$card->getId(), $user); - $count = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId(), $lastRead); - $card->setCommentsUnread($count); + $countUnreadComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId(), $lastRead); + $countComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId()); + $card->setCommentsUnread($countUnreadComments); + $card->setCommentsCount($countComments); $stack = $this->stackMapper->find($card->getStackId()); $board = $this->boardService->find($stack->getBoardId()); diff --git a/src/components/card/CardSidebarTabComments.vue b/src/components/card/CardSidebarTabComments.vue index ffbac760c..d10260cb6 100644 --- a/src/components/card/CardSidebarTabComments.vue +++ b/src/components/card/CardSidebarTabComments.vue @@ -7,7 +7,11 @@ - +
    @@ -23,8 +27,8 @@
-
-

{{ t('deck', 'No comments yet. Begin the discussion!') }}

+
+

{{ error || t('deck', 'No comments yet. Begin the discussion!') }}

@@ -36,6 +40,7 @@ import CommentItem from './CommentItem' import CommentForm from './CommentForm' import InfiniteLoading from 'vue-infinite-loading' import { getCurrentUser } from '@nextcloud/auth' + export default { name: 'CardSidebarTabComments', components: { @@ -60,6 +65,7 @@ export default { newComment: '', isLoading: false, currentUser: getCurrentUser(), + error: null, } }, computed: { @@ -85,19 +91,34 @@ export default { }, methods: { async infiniteHandler($state) { - await this.loadMore() - if (this.hasMoreComments(this.card.id)) { - $state.loaded() - } else { + this.error = null + try { + await this.loadMore() + if (this.hasMoreComments(this.card.id)) { + $state.loaded() + } else { + $state.complete() + } + } catch (e) { + console.error('Failed to fetch more comments during infinite loading', e) + this.error = t('deck', 'Failed to load comments') $state.complete() } }, async loadComments() { + this.$store.dispatch('setReplyTo', null) + this.error = null 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) + try { + 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) + } + } catch (e) { + this.isLoading = false + console.error('Failed to fetch more comments during infinite loading', e) + this.error = t('deck', 'Failed to load comments') } }, async createComment(content) { @@ -115,6 +136,9 @@ export default { await this.$store.dispatch('fetchMore', { cardId: this.card.id }) this.isLoading = false }, + cancelReply() { + this.$store.dispatch('setReplyTo', null) + }, }, } diff --git a/src/components/card/CommentForm.vue b/src/components/card/CommentForm.vue index 69714b66b..028f7ef02 100644 --- a/src/components/card/CommentForm.vue +++ b/src/components/card/CommentForm.vue @@ -41,6 +41,7 @@
@import '../../css/comments'; + .comment-form__contenteditable { + word-break: break-word; + border-radius: var(--border-radius-large) + } + .atwho-wrap { width: 100%; & > div[contenteditable] { diff --git a/src/components/card/CommentItem.vue b/src/components/card/CommentItem.vue index 70d10a2f0..118ad0f4e 100644 --- a/src/components/card/CommentItem.vue +++ b/src/components/card/CommentItem.vue @@ -1,10 +1,22 @@