Skip to content

Commit 99be7a9

Browse files
authored
Merge pull request #124 from NeuroJSON/dev-fan
refactor: port autobidsify pipeline to TypeScript, mirror Python file structure
2 parents ecf15eb + edb2a8f commit 99be7a9

File tree

15 files changed

+5623
-2445
lines changed

15 files changed

+5623
-2445
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"devDependencies": {
6464
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
6565
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
66+
"@types/js-yaml": "^4.0.9",
6667
"@types/node": "^20.5.7",
6768
"@types/pako": "^2.0.3",
6869
"@typescript-eslint/eslint-plugin": "^5.31.0",

src/components/PreviewModal.tsx

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,14 @@ const PreviewModal: React.FC<{
2828
// fix end---------------------
2929

3030
useEffect(() => {
31-
if (!isOpen) return;
32-
//add spinner
33-
// if (!isOpen || isLoading) return;
34-
35-
// fix start-----------: Get the container element from the ref.
36-
// const container = canvasContainerRef.current;
37-
// if (!container) {
38-
// // This can happen briefly on the first render, so we just wait for the next render.
39-
// return;
40-
// }
41-
// // 3. Check for the required legacy functions on the window object.
42-
// if (
43-
// typeof window.previewdata !== "function" ||
44-
// typeof window.initcanvas_with_container !== "function"
45-
// ) {
46-
// console.error(
47-
// "❌ Legacy preview script functions are not available on the window object."
48-
// );
49-
// return;
50-
// }
51-
52-
// window.previewdata(dataKey, previewIndex, isInternal, false);
53-
// fix end---------------------------------
54-
// clear old canvas
31+
// if (!isOpen) return;
32+
if (!isOpen) {
33+
// Modal just closed — clean up Three.js immediately
34+
if (typeof window.destroyPreview === "function") {
35+
window.destroyPreview();
36+
}
37+
return;
38+
}
5539
const canvasDiv = document.getElementById("canvas");
5640
if (canvasDiv)
5741
while (canvasDiv.firstChild) canvasDiv.removeChild(canvasDiv.firstChild);
@@ -69,6 +53,10 @@ const PreviewModal: React.FC<{
6953

7054
return () => {
7155
clearInterval(interval);
56+
// Component unmounting — clean up Three.js
57+
if (typeof window.destroyPreview === "function") {
58+
window.destroyPreview();
59+
}
7260
};
7361
}, [isOpen, dataKey, previewIndex, isInternal]);
7462

0 commit comments

Comments
 (0)