mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
fix: prevent memory leaks by disposing watchers in Location component
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Loading, Lock, WarnTriangleFilled } from '@element-plus/icons-vue';
|
import { Loading, Lock, WarnTriangleFilled } from '@element-plus/icons-vue';
|
||||||
import { ref, watch, watchEffect } from 'vue';
|
import { onBeforeUnmount, ref, watch } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
@@ -66,18 +66,20 @@
|
|||||||
const groupName = ref('');
|
const groupName = ref('');
|
||||||
const isClosed = ref(false);
|
const isClosed = ref(false);
|
||||||
|
|
||||||
watchEffect(() => {
|
let isDisposed = false;
|
||||||
parse();
|
onBeforeUnmount(() => {
|
||||||
|
isDisposed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(() => [props.location, props.traveling, props.hint, props.grouphint], parse, { immediate: true });
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => lastInstanceApplied.value,
|
() => lastInstanceApplied.value,
|
||||||
(instanceId) => {
|
(instanceId) => {
|
||||||
if (instanceId === currentInstanceId()) {
|
if (instanceId === currentInstanceId()) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{ immediate: true }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function currentInstanceId() {
|
function currentInstanceId() {
|
||||||
@@ -88,6 +90,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parse() {
|
function parse() {
|
||||||
|
if (isDisposed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
text.value = '';
|
text.value = '';
|
||||||
region.value = '';
|
region.value = '';
|
||||||
strict.value = false;
|
strict.value = false;
|
||||||
@@ -122,7 +127,7 @@
|
|||||||
groupName.value = L.groupId;
|
groupName.value = L.groupId;
|
||||||
getGroupName(instanceId)
|
getGroupName(instanceId)
|
||||||
.then((name) => {
|
.then((name) => {
|
||||||
if (name && currentInstanceId() === L.tag) {
|
if (!isDisposed && name && currentInstanceId() === L.tag) {
|
||||||
groupName.value = name;
|
groupName.value = name;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -163,7 +168,7 @@
|
|||||||
if (typeof ref === 'undefined') {
|
if (typeof ref === 'undefined') {
|
||||||
getWorldName(L.worldId)
|
getWorldName(L.worldId)
|
||||||
.then((name) => {
|
.then((name) => {
|
||||||
if (name && currentInstanceId() === L.tag) {
|
if (!isDisposed && name && currentInstanceId() === L.tag) {
|
||||||
if (L.instanceId) {
|
if (L.instanceId) {
|
||||||
text.value = `${name} #${instanceName} ${L.accessTypeName}`;
|
text.value = `${name} #${instanceName} ${L.accessTypeName}`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user