fix: workspace image flickering (#1247)

This commit is contained in:
Himself65
2023-03-01 21:25:16 -06:00
committed by GitHub
parent 1a72640a9b
commit e67411aea4

View File

@@ -22,9 +22,16 @@ export function useWorkspaceBlobImage(
const blobStorage = useWorkspaceBlob(blockSuiteWorkspace);
const [imageURL, setImageURL] = useState<string | null>(null);
useEffect(() => {
const controller = new AbortController();
blobStorage?.get(key).then(blob => {
if (controller.signal.aborted) {
return;
}
setImageURL(blob);
});
return () => {
controller.abort();
};
}, [blobStorage, key]);
return imageURL;
}