mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
set tool search worker to null to remove references while unmounted
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { BAlert } from "bootstrap-vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, type ComputedRef, onMounted, type PropType, watch } from "vue";
|
||||
import { computed, type ComputedRef, onMounted, onUnmounted, type PropType, watch } from "vue";
|
||||
import { useRouter } from "vue-router/composables";
|
||||
|
||||
import { type Tool, type ToolSection, useToolStore } from "@/stores/toolStore";
|
||||
@@ -124,7 +124,7 @@ onMounted(() => {
|
||||
if (!searchWorker.value) {
|
||||
searchWorker.value = new Worker(new URL("components/Panels/toolSearch.worker.js", import.meta.url));
|
||||
}
|
||||
searchWorker.value!.onmessage = ({ data }) => {
|
||||
searchWorker.value.onmessage = ({ data }) => {
|
||||
const { type, payload, sectioned, query, closestTerm } = data;
|
||||
if (type === "searchToolsByKeysResult" && query === props.query) {
|
||||
emit("onResults", payload, sectioned, closestTerm);
|
||||
@@ -136,6 +136,13 @@ onMounted(() => {
|
||||
};
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
// The worker is not terminated but it will not be listening to messages
|
||||
if (searchWorker.value?.onmessage) {
|
||||
searchWorker.value.onmessage = null;
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => currentFavorites.value.tools,
|
||||
() => {
|
||||
|
||||
@@ -82,11 +82,6 @@ export const useToolStore = defineStore("toolStore", () => {
|
||||
const loading = ref(false);
|
||||
|
||||
const searchWorker = ref<Worker | undefined>(undefined);
|
||||
// TODO: Where do we terminate the worker?
|
||||
// onScopeDispose(() => {
|
||||
// searchWorker.value?.terminate();
|
||||
// searchWorker.value = undefined;
|
||||
// });
|
||||
|
||||
const getToolForId = computed(() => {
|
||||
return (toolId: string) => toolsById.value[toolId];
|
||||
|
||||
Reference in New Issue
Block a user