Adjust image fallback cache behavior
This commit is contained in:
parent
84ff9885cc
commit
1894d710ef
@ -32,15 +32,10 @@ export default function ImageWithFallback({
|
||||
const imgRef = useRef<HTMLImageElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(
|
||||
// Prevent blank flash by waiting for image to load
|
||||
() => setWasCached(
|
||||
Boolean(imgRef.current?.complete) &&
|
||||
(imgRef.current?.naturalWidth ?? 0) > 0,
|
||||
),
|
||||
50,
|
||||
setWasCached(
|
||||
Boolean(imgRef.current?.complete) &&
|
||||
(imgRef.current?.naturalWidth ?? 0) > 0,
|
||||
);
|
||||
return () => clearTimeout(timeout);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -108,4 +103,4 @@ export default function ImageWithFallback({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import { INITIAL_UPLOAD_STATE, UploadState } from '@/admin/upload';
|
||||
import { RecipeProps } from '@/recipe';
|
||||
import { getCountsForCategoriesCachedAction } from '@/category/actions';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { toastSuccess } from '@/toast';
|
||||
|
||||
export default function AppStateProvider({
|
||||
children,
|
||||
@ -169,7 +170,11 @@ export default function AppStateProvider({
|
||||
setUserEmail(undefined);
|
||||
setUserEmailEager(undefined);
|
||||
clearAuthEmailCookie();
|
||||
if (isPathProtected(pathname)) { router.push(PATH_ROOT); }
|
||||
if (isPathProtected(pathname)) {
|
||||
router.push(PATH_ROOT);
|
||||
} else {
|
||||
toastSuccess('Signed out');
|
||||
}
|
||||
}, [router, pathname]);
|
||||
|
||||
// Returns false when upload is cancelled
|
||||
|
||||
Loading…
Reference in New Issue
Block a user