aboutsummaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-07-05 14:27:40 +0300
committereug-vs <eug-vs@keemail.me>2020-07-05 14:27:40 +0300
commitc02ba097faa134266dc226be9bccc2070855e2b7 (patch)
treefdf7e9b933fc52f030d148e3a4d3c35202209d69 /src/pages
parent1a36aadf83ccbb5ff86f027cc9109bfa9dbe75bc (diff)
downloadwhich-ui-c02ba097faa134266dc226be9bccc2070855e2b7.tar.gz
fix: display loader correctly
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/ProfilePage/ProfilePage.tsx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx
index 3beeb00..34c9efa 100644
--- a/src/pages/ProfilePage/ProfilePage.tsx
+++ b/src/pages/ProfilePage/ProfilePage.tsx
@@ -16,16 +16,19 @@ const ProfilePage: React.FC = () => {
const { page, navigate } = useNavigate();
const { user } = useAuth();
const [isInfoLoading, setIsInfoLoading] = useState(false);
+ const [isPollsLoading, setIsPollsLoading] = useState(false);
useEffect(() => {
const id = page?.id || user?._id;
setIsInfoLoading(true);
+ setIsPollsLoading(true);
if (id) {
get(`/users/${id}`).then(response => {
setUserInfo(response.data);
setIsInfoLoading(false);
});
get(`/profiles/${id}`).then(response => {
+ setIsPollsLoading(false);
setPolls([]);
setPolls(response.data);
setTotalVotes(response.data.reduce(
@@ -47,7 +50,7 @@ const ProfilePage: React.FC = () => {
totalVotes={totalVotes}
isLoading={isInfoLoading}
/>
- <Feed polls={[...polls]} />
+ {isPollsLoading ? <Feed polls={[]} /> : (polls.length > 0 && <Feed polls={polls} />)}
</Container>
);
};