From 02ccf2496413bd3bd6c0e4636f22b036a407d444 Mon Sep 17 00:00:00 2001 From: marcoelissa Date: Thu, 10 Nov 2022 03:06:03 +0700 Subject: [PATCH] fix infinite loop when no comment found --- src/components/@shared/Orbis/Comment/Posts.module.css | 5 +++++ src/components/@shared/Orbis/Comment/Posts.tsx | 6 +++++- src/components/@shared/Orbis/Comment/index.tsx | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/@shared/Orbis/Comment/Posts.module.css b/src/components/@shared/Orbis/Comment/Posts.module.css index 5eaaf21ed..b9d2499dc 100644 --- a/src/components/@shared/Orbis/Comment/Posts.module.css +++ b/src/components/@shared/Orbis/Comment/Posts.module.css @@ -16,3 +16,8 @@ padding: calc(var(--spacer) / 2) var(--spacer); border-top: 1px solid var(--border-color); } + +.noComment { + padding: calc(var(--spacer) / 2) var(--spacer); + text-align: center; +} diff --git a/src/components/@shared/Orbis/Comment/Posts.tsx b/src/components/@shared/Orbis/Comment/Posts.tsx index 77e8a715c..a5a9f7538 100644 --- a/src/components/@shared/Orbis/Comment/Posts.tsx +++ b/src/components/@shared/Orbis/Comment/Posts.tsx @@ -22,10 +22,14 @@ export default function Posts({ posts.map((post, index) => )} - {loading && ( + {loading ? (
+ ) : ( + !posts.length && ( +
No comment yet...
+ ) )} {!loading && hasMore && ( diff --git a/src/components/@shared/Orbis/Comment/index.tsx b/src/components/@shared/Orbis/Comment/index.tsx index c899e4315..e09e97aa0 100644 --- a/src/components/@shared/Orbis/Comment/index.tsx +++ b/src/components/@shared/Orbis/Comment/index.tsx @@ -22,7 +22,7 @@ export default function Comment({ asset }: { asset: AssetExtended }) { if (error) { console.log(error) } - if (data) { + if (data && data.length) { const newPosts = posts.concat(data) setPosts(newPosts)