@@ -64,30 +64,31 @@ const allChanges = computed(() => {
6464 ].sort ((a , b ) => a .path .localeCompare (b .path ))
6565})
6666
67- // Sync selection with ?file= query for shareable links
68- watch (
69- [() => route .query .file , compare ],
70- ([filePath ]) => {
71- if (initializedFromQuery .value || ! filePath || ! compare .value ) return
72- const match = allChanges .value .find (f => f .path === filePath )
73- if (match ) {
74- selectedFile .value = match
75- initializedFromQuery .value = true
76- }
77- },
78- { immediate: true },
79- )
67+ const selectedFromQuery = computed (() => {
68+ const filePath = route .query .file
69+ if (! filePath || ! compare .value ) return null
70+ return allChanges .value .find (f => f .path === filePath ) ?? null
71+ })
8072
81- watch (
82- selectedFile ,
83- file => {
84- const query = { ... route .query }
85- if (file ?.path ) query .file = file .path
86- else delete query .file
87- router .replace ({ query })
88- },
89- { deep: false },
90- )
73+ // Sync selection with ?file= query for shareable links (SSR + client)
74+ watchEffect (() => {
75+ if (initializedFromQuery .value || ! selectedFromQuery .value ) return
76+ selectedFile .value = selectedFromQuery .value
77+ initializedFromQuery .value = true
78+ })
79+
80+ if (import .meta .client ) {
81+ watch (
82+ selectedFile ,
83+ file => {
84+ const query = { ... route .query }
85+ if (file ?.path ) query .file = file .path
86+ else delete query .file
87+ router .replace ({ query })
88+ },
89+ { deep: false },
90+ )
91+ }
9192
9293const groupedDeps = computed (() => {
9394 if (! compare .value ?.dependencyChanges ) return new Map ()
0 commit comments