Skip to content

Commit

Permalink
Load the notes from IndexedDB only once (#51)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tomasr8 authored Jul 18, 2024
1 parent d52219d commit d3d4e51
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/pages/participant/ParticipantPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(!!state?.fromScan && !!participant?.checkedIn);

useEffect(() => {
Expand Down Expand Up @@ -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 <NotFoundBanner text="Event not found" icon={<CalendarDaysIcon />} />;
} else if (!regform) {
Expand Down

0 comments on commit d3d4e51

Please sign in to comment.