diff --git a/src/components/Location.vue b/src/components/Location.vue index 8b60fe65..57a92eb5 100644 --- a/src/components/Location.vue +++ b/src/components/Location.vue @@ -25,7 +25,6 @@ import { ref, watchEffect } from 'vue'; import { getGroupName, getWorldName, parseLocation } from '../shared/utils'; import { useGroupStore, useInstanceStore, useSearchStore, useWorldStore } from '../stores'; - import { instanceRequest } from '../api'; import { useI18n } from 'vue-i18n'; const { t } = useI18n(); @@ -33,6 +32,7 @@ const { showGroupDialog } = useGroupStore(); const { showPreviousInstancesInfoDialog } = useInstanceStore(); const { verifyShortName } = useSearchStore(); + const { cachedInstances } = useInstanceStore(); const props = defineProps({ location: String, @@ -89,21 +89,15 @@ return; } - instanceRequest - .getCachedInstance({ worldId: L.worldId, instanceId: L.instanceId }) - .then((args) => { - if (currentInstanceId() === L.tag) { - if (args.json.displayName) { - setText(L, args.json.displayName); - } - if (args.json.closedAt) { - isClosed.value = true; - } - } - }) - .catch((e) => { - console.error(e); - }); + const instanceRef = cachedInstances.get(L.tag); + if (typeof instanceRef !== 'undefined') { + if (instanceRef.displayName) { + setText(L, instanceRef.displayName); + } + if (instanceRef.closedAt) { + isClosed.value = true; + } + } if (props.grouphint) { groupName.value = props.grouphint; diff --git a/src/components/LocationWorld.vue b/src/components/LocationWorld.vue index 8a1e0509..dd456ca4 100644 --- a/src/components/LocationWorld.vue +++ b/src/components/LocationWorld.vue @@ -17,10 +17,10 @@ import { Lock, Unlock, WarnTriangleFilled } from '@element-plus/icons-vue'; import { ref, watch } from 'vue'; import { getGroupName, parseLocation } from '../shared/utils'; - import { useGroupStore, useLaunchStore } from '../stores'; - import { instanceRequest } from '../api'; + import { useGroupStore, useLaunchStore, useInstanceStore } from '../stores'; import { useI18n } from 'vue-i18n'; const { t } = useI18n(); + const { cachedInstances } = useInstanceStore(); const launchStore = useLaunchStore(); const groupStore = useGroupStore(); @@ -65,21 +65,15 @@ return; } - instanceRequest - .getCachedInstance({ worldId: L.worldId, instanceId: L.instanceId }) - .then((args) => { - if (locObj.tag === L.tag) { - if (args.json.displayName) { - instanceName.value = args.json.displayName; - } - if (args.json.closedAt) { - isClosed.value = true; - } - } - }) - .catch((e) => { - console.error(e); - }); + const instanceRef = cachedInstances.get(L.tag); + if (typeof instanceRef !== 'undefined') { + if (instanceRef.displayName) { + instanceName.value = instanceRef.displayName; + } + if (instanceRef.closedAt) { + isClosed.value = true; + } + } if (props.grouphint) { groupName.value = props.grouphint; diff --git a/src/stores/user.js b/src/stores/user.js index 6077ac61..60372d65 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -646,6 +646,15 @@ export const useUserStore = defineStore('User', () => { sharedFeedStore.updateSharedFeed(false); } } + if ( + !instanceStore.cachedInstances.has(ref.$location.tag) && + isRealInstance(ref.location) + ) { + instanceRequest.getInstance({ + worldId: ref.$location.worldId, + instanceId: ref.$location.instanceId + }); + } if ( ref.$isVRCPlus && ref.badges &&