From e5e13d7b3b985fffc220a0808faf3a69eaaa3d72 Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Wed, 17 Jul 2024 15:11:30 +0200 Subject: [PATCH] Load the notes from IndexedDB only once 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) {