[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: lazy loading packages (#966)

Co-authored-by: Daniel Roe <daniel@roe.dev>

authored by

Florian Heuberger
Daniel Roe
and committed by
GitHub
37a14693 77f8f81e

+16 -9
+16 -9
app/pages/@[org].vue
··· 15 15 16 16 const { isConnected } = useConnector() 17 17 18 - // Fetch all packages in this org using the org packages API 19 - const { data: results, status, error } = await useOrgPackages(orgName) 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 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 - } 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 + showError({ 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 + ) 28 35 29 36 const packages = computed(() => results.value?.objects ?? []) 30 37 const packageCount = computed(() => packages.value.length)