Skip to content

Commit

Permalink
fix: fix flashing on pollInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanKnott committed Dec 24, 2020
1 parent 9f27bd1 commit 8d3b0bd
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 51 deletions.
5 changes: 1 addition & 4 deletions frontend/src/Admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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="/" />;
Expand Down Expand Up @@ -259,7 +256,7 @@ const AdminRoute = () => {
</>
);
}
return <span>error</span>;
return <GlobalTopNavbar projectID={null} onSaveProjectName={NOOP} name={null} />;
};

export default AdminRoute;
5 changes: 1 addition & 4 deletions frontend/src/App/TopNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -181,7 +178,7 @@ const ProjectFinder = () => {
</>
);
}
return <span>error</span>;
return <span>loading</span>;
};
type ProjectPopupProps = {
history: any;
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/Projects/Project/Board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -818,7 +815,7 @@ const ProjectBoard: React.FC<ProjectBoardProps> = ({ projectID, onCardLabelClick
);
}

return <span>Error</span>;
return <BoardLoading />;
};

export default ProjectBoard;
15 changes: 6 additions & 9 deletions frontend/src/Projects/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -637,7 +629,12 @@ const Project = () => {
</>
);
}
return <div>Error</div>;
return (
<>
<GlobalTopNavbar onSaveProjectName={NOOP} name="" projectID={null} />
<BoardLoading />
</>
);
};

export default Project;
5 changes: 1 addition & 4 deletions frontend/src/Projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ const Projects = () => {
);
},
});
if (loading) {
return <GlobalTopNavbar onSaveProjectName={NOOP} projectID={null} name={null} />;
}

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

export default Projects;
5 changes: 1 addition & 4 deletions frontend/src/Teams/Members/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@ const Members: React.FC<MembersProps> = ({ teamID }) => {
);
},
});
if (loading) {
return <span>loading</span>;
}

if (data && user) {
return (
Expand Down Expand Up @@ -562,7 +559,7 @@ const Members: React.FC<MembersProps> = ({ teamID }) => {
);
}

return <div>error</div>;
return <div>loading</div>;
};

export default Members;
5 changes: 1 addition & 4 deletions frontend/src/Teams/Projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -193,7 +190,7 @@ const TeamProjects: React.FC<TeamProjectsProps> = ({ teamID }) => {
</ProjectsContainer>
);
}
return <span>error</span>;
return <span>loading</span>;
};

export default TeamProjects;
33 changes: 15 additions & 18 deletions frontend/src/Teams/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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="/" />;
Expand Down Expand Up @@ -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;

0 comments on commit 8d3b0bd

Please sign in to comment.