From 2aad2d6677bd7ccf530cf8b602f809399c2f143f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 23 Apr 2021 15:40:39 +0200 Subject: [PATCH 1/5] Proper error handling when fetching comments fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../card/CardSidebarTabComments.vue | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/components/card/CardSidebarTabComments.vue b/src/components/card/CardSidebarTabComments.vue index ffbac760c..c12d2eff8 100644 --- a/src/components/card/CardSidebarTabComments.vue +++ b/src/components/card/CardSidebarTabComments.vue @@ -23,8 +23,8 @@
-
-

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

+
+

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

@@ -60,6 +60,7 @@ export default { newComment: '', isLoading: false, currentUser: getCurrentUser(), + error: null, } }, computed: { @@ -85,19 +86,33 @@ 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.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) { From 3c6e6bb29c9102f6c0ec41c76f40a4da5b3b93b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 23 Apr 2021 15:40:55 +0200 Subject: [PATCH 2/5] Wrap lines properly in comment text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/card/CommentForm.vue | 5 +++++ src/css/comments.scss | 1 + 2 files changed, 6 insertions(+) diff --git a/src/components/card/CommentForm.vue b/src/components/card/CommentForm.vue index aae2acca4..5d38d35b9 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; + } + .atwho-wrap { width: 100%; & > div[contenteditable] { diff --git a/src/css/comments.scss b/src/css/comments.scss index e58da2e6a..f2fa497a2 100644 --- a/src/css/comments.scss +++ b/src/css/comments.scss @@ -48,4 +48,5 @@ .comment--content { margin-left: 44px; + word-break: break-word; } From 70cf89a52089a031952e349a4986201206810bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 23 Apr 2021 15:41:22 +0200 Subject: [PATCH 3/5] Fix faulty path when fetching comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/services/CommentApi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/CommentApi.js b/src/services/CommentApi.js index dae7b3e77..34109cdc8 100644 --- a/src/services/CommentApi.js +++ b/src/services/CommentApi.js @@ -31,7 +31,7 @@ export class CommentApi { } async loadComments({ cardId, limit, offset }) { - const api = await axios.get(generateOcsUrl(`apps/deck/api/v1.0/cards${cardId}/comments`), { + const api = await axios.get(generateOcsUrl(`apps/deck/api/v1.0/cards/${cardId}/comments`), { params: { limit, offset }, headers: { 'OCS-APIRequest': 'true' }, }) From 0a9c846ae993109976265bd4fad9a794bd2b2b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 23 Apr 2021 16:34:29 +0200 Subject: [PATCH 4/5] Allow to cancel repies and adapt comment ui to talk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../card/CardSidebarTabComments.vue | 11 ++- src/components/card/CommentForm.vue | 1 + src/components/card/CommentItem.vue | 75 +++++++++++++++---- 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/components/card/CardSidebarTabComments.vue b/src/components/card/CardSidebarTabComments.vue index c12d2eff8..d10260cb6 100644 --- a/src/components/card/CardSidebarTabComments.vue +++ b/src/components/card/CardSidebarTabComments.vue @@ -7,7 +7,11 @@
- +
    @@ -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: { @@ -101,6 +106,7 @@ export default { } }, async loadComments() { + this.$store.dispatch('setReplyTo', null) this.error = null this.isLoading = true try { @@ -130,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 5d38d35b9..11a450b0d 100644 --- a/src/components/card/CommentForm.vue +++ b/src/components/card/CommentForm.vue @@ -178,6 +178,7 @@ export default { .comment-form__contenteditable { word-break: break-word; + border-radius: var(--border-radius-large) } .atwho-wrap { 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 @@