fix: Fix memory leaking in Artifacts (#22303)
This commit is contained in:
@@ -90,14 +90,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
artifactCode.subscribe((value) => {
|
const unsubscribeArtifactCode = artifactCode.subscribe((value) => {
|
||||||
if (contents) {
|
if (contents) {
|
||||||
const codeIdx = contents.findIndex((content) => content.content.includes(value));
|
const codeIdx = contents.findIndex((content) => content.content.includes(value));
|
||||||
selectedContentIdx = codeIdx !== -1 ? codeIdx : 0;
|
selectedContentIdx = codeIdx !== -1 ? codeIdx : 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
artifactContents.subscribe((value) => {
|
const unsubscribeArtifactContents = artifactContents.subscribe((value) => {
|
||||||
contents = value;
|
contents = value;
|
||||||
console.log('Artifact contents updated:', contents);
|
console.log('Artifact contents updated:', contents);
|
||||||
|
|
||||||
@@ -108,6 +108,11 @@
|
|||||||
|
|
||||||
selectedContentIdx = contents ? contents.length - 1 : 0;
|
selectedContentIdx = contents ? contents.length - 1 : 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribeArtifactCode();
|
||||||
|
unsubscribeArtifactContents();
|
||||||
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user