Improve router/upload state coordination

This commit is contained in:
Sam Becker 2025-03-01 11:11:52 -06:00
parent 7fbe10e005
commit 237f977630
2 changed files with 11 additions and 7 deletions

View File

@ -56,17 +56,22 @@ export default function PhotoUploadWithStatus({
const shouldResetUploadStateAfterPending = useRef(false);
const [isPending, startTransition] = useTransition();
// Only reset upload state after route transition completes
useEffect(() => {
if (!isPending && shouldResetUploadStateAfterPending.current) {
resetUploadState?.();
shouldResetUploadStateAfterPending.current = false;
}
}, [isPending, resetUploadState]);
// Reset upload state when component unmounts
// when not reset during route transition
useEffect(() => {
return () => {
if (shouldResetUploadStateAfterPending.current) {
resetUploadState?.();
}
};
}, [isPending, resetUploadState]);
}, [resetUploadState]);
const isFinishing = isPending && shouldResetUploadStateAfterPending.current;
const uploadNumberText = `${fileUploadIndex + 1} of ${filesLength}`;
@ -147,14 +152,15 @@ export default function PhotoUploadWithStatus({
{isUploading
? isFinishing
? <>
Finishing
Finishing ...
</>
: <>
{!showButton &&
{!showButton && <>
<ResponsiveText shortText={uploadNumberText}>
Uploading {uploadNumberText}
</ResponsiveText>}
{': '}
</ResponsiveText>
{': '}
</>}
{fileUploadName}
</>
: !showButton && <>Initializing</>}

View File

@ -134,8 +134,6 @@ export default function AppStateProvider({
},
);
console.log('adminData', adminData);
useEffect(() => {
if (userEmail) {
storeAuthEmailCookie(userEmail);