Skip to content

Commit ac93b16

Browse files
committed
fix: lazy loading packages
1 parent 146c677 commit ac93b16

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

app/pages/@[org].vue

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@ const orgName = computed(() => route.params.org)
1515
1616
const { isConnected } = useConnector()
1717
18-
// Fetch all packages in this org using the org packages API
19-
const { data: results, status, error } = await useOrgPackages(orgName)
20-
21-
if (status.value === 'error' && error.value?.statusCode === 404) {
22-
throw createError({
23-
statusCode: 404,
24-
statusMessage: $t('org.page.not_found'),
25-
message: $t('org.page.not_found_message', { name: orgName.value }),
26-
})
27-
}
18+
// Fetch all packages in this org using the org packages API (lazy to not block navigation)
19+
const { data: results, status, error } = useOrgPackages(orgName)
20+
21+
// Handle 404 errors reactively (since we're not awaiting)
22+
watch(
23+
[status, error],
24+
([newStatus, newError]) => {
25+
if (newStatus === 'error' && newError?.statusCode === 404) {
26+
throw createError({
27+
statusCode: 404,
28+
statusMessage: $t('org.page.not_found'),
29+
message: $t('org.page.not_found_message', { name: orgName.value }),
30+
})
31+
}
32+
},
33+
{ immediate: true },
34+
)
2835
2936
const packages = computed(() => results.value?.objects ?? [])
3037
const packageCount = computed(() => packages.value.length)

0 commit comments

Comments
 (0)