Skip to content

Commit 0b78d47

Browse files
authored
非効率な部分を削除 (#668)
# PRの概要 close #655 ## 具体的な変更内容 - useModalの適用範囲を制限 - existの確認をより簡単に ## 影響範囲 ## 動作要件 ## 補足 ## レビューリクエストを出す前にチェック! - [ ] 改めてセルフレビューしたか - [ ] 手動での動作検証を行ったか - [ ] server の機能追加ならば、テストを書いたか - 理由: 書いた | server の機能追加ではない - [ ] 間違った使い方が存在するならば、それのドキュメントをコメントで書いたか - 理由: 書いた | 間違った使い方は存在しない - [ ] わかりやすいPRになっているか <!-- レビューリクエスト後は、Slackでもメンションしてお願いすることを推奨します。 -->
1 parent c1dfc1d commit 0b78d47

File tree

6 files changed

+47
-44
lines changed

6 files changed

+47
-44
lines changed

server/src/router/users.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "common/zod/schemas";
88
import { Hono } from "hono";
99
import { z } from "zod";
10+
import { prisma } from "../database/client";
1011
import {
1112
getPendingRequestsFromUser,
1213
getPendingRequestsToUser,
@@ -51,9 +52,17 @@ const router = new Hono()
5152
// ユーザーの存在を確認するためのエンドポイント。だれでもアクセス可能
5253
.get("/exists/:guid", param({ guid: z.string() }), async (c) => {
5354
const guid = c.req.valid("param").guid;
54-
const ok = await core.userExists(guid as GUID);
55-
c.status(ok.code);
56-
return c.json({});
55+
const user = await prisma.user.findFirst({
56+
where: {
57+
guid: guid,
58+
},
59+
select: { guid: true, name: true },
60+
});
61+
if (!user) {
62+
return c.json({ message: "User not found" }, 404);
63+
}
64+
65+
return c.json(200);
5766
})
5867

5968
// 特定のユーザーとマッチしたユーザーを取得

web/app/chat/layout.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import BottomBar from "~/components/BottomBar";
22
import Header from "~/components/Header";
33
import { NavigateByAuthState } from "~/components/common/NavigateByAuthState";
4+
import { ModalProvider } from "~/components/common/modal/ModalProvider";
45

5-
export default function Layout({
6-
children,
7-
}: {
8-
children: React.ReactNode;
9-
}) {
6+
export default function Layout({ children }: { children: React.ReactNode }) {
107
return (
118
<>
12-
<Header title="チャット" />
13-
<NavigateByAuthState type="toLoginForUnauthenticated">
14-
<div className="h-full overflow-y-auto pt-12 pb-12">{children}</div>
15-
</NavigateByAuthState>
16-
<BottomBar activeTab="3_chat" />
9+
<ModalProvider>
10+
<Header title="チャット" />
11+
<NavigateByAuthState type="toLoginForUnauthenticated">
12+
<div className="h-full overflow-y-auto pt-12 pb-12">{children}</div>
13+
</NavigateByAuthState>
14+
<BottomBar activeTab="3_chat" />
15+
</ModalProvider>
1716
</>
1817
);
1918
}

web/app/friends/layout.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import BottomBar from "~/components/BottomBar";
22
import Header from "~/components/Header";
33
import { NavigateByAuthState } from "~/components/common/NavigateByAuthState";
4+
import { ModalProvider } from "~/components/common/modal/ModalProvider";
45

5-
export default function Layout({
6-
children,
7-
}: {
8-
children: React.ReactNode;
9-
}) {
6+
export default function Layout({ children }: { children: React.ReactNode }) {
107
return (
118
<>
12-
<Header title="フレンド" />
13-
<NavigateByAuthState type="toLoginForUnauthenticated">
14-
<div className="h-full overflow-y-auto pt-12 pb-12">{children}</div>
15-
</NavigateByAuthState>
16-
<BottomBar activeTab="1_friends" />
9+
<ModalProvider>
10+
<Header title="フレンド" />
11+
<NavigateByAuthState type="toLoginForUnauthenticated">
12+
<div className="h-full overflow-y-auto pt-12 pb-12">{children}</div>
13+
</NavigateByAuthState>
14+
<BottomBar activeTab="1_friends" />
15+
</ModalProvider>
1716
</>
1817
);
1918
}

web/app/layout.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import "@fontsource/roboto/500.css";
1010
import "@fontsource/roboto/700.css";
1111
import BanLandscape from "~/components/BanLandscape";
1212
import { AlertProvider } from "~/components/common/alert/AlertProvider";
13-
import { ModalProvider } from "~/components/common/modal/ModalProvider";
14-
import AuthProvider from "~/firebase/auth/AuthProvider";
1513

1614
const theme = createTheme({
1715
palette: {
@@ -45,15 +43,13 @@ export default function RootLayout({
4543
anchorOrigin={{ horizontal: "right", vertical: "top" }}
4644
>
4745
<React.StrictMode>
48-
<AuthProvider>
49-
<CssBaseline />
50-
<AlertProvider>
51-
<ModalProvider>
52-
<BanLandscape />
53-
{children}
54-
</ModalProvider>
55-
</AlertProvider>
56-
</AuthProvider>
46+
<CssBaseline />
47+
<AlertProvider>
48+
{/* <ModalProvider> */}
49+
<BanLandscape />
50+
{children}
51+
{/* </ModalProvider> */}
52+
</AlertProvider>
5753
</React.StrictMode>
5854
</SnackbarProvider>
5955
</ThemeProvider>

web/app/search/layout.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import BottomBar from "~/components/BottomBar";
22
import Header from "~/components/Header";
33
import { NavigateByAuthState } from "~/components/common/NavigateByAuthState";
4+
import { ModalProvider } from "~/components/common/modal/ModalProvider";
45

5-
export default function Layout({
6-
children,
7-
}: {
8-
children: React.ReactNode;
9-
}) {
6+
export default function Layout({ children }: { children: React.ReactNode }) {
107
return (
118
<>
12-
<Header title="検索" />
13-
<NavigateByAuthState type="toLoginForUnauthenticated">
14-
<div className="h-full overflow-y-auto pt-12 pb-12">{children}</div>
15-
</NavigateByAuthState>
16-
<BottomBar activeTab="2_search" />
9+
<ModalProvider>
10+
<Header title="検索" />
11+
<NavigateByAuthState type="toLoginForUnauthenticated">
12+
<div className="h-full overflow-y-auto pt-12 pb-12">{children}</div>
13+
</NavigateByAuthState>
14+
<BottomBar activeTab="2_search" />
15+
</ModalProvider>
1716
</>
1817
);
1918
}

web/components/common/modal/ModalProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import type { UserWithCoursesAndSubjects } from "common/types";
23
import { type ReactNode, createContext, useContext, useState } from "react";
34
import { useAboutMe } from "~/api/user";

0 commit comments

Comments
 (0)