From bc4142e5501b451c487a9038ff0649280209ca05 Mon Sep 17 00:00:00 2001 From: saltrafael Date: Thu, 15 Jul 2021 10:25:48 -0300 Subject: [PATCH] Mobile view: Make comments expandable --- ui/component/commentsList/view.jsx | 42 +++++++++++++++++++++++++++--- ui/scss/component/_card.scss | 5 ++++ ui/scss/component/_comments.scss | 8 ++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/ui/component/commentsList/view.jsx b/ui/component/commentsList/view.jsx index 433103792..5ce7f5f8c 100644 --- a/ui/component/commentsList/view.jsx +++ b/ui/component/commentsList/view.jsx @@ -13,6 +13,7 @@ import usePersistedState from 'effects/use-persisted-state'; import { ENABLE_COMMENT_REACTIONS } from 'config'; import Empty from 'component/common/empty'; import debounce from 'util/debounce'; +import { useIsMobile } from 'effects/use-screensize'; const DEBOUNCE_SCROLL_HANDLER_MS = 200; @@ -74,6 +75,8 @@ function CommentList(props: Props) { const DEFAULT_SORT = ENABLE_COMMENT_REACTIONS ? SORT_BY.POPULARITY : SORT_BY.NEWEST; const [sort, setSort] = usePersistedState('comment-sort-by', DEFAULT_SORT); const [page, setPage] = React.useState(0); + const isMobile = useIsMobile(); + const [expandedComments, setExpandedComments] = React.useState(!isMobile); const totalFetchedComments = allCommentIds ? allCommentIds.length : 0; // Display comments immediately if not fetching reactions @@ -191,7 +194,7 @@ function CommentList(props: Props) { } const handleCommentScroll = debounce(() => { - if (shouldFetchNextPage(page, topLevelTotalPages, window, document)) { + if (!isMobile && shouldFetchNextPage(page, topLevelTotalPages, window, document)) { setPage(page + 1); } }, DEBOUNCE_SCROLL_HANDLER_MS); @@ -205,6 +208,7 @@ function CommentList(props: Props) { } } }, [ + isMobile, page, moreBelow, spinnerRef, @@ -279,7 +283,10 @@ function CommentList(props: Props) { )} -