From d3d4e51fcb6e526368999852a851c7cd672a1910 Mon Sep 17 00:00:00 2001 From: Tomas R Date: Thu, 18 Jul 2024 13:12:54 +0200 Subject: [PATCH] Load the notes from IndexedDB only once (#51) This fixes a rare confition when a user keeps typing while the IndexedDB is saving the previous text. When the text is saved, liveQuery triggers a rerender which deletes whatever the user typed after IndexedDB started saving the notes. --- src/pages/participant/ParticipantPage.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pages/participant/ParticipantPage.tsx b/src/pages/participant/ParticipantPage.tsx index 62ec252..7db3715 100644 --- a/src/pages/participant/ParticipantPage.tsx +++ b/src/pages/participant/ParticipantPage.tsx @@ -104,7 +104,7 @@ function ParticipantPageContent({ const {soundEffect} = useSettings(); const offline = useIsOffline(); const errorModal = useErrorModal(); - const [notes, setNotes] = useState(''); + const [notes, setNotes] = useState(participant?.notes || ''); const showCheckedInWarning = useRef(!!state?.fromScan && !!participant?.checkedIn); useEffect(() => { @@ -180,12 +180,6 @@ function ParticipantPageContent({ return () => controller.abort(); }, [eventId, regformId, participantId, errorModal, autoCheckin, offline, performCheckin]); - useEffect(() => { - if (participant) { - setNotes(participant.notes); - } - }, [participant]); - if (!event) { return } />; } else if (!regform) {