Skip to content

Commit 200d861

Browse files
committed
adding flush post, this should hopefully make the auto scrolling more reliable
1 parent ef51c3d commit 200d861

File tree

2 files changed

+51
-45
lines changed

2 files changed

+51
-45
lines changed

app/components/Changelog/Markdown.vue

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@ if (import.meta.client) {
1515
const { settings } = useSettings()
1616
1717
// doing this server side can make it that we go to the homepage
18-
const stopWatching = watchEffect(() => {
19-
const toc = data.value?.toc
18+
const stopWatching = watchEffect(
19+
() => {
20+
const toc = data.value?.toc
2021
21-
if (toc && route.hash) {
22-
// scroll if there is a hash in the url
23-
return navigateTo(route.hash)
24-
}
22+
if (toc && route.hash) {
23+
// scroll if there is a hash in the url
24+
return navigateTo(route.hash)
25+
}
2526
26-
// don't allow auto scrolling when disabled and there was no hash before
27-
if (!settings.value.changelogAutoScroll || !toc || !goToVersion || route.hash) {
28-
return
29-
}
30-
// lc = lower case
31-
const lcRequestedVersion = goToVersion.toLowerCase()
32-
for (const item of toc) {
33-
if (item.text.toLowerCase().includes(lcRequestedVersion)) {
34-
navigateTo(`#${item.id}`)
27+
// don't allow auto scrolling when disabled and there was no hash before
28+
if (!settings.value.changelogAutoScroll || !toc || !goToVersion || route.hash) {
3529
return
3630
}
37-
}
38-
})
31+
// lc = lower case
32+
const lcRequestedVersion = goToVersion.toLowerCase()
33+
for (const item of toc) {
34+
if (item.text.toLowerCase().includes(lcRequestedVersion)) {
35+
navigateTo(`#${item.id}`)
36+
return
37+
}
38+
}
39+
},
40+
{ flush: 'post' },
41+
)
3942
4043
// stops watchEffect from trigger just before navigating
4144
onBeforeRouteLeave(stopWatching)

app/components/Changelog/Releases.vue

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,40 @@ if (import.meta.client) {
3030
const { settings } = useSettings()
3131
3232
// doing this server side can make it that we go to the homepage
33-
const stopWatching = watchEffect(() => {
34-
const uReleases = releases.value
35-
if (route.hash && uReleases) {
36-
// scroll if there is a hash in the url
37-
navigateTo(route.hash, { replace: true })
38-
return
39-
}
40-
// don't allow auto scrolling when disabled and there was no hash before
41-
if (!settings.value.changelogAutoScroll) {
42-
return
43-
}
44-
const date = requestedDate?.toLowerCase()
45-
if (route.hash || !date || !uReleases || !goToVersion) {
46-
return
47-
}
48-
const uMatchingDateReleases = matchingDateReleases.value
49-
if (uMatchingDateReleases?.length < 1) {
50-
// if no releases have matched the requested version publish date then most likely no release note has been made
51-
return
52-
}
33+
const stopWatching = watchEffect(
34+
() => {
35+
const uReleases = releases.value
36+
if (route.hash && uReleases) {
37+
// scroll if there is a hash in the url
38+
navigateTo(route.hash, { replace: true })
39+
return
40+
}
41+
// don't allow auto scrolling when disabled and there was no hash before
42+
if (!settings.value.changelogAutoScroll) {
43+
return
44+
}
45+
const date = requestedDate?.toLowerCase()
46+
if (route.hash || !date || !uReleases || !goToVersion) {
47+
return
48+
}
49+
const uMatchingDateReleases = matchingDateReleases.value
50+
if (uMatchingDateReleases?.length < 1) {
51+
// if no releases have matched the requested version publish date then most likely no release note has been made
52+
return
53+
}
5354
54-
if (goToVersion) {
55-
for (const match of uMatchingDateReleases) {
56-
if (match.title.toLowerCase().includes(goToVersion)) {
57-
navigateTo(`#release-${slugify(match.title)}`, { replace: true })
58-
return
55+
if (goToVersion) {
56+
for (const match of uMatchingDateReleases) {
57+
if (match.title.toLowerCase().includes(goToVersion)) {
58+
navigateTo(`#release-${slugify(match.title)}`, { replace: true })
59+
return
60+
}
5961
}
6062
}
61-
}
62-
navigateTo(`#date-${date}`, { replace: true })
63-
})
63+
navigateTo(`#date-${date}`, { replace: true })
64+
},
65+
{ flush: 'post' },
66+
)
6467
// stops watchEffect from trigger just before navigating
6568
onBeforeRouteLeave(stopWatching)
6669
}

0 commit comments

Comments
 (0)