mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
fix: loading flashes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { Avatar, injectNotificationManager } from '@modrinth/ui'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||
import dayjs from 'dayjs'
|
||||
import { onUnmounted, ref } from 'vue'
|
||||
@@ -10,11 +11,16 @@ import { instance_listener } from '@/helpers/events.js'
|
||||
import { list } from '@/helpers/instance'
|
||||
|
||||
const { handleError } = injectNotificationManager()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const recentInstances = ref([])
|
||||
const getInstances = async () => {
|
||||
const instances = await list().catch(handleError)
|
||||
|
||||
for (const instance of instances) {
|
||||
queryClient.setQueryData(['instances', 'summary', instance.id], instance)
|
||||
}
|
||||
|
||||
recentInstances.value = instances
|
||||
.sort((a, b) => {
|
||||
const dateACreated = dayjs(a.created)
|
||||
|
||||
@@ -226,7 +226,10 @@ window.addEventListener('online', () => {
|
||||
offline.value = false
|
||||
})
|
||||
|
||||
const instance = ref<GameInstance>()
|
||||
const initialInstanceId = String(displayedInstanceRoute.value.params.id ?? '')
|
||||
const instance = ref<GameInstance | undefined>(
|
||||
queryClient.getQueryData<GameInstance>(['instances', 'summary', initialInstanceId]),
|
||||
)
|
||||
const instanceBreadcrumb = useRootBreadcrumb({
|
||||
slot: 'instance',
|
||||
id: () => `instance:${String(displayedInstanceRoute.value.params.id ?? '')}`,
|
||||
@@ -387,6 +390,9 @@ async function fetchInstance() {
|
||||
}
|
||||
|
||||
instance.value = nextInstance ?? undefined
|
||||
if (nextInstance) {
|
||||
queryClient.setQueryData(['instances', 'summary', nextInstance.id], nextInstance)
|
||||
}
|
||||
displayedInstanceRoute.value = nextRoute
|
||||
sharedInstanceState.reset()
|
||||
sharedInstanceState.refreshAvailability()
|
||||
|
||||
@@ -350,10 +350,8 @@ function getProjectBreadcrumbLabel(projectId) {
|
||||
return formatMessage(commonMessages.loadingLabel)
|
||||
}
|
||||
|
||||
return (
|
||||
queryClient.getQueryData(['projects', 'summary', identifier])?.name ??
|
||||
formatMessage(commonMessages.loadingLabel)
|
||||
)
|
||||
const summary = queryClient.getQueryData(['projects', 'summary', identifier])
|
||||
return summary?.name ?? summary?.title ?? formatMessage(commonMessages.loadingLabel)
|
||||
}
|
||||
|
||||
const projectBreadcrumbLabel = ref(getProjectBreadcrumbLabel(route.params.id))
|
||||
|
||||
Reference in New Issue
Block a user