Skip to content

Commit

Permalink
Merge pull request #102 from elsoul/new/style
Browse files Browse the repository at this point in the history
new/style
  • Loading branch information
KishiTheMechanic authored Dec 26, 2023
2 parents 5e79e9f + 342586d commit a9c99ee
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/components/pages/user/chat/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { GPTModel, chatContentSchema, getGptChatModelName } from '@/utils/form'
import { fetchSkeetFunctions } from '@/lib/skeet'
import Image from 'next/image'
import { ChatRoom } from './ChatMenu'
import { CreateStreamChatMessageParams } from '@common/types/http/skeet/createStreamChatMessageParams'
import { CreateStreamChatMessageParams } from '@common/types/http/createStreamChatMessageParams'
import { z } from 'zod'
import { useForm, Controller } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/user/vertex-ai/VertexChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
VertexChatBoxQuery$variables,
} from '@/__generated__/VertexChatBoxQuery.graphql'
import { sleep } from '@/utils/time'
import { CreateVertexMessageParams } from '@common/types/http/skeet/createVertexMessageParams'
import { CreateVertexMessageParams } from '@common/types/http/createVertexMessageParams'
import VertexChatExamples from './VertexChatExamples'

type ChatMessage = {
Expand Down
24 changes: 4 additions & 20 deletions src/layouts/auth/AuthLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import type { ReactNode } from 'react'
import { useEffect, useCallback } from 'react'
import CommonFooter from '@/layouts/common/CommonFooter'
import { User, signOut } from 'firebase/auth'
import { fetchQuery, graphql } from 'react-relay'
import { graphql } from 'react-relay'
import AuthHeader from './AuthHeader'
import { useRecoilState } from 'recoil'
import { defaultUser, userState } from '@/store/user'
import { auth } from '@/lib/firebase'
import { createEnvironment } from '@/lib/relayEnvironment'
import { AuthLayoutQuery } from '@/__generated__/AuthLayoutQuery.graphql'
import useI18nRouter from '@/hooks/useI18nRouter'

type Props = {
Expand Down Expand Up @@ -54,27 +52,13 @@ export default function AuthLayout({ children }: Props) {
const onAuthStateChanged = useCallback(
async (fbUser: User | null) => {
if (auth && fbUser && fbUser.emailVerified) {
const user = await fetchQuery<AuthLayoutQuery>(
createEnvironment(),
authLayoutQuery,
{},
).toPromise()
if (user?.me?.id) {
setUser({
id: user.me.id,
uid: fbUser.uid,
email: fbUser.email ?? '',
username: user.me.username ?? '',
iconUrl: user.me.iconUrl ?? '',
emailVerified: fbUser.emailVerified,
})
try {
await routerPush('/user/vertex-ai')
} else {
} catch (e) {
console.error(e)
setUser(defaultUser)
await signOut(auth)
}
} else {
setUser(defaultUser)
}
},
[setUser, routerPush],
Expand Down
7 changes: 5 additions & 2 deletions src/layouts/user/UserLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ export default function UserLayout({ children }: Props) {
await routerPush('/auth/login')
}
} else {
setUser(defaultUser)
await routerPush('/auth/login')
if (auth && !fbUser) {
setUser(defaultUser)
await signOut(auth)
await routerPush('/auth/login')
}
}
},
[setUser, routerPush],
Expand Down
33 changes: 0 additions & 33 deletions src/types/article.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/types/http/skeet/createStreamChatMessageParams.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/types/http/skeet/createVertexMessageParams.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/types/http/skeet/rootParams.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/types/models/README.md

This file was deleted.

6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"paths": {
"@/*": ["src/*"],
"@lib/*": ["lib/*"],
"@root/*": ["./*"]
"@root/*": ["./*"],
"@common/*": ["./common/*"]
}
},
"ts-node": {
Expand All @@ -32,7 +33,8 @@
"**/*.ts",
"**/*.tsx",
"build.ts",
"devBuild.ts"
"devBuild.ts",
"common/**/*"
],
"exclude": [
"node_modules",
Expand Down

0 comments on commit a9c99ee

Please sign in to comment.