Browse Source

fix: better rare error handling

develop
Ezerous 4 years ago
parent
commit
e0f92a0765
  1. 2
      packages/concordia-app/src/views/Home/HomeTopicList/index.jsx
  2. 6
      packages/concordia-app/src/views/Profile/ProfilePostList/index.jsx
  3. 6
      packages/concordia-app/src/views/Profile/ProfileTopicList/index.jsx
  4. 6
      packages/concordia-app/src/views/Topic/TopicView/TopicPostList/index.jsx

2
packages/concordia-app/src/views/Home/HomeTopicList/index.jsx

@ -41,7 +41,7 @@ const HomeTopicList = () => {
useEffect(() => { useEffect(() => {
if (numTopicsResult) { if (numTopicsResult) {
setNumTopics(parseInt(numTopicsResult.value, 10)); setNumTopics(parseInt(numTopicsResult.value, 10) || 0);
} }
}, [numTopicsResult]); }, [numTopicsResult]);

6
packages/concordia-app/src/views/Profile/ProfilePostList/index.jsx

@ -51,13 +51,15 @@ const ProfilePostList = (props) => {
useEffect(() => { useEffect(() => {
if (getUserPostCountResult) { if (getUserPostCountResult) {
setUserPostCount(parseInt(getUserPostCountResult.value, 10)); setUserPostCount(parseInt(getUserPostCountResult.value, 10) || 0);
} }
}, [getUserPostCountResult, userPostCount]); }, [getUserPostCountResult, userPostCount]);
useEffect(() => { useEffect(() => {
if (getUserPostsResult) { if (getUserPostsResult) {
setPostIds(getUserPostsResult.value.slice().reverse().map(Number)); const { value } = getUserPostsResult;
const res = value || [];
setPostIds(res.slice().reverse().map(Number));
} }
}, [getUserPostsResult, userPostCount]); }, [getUserPostsResult, userPostCount]);

6
packages/concordia-app/src/views/Profile/ProfileTopicList/index.jsx

@ -51,13 +51,15 @@ const ProfileTopicList = (props) => {
useEffect(() => { useEffect(() => {
if (getUserTopicCountResult) { if (getUserTopicCountResult) {
setUserTopicCount(parseInt(getUserTopicCountResult.value, 10)); setUserTopicCount(parseInt(getUserTopicCountResult.value, 10) || 0);
} }
}, [getUserTopicCountResult, userTopicCount]); }, [getUserTopicCountResult, userTopicCount]);
useEffect(() => { useEffect(() => {
if (getUserTopicsResult) { if (getUserTopicsResult) {
setTopicIds(getUserTopicsResult.value.slice().reverse().map(Number)); const { value } = getUserTopicsResult;
const res = value || [];
setTopicIds(res.slice().reverse().map(Number));
} }
}, [getUserTopicsResult, userTopicCount]); }, [getUserTopicsResult, userTopicCount]);

6
packages/concordia-app/src/views/Topic/TopicView/TopicPostList/index.jsx

@ -49,13 +49,15 @@ const TopicPostList = (props) => {
useEffect(() => { useEffect(() => {
if (getTopicPostCountResult) { if (getTopicPostCountResult) {
setTopicPostCount(parseInt(getTopicPostCountResult.value, 10)); setTopicPostCount(parseInt(getTopicPostCountResult.value, 10) || 0);
} }
}, [getTopicPostCountResult, topicPostCount]); }, [getTopicPostCountResult, topicPostCount]);
useEffect(() => { useEffect(() => {
if (getTopicPostsResult) { if (getTopicPostsResult) {
setPostIds(getTopicPostsResult.value.slice().map(Number)); const { value } = getTopicPostsResult;
const res = value || [];
setPostIds(res.slice().map(Number));
} }
}, [getTopicPostsResult, topicPostCount]); }, [getTopicPostsResult, topicPostCount]);

Loading…
Cancel
Save