From 8b29cebee83b92dd962aaafa913a0aa1486d9504 Mon Sep 17 00:00:00 2001 From: renatodellosso Date: Sun, 16 Feb 2025 22:45:42 -0500 Subject: [PATCH] Fix picklists overwriting before they load --- components/stats/Picklist.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/stats/Picklist.tsx b/components/stats/Picklist.tsx index 939a366f..d12d3b2e 100644 --- a/components/stats/Picklist.tsx +++ b/components/stats/Picklist.tsx @@ -20,6 +20,8 @@ import { const SHOW_PICKLISTS_ON_TEAM_CARDS = false; const SHOW_CARD_IDS = false; +const api = new ClientApi(); + function TeamCard(props: { entry: PicklistEntry; draggable: boolean; @@ -297,8 +299,6 @@ export function TeamList(props: { ); } -const api = new ClientApi(); - export default function PicklistScreen(props: { teams: number[]; reports: Report[]; @@ -321,10 +321,10 @@ export default function PicklistScreen(props: { const teams = props.teams.map((team) => ({ number: team })); // Save picklists - useEffect( - () => savePicklistGroup(props.picklist._id, picklists, strikethroughs, api), - [props.picklist._id, picklists, strikethroughs], - ); + useEffect(() => { + if (loadingPicklists !== LoadState.Loaded) return; + savePicklistGroup(props.picklist._id, picklists, strikethroughs, api); + }, [props.picklist._id, picklists, strikethroughs]); const updatePicklist = useCallback( (picklist: Picklist) => {