From 2d8dbc70ad165f124f8a225e7bae3cc4f8bb6cbd 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/4] 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 2a307b92a7e46641304374b0cf5d815d353933a8 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/4] 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 69714b66b..a530900ef 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 2d5e29de5d5d3d58e5477fa2ec79e20982881822 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 3/4] 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 a530900ef..028f7ef02 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 @@