Skip to content

Commit b1438bd

Browse files
authored
fix: blocking await for jump back in (#4870)
* fix: loading state for jump back in * fix: lint
1 parent 267e0cb commit b1438bd

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

apps/app-frontend/src/components/ui/world/RecentWorldsList.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { LoaderCircleIcon } from '@modrinth/assets'
23
import type { GameVersion } from '@modrinth/ui'
34
import { GAME_MODES, HeadingLink, injectNotificationManager } from '@modrinth/ui'
45
import type { Dayjs } from 'dayjs'
@@ -39,6 +40,7 @@ const props = defineProps<{
3940
const theme = useTheming()
4041
4142
const jumpBackInItems = ref<JumpBackInItem[]>([])
43+
const loading = ref(true)
4244
const serverData = ref<Record<string, ServerData>>({})
4345
const protocolVersions = ref<Record<string, ProtocolVersion | null>>({})
4446
const gameVersions = ref<GameVersion[]>(await get_game_versions().catch(() => []))
@@ -71,9 +73,13 @@ watch([() => props.recentInstances, () => showWorlds.value], async () => {
7173
})
7274
})
7375
74-
await populateJumpBackIn().catch(() => {
75-
console.error('Failed to populate jump back in')
76-
})
76+
populateJumpBackIn()
77+
.catch(() => {
78+
console.error('Failed to populate jump back in')
79+
})
80+
.finally(() => {
81+
loading.value = false
82+
})
7783
7884
async function populateJumpBackIn() {
7985
console.info('Repopulating jump back in...')
@@ -233,7 +239,15 @@ onUnmounted(() => {
233239
</script>
234240

235241
<template>
236-
<div v-if="jumpBackInItems.length > 0" class="flex flex-col gap-2">
242+
<div v-if="loading" class="flex flex-col gap-2">
243+
<span class="flex mt-1 mb-3 leading-none items-center gap-1 text-primary text-lg font-bold">
244+
Jump back in
245+
</span>
246+
<div class="text-center py-4">
247+
<LoaderCircleIcon class="mx-auto size-8 animate-spin text-contrast" />
248+
</div>
249+
</div>
250+
<div v-else-if="jumpBackInItems.length > 0" class="flex flex-col gap-2">
237251
<HeadingLink v-if="theme.getFeatureFlag('worlds_tab')" to="/worlds" class="mt-1">
238252
Jump back in
239253
</HeadingLink>

0 commit comments

Comments
 (0)