refactor: polling is now turned off in development mode
This commit is contained in:
parent
e2634dc490
commit
167d285d02
1
frontend/.env
Normal file
1
frontend/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
REACT_APP_ENABLE_POLLING=true
|
1
frontend/.env.development
Normal file
1
frontend/.env.development
Normal file
@ -0,0 +1 @@
|
|||||||
|
REACT_APP_ENABLE_POLLING=false
|
@ -36,6 +36,7 @@ import Input from 'shared/components/Input';
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import updateApolloCache from 'shared/utils/cache';
|
import updateApolloCache from 'shared/utils/cache';
|
||||||
import NOOP from 'shared/utils/noop';
|
import NOOP from 'shared/utils/noop';
|
||||||
|
import polling from 'shared/utils/polling';
|
||||||
|
|
||||||
export const ActionsList = styled.ul`
|
export const ActionsList = styled.ul`
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -384,7 +385,7 @@ const Details: React.FC<DetailsProps> = ({
|
|||||||
});
|
});
|
||||||
const { loading, data, refetch } = useFindTaskQuery({
|
const { loading, data, refetch } = useFindTaskQuery({
|
||||||
variables: { taskID },
|
variables: { taskID },
|
||||||
pollInterval: 3000,
|
pollInterval: polling.TASK_DETAILS,
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
});
|
});
|
||||||
const [setTaskComplete] = useSetTaskCompleteMutation();
|
const [setTaskComplete] = useSetTaskCompleteMutation();
|
||||||
|
@ -35,6 +35,7 @@ import Board, { BoardLoading } from './Board';
|
|||||||
import Details from './Details';
|
import Details from './Details';
|
||||||
import LabelManagerEditor from './LabelManagerEditor';
|
import LabelManagerEditor from './LabelManagerEditor';
|
||||||
import UserManagementPopup from './UserManagementPopup';
|
import UserManagementPopup from './UserManagementPopup';
|
||||||
|
import polling from 'shared/utils/polling';
|
||||||
|
|
||||||
type TaskRouteProps = {
|
type TaskRouteProps = {
|
||||||
taskID: string;
|
taskID: string;
|
||||||
@ -60,7 +61,7 @@ const Project = () => {
|
|||||||
const [updateTaskName] = useUpdateTaskNameMutation();
|
const [updateTaskName] = useUpdateTaskNameMutation();
|
||||||
const { data, error } = useFindProjectQuery({
|
const { data, error } = useFindProjectQuery({
|
||||||
variables: { projectID },
|
variables: { projectID },
|
||||||
pollInterval: 3000,
|
pollInterval: polling.PROJECT,
|
||||||
});
|
});
|
||||||
const [toggleTaskLabel] = useToggleTaskLabelMutation({
|
const [toggleTaskLabel] = useToggleTaskLabelMutation({
|
||||||
onCompleted: newTaskLabel => {
|
onCompleted: newTaskLabel => {
|
||||||
|
@ -22,6 +22,7 @@ import produce from 'immer';
|
|||||||
import NOOP from 'shared/utils/noop';
|
import NOOP from 'shared/utils/noop';
|
||||||
import theme from 'App/ThemeStyles';
|
import theme from 'App/ThemeStyles';
|
||||||
import { mixin } from '../shared/utils/styles';
|
import { mixin } from '../shared/utils/styles';
|
||||||
|
import polling from 'shared/utils/polling';
|
||||||
|
|
||||||
type CreateTeamData = { teamName: string };
|
type CreateTeamData = { teamName: string };
|
||||||
|
|
||||||
@ -203,7 +204,7 @@ type ShowNewProject = {
|
|||||||
|
|
||||||
const Projects = () => {
|
const Projects = () => {
|
||||||
const { showPopup, hidePopup } = usePopup();
|
const { showPopup, hidePopup } = usePopup();
|
||||||
const { loading, data } = useGetProjectsQuery({ pollInterval: 3000, fetchPolicy: 'cache-and-network' });
|
const { loading, data } = useGetProjectsQuery({ pollInterval: polling.PROJECTS, fetchPolicy: 'cache-and-network' });
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = 'Taskcafé';
|
document.title = 'Taskcafé';
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -2,6 +2,7 @@ import React, { useState } from 'react';
|
|||||||
import Input from 'shared/components/Input';
|
import Input from 'shared/components/Input';
|
||||||
import updateApolloCache from 'shared/utils/cache';
|
import updateApolloCache from 'shared/utils/cache';
|
||||||
import produce from 'immer';
|
import produce from 'immer';
|
||||||
|
import polling from 'shared/utils/polling';
|
||||||
import Button from 'shared/components/Button';
|
import Button from 'shared/components/Button';
|
||||||
import { useCurrentUser } from 'App/context';
|
import { useCurrentUser } from 'App/context';
|
||||||
import Select from 'shared/components/Select';
|
import Select from 'shared/components/Select';
|
||||||
@ -422,7 +423,7 @@ const Members: React.FC<MembersProps> = ({ teamID }) => {
|
|||||||
const { loading, data } = useGetTeamQuery({
|
const { loading, data } = useGetTeamQuery({
|
||||||
variables: { teamID },
|
variables: { teamID },
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
pollInterval: 3000,
|
pollInterval: polling.MEMBERS,
|
||||||
});
|
});
|
||||||
const { user } = useCurrentUser();
|
const { user } = useCurrentUser();
|
||||||
const warning =
|
const warning =
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Input from 'shared/components/Input';
|
import Input from 'shared/components/Input';
|
||||||
import theme from 'App/ThemeStyles';
|
import theme from 'App/ThemeStyles';
|
||||||
|
import polling from 'shared/utils/polling';
|
||||||
|
|
||||||
const FilterSearch = styled(Input)`
|
const FilterSearch = styled(Input)`
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -158,7 +159,7 @@ const TeamProjects: React.FC<TeamProjectsProps> = ({ teamID }) => {
|
|||||||
const { loading, data } = useGetTeamQuery({
|
const { loading, data } = useGetTeamQuery({
|
||||||
variables: { teamID },
|
variables: { teamID },
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
pollInterval: 3000,
|
pollInterval: polling.TEAM_PROJECTS,
|
||||||
});
|
});
|
||||||
if (data) {
|
if (data) {
|
||||||
return (
|
return (
|
||||||
|
13
frontend/src/shared/utils/polling.ts
Normal file
13
frontend/src/shared/utils/polling.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
function resolve(interval: number) {
|
||||||
|
if (process.env.REACT_APP_ENABLE_POLLING === 'true') return interval;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const polling = {
|
||||||
|
PROJECTS: resolve(3000),
|
||||||
|
PROJECT: resolve(3000),
|
||||||
|
MEMBERS: resolve(3000),
|
||||||
|
TEAM_PROJECTS: resolve(3000),
|
||||||
|
TASK_DETAILS: resolve(3000),
|
||||||
|
};
|
||||||
|
|
||||||
|
export default polling;
|
Loading…
Reference in New Issue
Block a user