perf(analytics): project minimal columns in GetStats/GetAnalyticsOverview #3
@@ -267,15 +267,27 @@ export default function ProfilePage() {
|
|||||||
const [currentPassword, setCurrentPassword] = useState("");
|
const [currentPassword, setCurrentPassword] = useState("");
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
|
|
||||||
|
// Keep a ref to the latest carousel so the unmount cleanup can revoke the
|
||||||
|
// outstanding preview object URLs without re-running on every change.
|
||||||
|
const pdfCarouselRef = useRef<PdfCarouselItem[]>([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
pdfCarouselRef.current = pdfCarousel;
|
||||||
|
}, [pdfCarousel]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Revoke any remaining preview object URLs only on unmount. Per-change
|
||||||
|
// revocation is already handled explicitly in savePdfToCarousel (replace) and
|
||||||
|
// resetPdfCarousel (clear); doing it here on every pdfCarousel change revoked
|
||||||
|
// URLs that were still referenced by other items in the deck, breaking their
|
||||||
|
// previews.
|
||||||
return () => {
|
return () => {
|
||||||
pdfCarousel.forEach((item) => {
|
pdfCarouselRef.current.forEach((item) => {
|
||||||
if (item.pdfUrl) {
|
if (item.pdfUrl) {
|
||||||
window.URL.revokeObjectURL(item.pdfUrl);
|
window.URL.revokeObjectURL(item.pdfUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}, [pdfCarousel]);
|
}, []);
|
||||||
|
|
||||||
const loadProfile = useCallback(async () => {
|
const loadProfile = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user