Skip to content

Commit 9cf95ac

Browse files
committed
fix: skills SSR + code viewer race condition
1 parent 92153ac commit 9cf95ac

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

app/pages/[...package].vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ const {
7171
)
7272
onMounted(() => fetchInstallSize())
7373
74-
// Fetch skills data (lazy, client-side)
74+
// Fetch skills data
7575
const { data: skillsData } = useLazyFetch<SkillsListResponse>(
7676
() => {
7777
const base = `/skills/${packageName.value}`
7878
const version = requestedVersion.value
7979
return version ? `${base}/v/${version}` : base
8080
},
81-
{ server: false, default: () => ({ package: '', version: '', skills: [] }) },
81+
{ default: () => ({ package: '', version: '', skills: [] }) },
8282
)
8383
8484
const { data: packageAnalysis } = usePackageAnalysis(packageName, requestedVersion)

app/pages/code/[...path].vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,18 @@ const fileContentUrl = computed(() => {
9999
return `/api/registry/file/${packageName.value}/v/${version.value}/${filePath.value}`
100100
})
101101
102-
const { data: fileContent, status: fileStatus } = useFetch<PackageFileContentResponse>(
103-
() => fileContentUrl.value!,
104-
{ immediate: !!fileContentUrl.value },
102+
const {
103+
data: fileContent,
104+
status: fileStatus,
105+
execute: fetchFileContent,
106+
} = useFetch<PackageFileContentResponse>(() => fileContentUrl.value!, { immediate: false })
107+
108+
watch(
109+
fileContentUrl,
110+
url => {
111+
if (url) fetchFileContent()
112+
},
113+
{ immediate: true },
105114
)
106115
107116
// Track hash manually since we update it via history API to avoid scroll

0 commit comments

Comments
 (0)