Fix memory leak in preview code (#2012)

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
This commit is contained in:
AustinMroz
2024-12-22 15:18:31 -06:00
committed by GitHub
parent 3767749398
commit cce5ade578
2 changed files with 22 additions and 0 deletions

View File

@@ -110,6 +110,9 @@ onMounted(() => {
})
onUnmounted(() => {
if (progressPreviewBlobUrl.value) {
URL.revokeObjectURL(progressPreviewBlobUrl.value)
}
api.removeEventListener('b_preview', onProgressPreviewReceived)
})
@@ -164,6 +167,9 @@ const formatTime = (time?: number) => {
const onProgressPreviewReceived = async ({ detail }: CustomEvent) => {
if (props.task.displayStatus === TaskItemDisplayStatus.Running) {
if (progressPreviewBlobUrl.value) {
URL.revokeObjectURL(progressPreviewBlobUrl.value)
}
progressPreviewBlobUrl.value = URL.createObjectURL(detail)
}
}