Skip to content

Commit

Permalink
refactor: remove type MayBe
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Mar 12, 2024
1 parent e4fb649 commit a93ef7b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/client/components/SocialShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { usePageFrontmatter, withBase } from 'vuepress/client'
import { getMetaContentByName, inBrowser, isExternalUrl } from '../utils.js'
import { SocialShareNetwork } from './SocialShareNetwork.js'
import type {
MayBe,
SocialShareNetwork as Network,
QRCodeOptions,
SocialShareFrontmatter,
Expand Down Expand Up @@ -76,7 +75,7 @@ export const SocialShare = defineComponent({
)

const frontmatter = usePageFrontmatter<SocialShareFrontmatter>()
const timer = ref<MayBe<number>>(null)
const timer = ref<number | undefined>()
const popup = reactive({
status: false,
resizable: false,
Expand Down Expand Up @@ -185,7 +184,7 @@ export const SocialShare = defineComponent({

// Methods
const openSharer = (shareURL: string) => {
let popWindow: MayBe<Window> = null
let popWindow: Window | null = null
const shareParams: string[] = [
`status=${popup.status ? 'yes' : 'no'}`,
`height=${popup.height}`,
Expand All @@ -205,7 +204,7 @@ export const SocialShare = defineComponent({
popWindow?.focus?.()
timer.value = window.setInterval(() => {
if (popWindow?.closed) {
window.clearInterval(timer.value!)
window.clearInterval(timer.value)
popWindow = null
}
}, 500)
Expand Down
2 changes: 0 additions & 2 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { QRCodeToDataURLOptions } from 'qrcode'

export type MayBe<T> = T | null | undefined

export type SocialShareType = 'popup' | 'qrcode' | 'direct'

export interface SocialShareNetwork {
Expand Down

0 comments on commit a93ef7b

Please sign in to comment.