mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
fix: stop rendering if destroyed (#1748)
This commit is contained in:
@@ -58,6 +58,7 @@ export { NebulaApp };
|
|||||||
|
|
||||||
export default function boot({ app, context }) {
|
export default function boot({ app, context }) {
|
||||||
let resolveRender;
|
let resolveRender;
|
||||||
|
let destroyed = false;
|
||||||
const rendered = new Promise((resolve) => {
|
const rendered = new Promise((resolve) => {
|
||||||
resolveRender = resolve;
|
resolveRender = resolve;
|
||||||
});
|
});
|
||||||
@@ -105,7 +106,7 @@ export default function boot({ app, context }) {
|
|||||||
delete cells[id];
|
delete cells[id];
|
||||||
},
|
},
|
||||||
add(component, unmount) {
|
add(component, unmount) {
|
||||||
(async () => {
|
return (async () => {
|
||||||
await rendered;
|
await rendered;
|
||||||
components.push(component);
|
components.push(component);
|
||||||
componentsUnmount.push(unmount);
|
componentsUnmount.push(unmount);
|
||||||
@@ -113,16 +114,18 @@ export default function boot({ app, context }) {
|
|||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
remove(component) {
|
remove(component) {
|
||||||
(async () => {
|
if (!destroyed) {
|
||||||
await rendered;
|
(async () => {
|
||||||
const ix = components.indexOf(component);
|
await rendered;
|
||||||
if (ix !== -1) {
|
const ix = components.indexOf(component);
|
||||||
componentsUnmount[ix]?.();
|
if (ix !== -1) {
|
||||||
components.splice(ix, 1);
|
componentsUnmount[ix]?.();
|
||||||
componentsUnmount.splice(ix, 1);
|
components.splice(ix, 1);
|
||||||
}
|
componentsUnmount.splice(ix, 1);
|
||||||
appRef?.current?.setComps(components);
|
}
|
||||||
})();
|
appRef?.current?.setComps(components);
|
||||||
|
})();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setMuiThemeName(themeName) {
|
setMuiThemeName(themeName) {
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -141,6 +144,7 @@ export default function boot({ app, context }) {
|
|||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
destroy() {
|
destroy() {
|
||||||
|
destroyed = true;
|
||||||
componentsUnmount.forEach((c) => {
|
componentsUnmount.forEach((c) => {
|
||||||
c && c();
|
c && c();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,9 +42,18 @@ export default function glue({
|
|||||||
};
|
};
|
||||||
model.on('closed', unmount);
|
model.on('closed', unmount);
|
||||||
|
|
||||||
root.add(portal, unmount);
|
|
||||||
// Cannot use model.id as it is not unique in a given mashup
|
// Cannot use model.id as it is not unique in a given mashup
|
||||||
root.addCell(currentId, cellRef);
|
root.addCell(currentId, cellRef);
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
await root.add(portal, unmount);
|
||||||
|
} catch (e) {
|
||||||
|
unmount();
|
||||||
|
onMount();
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
return [unmount, cellRef];
|
return [unmount, cellRef];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user