Skip to content

Commit 5d34b0e

Browse files
committed
chore: apply coderabbitai suggestion for timers cleanup
1 parent 138b1c3 commit 5d34b0e

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

app/pages/about.vue

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ import type { Role, GitHubContributor } from '#server/api/contributors.get'
44
const router = useRouter()
55
const canGoBack = useCanGoBack()
66
7-
// SSR & Validation Fix
8-
const isMounted = shallowRef(false)
9-
const activeContributor = shallowRef<GitHubContributor | null>(null)
10-
const openTimer = shallowRef<any>(null)
11-
const closeTimer = shallowRef<any>(null)
12-
const isFlipped = shallowRef(false)
13-
14-
onMounted(() => {
15-
isMounted.value = true
16-
})
17-
187
useSeoMeta({
198
title: () => `${$t('about.title')} - npmx`,
209
ogTitle: () => `${$t('about.title')} - npmx`,
@@ -30,6 +19,21 @@ defineOgImageComponent('Default', {
3019
description: 'a fast, modern browser for the **npm registry**',
3120
})
3221
22+
const isMounted = shallowRef(false)
23+
const activeContributor = shallowRef<GitHubContributor | null>(null)
24+
const openTimer = shallowRef<ReturnType<typeof setTimeout> | undefined>()
25+
const closeTimer = shallowRef<ReturnType<typeof setTimeout> | undefined>()
26+
const isFlipped = shallowRef(false)
27+
28+
onMounted(() => {
29+
isMounted.value = true
30+
})
31+
32+
onBeforeUnmount(() => {
33+
if (openTimer.value) clearTimeout(openTimer.value)
34+
if (closeTimer.value) clearTimeout(closeTimer.value)
35+
})
36+
3337
const pmLinks = {
3438
npm: 'https://www.npmjs.com/',
3539
pnpm: 'https://pnpm.io/',
@@ -141,7 +145,7 @@ function onMouseEnter(contributor: GitHubContributor) {
141145
function cancelClose() {
142146
if (closeTimer.value) {
143147
clearTimeout(closeTimer.value)
144-
closeTimer.value = null
148+
closeTimer.value = undefined
145149
}
146150
}
147151

0 commit comments

Comments
 (0)