Skip to content

Commit

Permalink
fix: optional
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 12, 2023
1 parent ee3f5db commit 4d03672
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface AppConfig {
hero: Hero
module: Module

custom: Custom
custom?: Custom
}
export interface Custom {
css: string[]
Expand Down
6 changes: 5 additions & 1 deletion src/components/layout/header/internal/AnimatedLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { useQuery } from '@tanstack/react-query'
import { useCallback } from 'react'
import { AnimatePresence, m } from 'framer-motion'
import { useRouter } from 'next/navigation'
import type { Bilibili } from '~/app/config'

import { getAdminUrl, isLogged, useViewport } from '~/atoms'
import { useSingleAndDoubleClick } from '~/hooks/common/use-single-double-click'
import { noopObj } from '~/lib/noop'
import { Routes } from '~/lib/route-builder'
import { toast } from '~/lib/toast'
import { useAppConfigSelector } from '~/providers/root/aggregation-data-provider'
Expand All @@ -23,7 +25,9 @@ const TapableLogo = () => {
enabled: false,
})

const { liveId } = useAppConfigSelector((config) => config.module.bilibili)!
const { liveId } = (useAppConfigSelector(
(config) => config.module?.bilibili,
) || noopObj) as Bilibili

const goLive = useCallback(() => {
window.open(`https://live.bilibili.com/${liveId}`)
Expand Down
4 changes: 3 additions & 1 deletion src/components/layout/header/internal/SiteOwnerAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {

export const SiteOwnerAvatar: Component = ({ className }) => {
const avatar = useAggregationSelector((data) => data.user.avatar)
const liveId = useAppConfigSelector((config) => config.module.bilibili.liveId)
const liveId = useAppConfigSelector(
(config) => config.module?.bilibili?.liveId,
)

const { data: isLiving } = useQuery({
queryKey: ['live-check'],
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/shared/AsideDonateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const overlayShowAtom = atom(false)

export const AsideDonateButton = () => {
const isClient = useIsClient()
const donate = useAppConfigSelector((config) => config.module.donate)!
const donate = useAppConfigSelector((config) => config.module?.donate)

const overlayOpen = useAtomValue(overlayShowAtom)

Expand Down
2 changes: 1 addition & 1 deletion src/providers/root/script-inject-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Script from 'next/script'
import { useAppConfigSelector } from './aggregation-data-provider'

export const ScriptInjectProvider = () => {
const scripts = useAppConfigSelector((config) => config.custom.scripts)
const scripts = useAppConfigSelector((config) => config.custom?.scripts)
if (!scripts) return null
return (
<>
Expand Down

1 comment on commit 4d03672

@vercel
Copy link

@vercel vercel bot commented on 4d03672 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

shiro-git-main-innei.vercel.app
springtide.vercel.app
shiro-innei.vercel.app
innei.in

Please sign in to comment.