fix: fix flashing on pollInterval

This commit is contained in:
Jordan Knott 2020-12-23 20:02:38 -06:00
parent 9f27bd157f
commit 8d3b0bd510
8 changed files with 27 additions and 51 deletions

View File

@ -214,9 +214,6 @@ const AdminRoute = () => {
});
},
});
if (loading) {
return <GlobalTopNavbar projectID={null} onSaveProjectName={NOOP} name={null} />;
}
if (data && user) {
if (user.roles.org !== 'admin') {
return <Redirect to="/" />;
@ -259,7 +256,7 @@ const AdminRoute = () => {
</>
);
}
return <span>error</span>;
return <GlobalTopNavbar projectID={null} onSaveProjectName={NOOP} name={null} />;
};
export default AdminRoute;

View File

@ -129,9 +129,6 @@ const colors = [theme.colors.primary, theme.colors.secondary];
const ProjectFinder = () => {
const { loading, data } = useGetProjectsQuery({ fetchPolicy: 'cache-and-network' });
if (loading) {
return <span>loading</span>;
}
if (data) {
const { projects, teams } = data;
const personalProjects = data.projects.filter(p => p.team === null);
@ -181,7 +178,7 @@ const ProjectFinder = () => {
</>
);
}
return <span>error</span>;
return <span>loading</span>;
};
type ProjectPopupProps = {
history: any;

View File

@ -459,9 +459,6 @@ const ProjectBoard: React.FC<ProjectBoardProps> = ({ projectID, onCardLabelClick
}
};
if (loading) {
return <BoardLoading />;
}
const getTaskStatusFilterLabel = (filter: TaskStatusFilter) => {
if (filter.status === TaskStatus.COMPLETE) {
return 'Complete';
@ -818,7 +815,7 @@ const ProjectBoard: React.FC<ProjectBoardProps> = ({ projectID, onCardLabelClick
);
}
return <span>Error</span>;
return <BoardLoading />;
};
export default ProjectBoard;

View File

@ -517,14 +517,6 @@ const Project = () => {
document.title = `${data.findProject.name} | Taskcafé`;
}
}, [data]);
if (loading) {
return (
<>
<GlobalTopNavbar onSaveProjectName={NOOP} name="" projectID={null} />
<BoardLoading />
</>
);
}
if (error) {
history.push('/projects');
}
@ -637,7 +629,12 @@ const Project = () => {
</>
);
}
return <div>Error</div>;
return (
<>
<GlobalTopNavbar onSaveProjectName={NOOP} name="" projectID={null} />
<BoardLoading />
</>
);
};
export default Project;

View File

@ -231,9 +231,6 @@ const Projects = () => {
);
},
});
if (loading) {
return <GlobalTopNavbar onSaveProjectName={NOOP} projectID={null} name={null} />;
}
const colors = theme.colors.multiColors;
if (data && user) {
@ -395,7 +392,7 @@ const Projects = () => {
</>
);
}
return <div>Error!</div>;
return <GlobalTopNavbar onSaveProjectName={NOOP} projectID={null} name={null} />;
};
export default Projects;

View File

@ -472,9 +472,6 @@ const Members: React.FC<MembersProps> = ({ teamID }) => {
);
},
});
if (loading) {
return <span>loading</span>;
}
if (data && user) {
return (
@ -562,7 +559,7 @@ const Members: React.FC<MembersProps> = ({ teamID }) => {
);
}
return <div>error</div>;
return <div>loading</div>;
};
export default Members;

View File

@ -160,9 +160,6 @@ const TeamProjects: React.FC<TeamProjectsProps> = ({ teamID }) => {
fetchPolicy: 'cache-and-network',
pollInterval: 3000,
});
if (loading) {
return <span>loading</span>;
}
if (data) {
return (
<ProjectsContainer>
@ -193,7 +190,7 @@ const TeamProjects: React.FC<TeamProjectsProps> = ({ teamID }) => {
</ProjectsContainer>
);
}
return <span>error</span>;
return <span>loading</span>;
};
export default TeamProjects;

View File

@ -94,23 +94,6 @@ const Teams = () => {
const { user } = useCurrentUser();
const [currentTab, setCurrentTab] = useState(0);
const match = useRouteMatch();
if (loading) {
return (
<GlobalTopNavbar
menuType={[
{ name: 'Projects', link: `${match.url}` },
{ name: 'Members', link: `${match.url}/members` },
]}
currentTab={currentTab}
onSetTab={tab => {
setCurrentTab(tab);
}}
onSaveProjectName={NOOP}
projectID={null}
name={null}
/>
);
}
if (data && user) {
if (!user.isVisible(PermissionLevel.TEAM, PermissionObjectType.TEAM, teamID)) {
return <Redirect to="/" />;
@ -146,7 +129,21 @@ const Teams = () => {
</>
);
}
return <div>Error!</div>;
return (
<GlobalTopNavbar
menuType={[
{ name: 'Projects', link: `${match.url}` },
{ name: 'Members', link: `${match.url}/members` },
]}
currentTab={currentTab}
onSetTab={tab => {
setCurrentTab(tab);
}}
onSaveProjectName={NOOP}
projectID={null}
name={null}
/>
);
};
export default Teams;