Skip to content

Commit

Permalink
fix(dashboard): prevent reports updating non stop (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudambro authored and Arnaud AMBROSELLI committed Mar 24, 2022
1 parent 88cf166 commit 3899601
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dashboard/src/scenes/report/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ const ActionCompletedAt = ({ date, status, onUpdateResults = () => null }) => {

useEffect(() => {
onUpdateResults(data.length);
}, [data.length, onUpdateResults]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.length]);

if (!data) return <div />;

Expand Down Expand Up @@ -375,7 +376,8 @@ const ActionCreatedAt = ({ date, onUpdateResults = () => null }) => {

useEffect(() => {
onUpdateResults(data.length);
}, [data.length, onUpdateResults]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.length]);

if (!data) return <div />;
const moreThanOne = data.length > 1;
Expand Down Expand Up @@ -450,7 +452,9 @@ const CommentCreatedAt = ({ date, onUpdateResults = () => null }) => {

useEffect(() => {
onUpdateResults(data.length);
}, [data.length, onUpdateResults]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.length]);

if (!data) return <div />;

return (
Expand Down Expand Up @@ -555,7 +559,8 @@ const PassagesCreatedAt = ({ date, report, onUpdateResults = () => null }) => {

useEffect(() => {
onUpdateResults(passages.length);
}, [onUpdateResults, passages.length]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [passages.length]);

const numberOfAnonymousPassages = useMemo(() => passages.filter((p) => !p.person)?.length, [passages]);
const numberOfNonAnonymousPassages = useMemo(() => passages.filter((p) => !!p.person)?.length, [passages]);
Expand Down Expand Up @@ -658,7 +663,8 @@ const TerritoryObservationsCreatedAt = ({ date, onUpdateResults = () => null })

useEffect(() => {
onUpdateResults(data.length);
}, [data.length, date, onUpdateResults]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.length]);

if (!data) return <div />;
const moreThanOne = data.length > 1;
Expand Down

0 comments on commit 3899601

Please sign in to comment.