From 0c9ab8abc2cb135ec51af1f2f97ef69f8b0aeb6e Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Wed, 23 Dec 2020 15:55:17 -0600 Subject: [PATCH] feat: add update polling to relevant views --- frontend/src/Admin/index.tsx | 2 +- frontend/src/App/TopNavbar.tsx | 2 +- frontend/src/Projects/Project/Details/index.tsx | 6 +++++- frontend/src/Projects/Project/index.tsx | 1 + frontend/src/Projects/index.tsx | 2 +- frontend/src/Teams/Members/index.tsx | 6 +++++- frontend/src/Teams/Projects/index.tsx | 6 +++++- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/src/Admin/index.tsx b/frontend/src/Admin/index.tsx index 018a717..5debe10 100644 --- a/frontend/src/Admin/index.tsx +++ b/frontend/src/Admin/index.tsx @@ -174,7 +174,7 @@ const AdminRoute = () => { useEffect(() => { document.title = 'Admin | Taskcafé'; }, []); - const { loading, data } = useUsersQuery(); + const { loading, data } = useUsersQuery({ fetchPolicy: 'cache-and-network' }); const { showPopup, hidePopup } = usePopup(); const { user } = useCurrentUser(); const [deleteInvitedUser] = useDeleteInvitedUserAccountMutation({ diff --git a/frontend/src/App/TopNavbar.tsx b/frontend/src/App/TopNavbar.tsx index 377eaed..7ba409a 100644 --- a/frontend/src/App/TopNavbar.tsx +++ b/frontend/src/App/TopNavbar.tsx @@ -128,7 +128,7 @@ const TeamProjectContainer = styled.div` const colors = [theme.colors.primary, theme.colors.secondary]; const ProjectFinder = () => { - const { loading, data } = useGetProjectsQuery(); + const { loading, data } = useGetProjectsQuery({ fetchPolicy: 'cache-and-network' }); if (loading) { return loading; } diff --git a/frontend/src/Projects/Project/Details/index.tsx b/frontend/src/Projects/Project/Details/index.tsx index c8edd9d..e6441e8 100644 --- a/frontend/src/Projects/Project/Details/index.tsx +++ b/frontend/src/Projects/Project/Details/index.tsx @@ -381,7 +381,11 @@ const Details: React.FC = ({ ); }, }); - const { loading, data, refetch } = useFindTaskQuery({ variables: { taskID }, fetchPolicy: 'cache-and-network' }); + const { loading, data, refetch } = useFindTaskQuery({ + variables: { taskID }, + pollInterval: 3000, + fetchPolicy: 'cache-and-network', + }); const [setTaskComplete] = useSetTaskCompleteMutation(); const [updateTaskDueDate] = useUpdateTaskDueDateMutation({ onCompleted: () => { diff --git a/frontend/src/Projects/Project/index.tsx b/frontend/src/Projects/Project/index.tsx index 59c63bb..b7ef371 100644 --- a/frontend/src/Projects/Project/index.tsx +++ b/frontend/src/Projects/Project/index.tsx @@ -436,6 +436,7 @@ const Project = () => { const { loading, data, error } = useFindProjectQuery({ variables: { projectID }, + pollInterval: 3000, }); const [updateProjectName] = useUpdateProjectNameMutation({ diff --git a/frontend/src/Projects/index.tsx b/frontend/src/Projects/index.tsx index b065f9b..159db44 100644 --- a/frontend/src/Projects/index.tsx +++ b/frontend/src/Projects/index.tsx @@ -202,7 +202,7 @@ type ShowNewProject = { const Projects = () => { const { showPopup, hidePopup } = usePopup(); - const { loading, data } = useGetProjectsQuery({ fetchPolicy: 'network-only' }); + const { loading, data } = useGetProjectsQuery({ pollInterval: 3000, fetchPolicy: 'cache-and-network' }); useEffect(() => { document.title = 'Taskcafé'; }, []); diff --git a/frontend/src/Teams/Members/index.tsx b/frontend/src/Teams/Members/index.tsx index a800350..f69abb0 100644 --- a/frontend/src/Teams/Members/index.tsx +++ b/frontend/src/Teams/Members/index.tsx @@ -419,7 +419,11 @@ type MembersProps = { const Members: React.FC = ({ teamID }) => { const { showPopup, hidePopup } = usePopup(); - const { loading, data } = useGetTeamQuery({ variables: { teamID } }); + const { loading, data } = useGetTeamQuery({ + variables: { teamID }, + fetchPolicy: 'cache-and-network', + pollInterval: 3000, + }); const { user, setUserRoles } = useCurrentUser(); const warning = 'You can’t leave because you are the only admin. To make another user an admin, click their avatar, select “Change permissions…”, and select “Admin”.'; diff --git a/frontend/src/Teams/Projects/index.tsx b/frontend/src/Teams/Projects/index.tsx index 66d831b..b2f9c77 100644 --- a/frontend/src/Teams/Projects/index.tsx +++ b/frontend/src/Teams/Projects/index.tsx @@ -155,7 +155,11 @@ type TeamProjectsProps = { }; const TeamProjects: React.FC = ({ teamID }) => { - const { loading, data } = useGetTeamQuery({ variables: { teamID } }); + const { loading, data } = useGetTeamQuery({ + variables: { teamID }, + fetchPolicy: 'cache-and-network', + pollInterval: 3000, + }); if (loading) { return loading; }