From e0f92a0765104014bba7cb56cb655f35d20e3ef9 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 1 Mar 2021 13:58:08 +0200 Subject: [PATCH] fix: better rare error handling --- .../concordia-app/src/views/Home/HomeTopicList/index.jsx | 2 +- .../src/views/Profile/ProfilePostList/index.jsx | 6 ++++-- .../src/views/Profile/ProfileTopicList/index.jsx | 6 ++++-- .../src/views/Topic/TopicView/TopicPostList/index.jsx | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/concordia-app/src/views/Home/HomeTopicList/index.jsx b/packages/concordia-app/src/views/Home/HomeTopicList/index.jsx index f41bb2f..e70c759 100644 --- a/packages/concordia-app/src/views/Home/HomeTopicList/index.jsx +++ b/packages/concordia-app/src/views/Home/HomeTopicList/index.jsx @@ -41,7 +41,7 @@ const HomeTopicList = () => { useEffect(() => { if (numTopicsResult) { - setNumTopics(parseInt(numTopicsResult.value, 10)); + setNumTopics(parseInt(numTopicsResult.value, 10) || 0); } }, [numTopicsResult]); diff --git a/packages/concordia-app/src/views/Profile/ProfilePostList/index.jsx b/packages/concordia-app/src/views/Profile/ProfilePostList/index.jsx index 51dbf37..3436aea 100644 --- a/packages/concordia-app/src/views/Profile/ProfilePostList/index.jsx +++ b/packages/concordia-app/src/views/Profile/ProfilePostList/index.jsx @@ -51,13 +51,15 @@ const ProfilePostList = (props) => { useEffect(() => { if (getUserPostCountResult) { - setUserPostCount(parseInt(getUserPostCountResult.value, 10)); + setUserPostCount(parseInt(getUserPostCountResult.value, 10) || 0); } }, [getUserPostCountResult, userPostCount]); useEffect(() => { if (getUserPostsResult) { - setPostIds(getUserPostsResult.value.slice().reverse().map(Number)); + const { value } = getUserPostsResult; + const res = value || []; + setPostIds(res.slice().reverse().map(Number)); } }, [getUserPostsResult, userPostCount]); diff --git a/packages/concordia-app/src/views/Profile/ProfileTopicList/index.jsx b/packages/concordia-app/src/views/Profile/ProfileTopicList/index.jsx index 0450cc5..c51aa51 100644 --- a/packages/concordia-app/src/views/Profile/ProfileTopicList/index.jsx +++ b/packages/concordia-app/src/views/Profile/ProfileTopicList/index.jsx @@ -51,13 +51,15 @@ const ProfileTopicList = (props) => { useEffect(() => { if (getUserTopicCountResult) { - setUserTopicCount(parseInt(getUserTopicCountResult.value, 10)); + setUserTopicCount(parseInt(getUserTopicCountResult.value, 10) || 0); } }, [getUserTopicCountResult, userTopicCount]); useEffect(() => { if (getUserTopicsResult) { - setTopicIds(getUserTopicsResult.value.slice().reverse().map(Number)); + const { value } = getUserTopicsResult; + const res = value || []; + setTopicIds(res.slice().reverse().map(Number)); } }, [getUserTopicsResult, userTopicCount]); diff --git a/packages/concordia-app/src/views/Topic/TopicView/TopicPostList/index.jsx b/packages/concordia-app/src/views/Topic/TopicView/TopicPostList/index.jsx index 7d26870..c83e3c4 100644 --- a/packages/concordia-app/src/views/Topic/TopicView/TopicPostList/index.jsx +++ b/packages/concordia-app/src/views/Topic/TopicView/TopicPostList/index.jsx @@ -49,13 +49,15 @@ const TopicPostList = (props) => { useEffect(() => { if (getTopicPostCountResult) { - setTopicPostCount(parseInt(getTopicPostCountResult.value, 10)); + setTopicPostCount(parseInt(getTopicPostCountResult.value, 10) || 0); } }, [getTopicPostCountResult, topicPostCount]); useEffect(() => { if (getTopicPostsResult) { - setPostIds(getTopicPostsResult.value.slice().map(Number)); + const { value } = getTopicPostsResult; + const res = value || []; + setPostIds(res.slice().map(Number)); } }, [getTopicPostsResult, topicPostCount]);