Skip to content

Commit

Permalink
fix: pref
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Jun 19, 2023
1 parent 7504ce9 commit 8f736d8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/ui/portal/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isClientSide } from '~/utils/env'

export const useRootPortal = () => {
const ctx = useContext(RootPortalContext)
if (!isClientSide()) {
if (!isClientSide) {
return null
}
return ctx.to || document.body
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/data/use-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useNoteData = () => {
const nid = useNoteNId()

const searchParams = useMemo(
() => (isClientSide() ? new URLSearchParams(location.search) : null),
() => (isClientSide ? new URLSearchParams(location.search) : null),
[nid],
)
const password = searchParams?.get('password')
Expand All @@ -31,7 +31,7 @@ export const useNoteNId = () => {

export const useNoteByNidQuery = (nid: string) => {
const searchParams = useMemo(
() => (isClientSide() ? new URLSearchParams(location.search) : null),
() => (isClientSide ? new URLSearchParams(location.search) : null),
[nid],
)
const password = searchParams?.get('password')
Expand Down
8 changes: 2 additions & 6 deletions src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export const isClientSide = () => {
return typeof window !== 'undefined'
}
export const isServerSide = () => {
return !isClientSide()
}
export const isClientSide = typeof window !== 'undefined'
export const isServerSide = !isClientSide

export const isDev = process.env.NODE_ENV === 'development'
4 changes: 2 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { API_URL } from '~/constants/env'

import PKG from '../../package.json'
import { getToken } from './cookie'
import { isDev } from './env'
import { isDev, isServerSide } from './env'

const genUUID = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
Expand Down Expand Up @@ -40,7 +40,7 @@ $axios.interceptors.request.use((config) => {
config.headers['x-uuid'] = uuid
}

if (isDev) {
if (isDev && isServerSide) {
console.log(`[Request]: ${config.url}`)
}

Expand Down

1 comment on commit 8f736d8

@vercel
Copy link

@vercel vercel bot commented on 8f736d8 Jun 19, 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:

springtide – ./

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

Please sign in to comment.