From f7af3b407b03776b4baf822521e0cc0fba0b112a Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 19 Sep 2024 16:06:59 -0400 Subject: [PATCH] clear stage Signed-off-by: Dave Richer --- .../production-board-kanban.container.jsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/client/src/components/production-board-kanban/production-board-kanban.container.jsx b/client/src/components/production-board-kanban/production-board-kanban.container.jsx index a0b8cc984..d94cb4e42 100644 --- a/client/src/components/production-board-kanban/production-board-kanban.container.jsx +++ b/client/src/components/production-board-kanban/production-board-kanban.container.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo } from "react"; +import React, { useEffect, useMemo, useRef } from "react"; import { useQuery, useSubscription } from "@apollo/client"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -13,6 +13,8 @@ const mapStateToProps = createStructuredSelector({ }); function ProductionBoardKanbanContainer({ bodyshop, currentUser }) { + const fired = useRef(false); // useRef to keep track of whether the subscription fired + const combinedStatuses = useMemo( () => [ ...bodyshop.md_ro_statuses.production_statuses, @@ -40,10 +42,15 @@ function ProductionBoardKanbanContainer({ bodyshop, currentUser }) { // const currentReducerData = useSelector((state) => (state.trello.lanes ? state.trello : {})); useEffect(() => { - if (updatedJobs && data) { - refetch().catch((err) => console.error(`Error re-fetching jobs in production: ${err.message}`)); + if (!updatedJobs) { + return; } - }, [updatedJobs, data, refetch]); + if (!fired.current) { + fired.current = true; + return; + } + refetch().catch((err) => console.error(`Error re-fetching jobs in production: ${err.message}`)); + }, [updatedJobs, refetch]); const filteredAssociationSettings = useMemo(() => { return associationSettings?.associations[0] || null;