Skip to content

Commit

Permalink
Merge branch 'develop' into fix/game-screen/typing
Browse files Browse the repository at this point in the history
  • Loading branch information
h-takeyeah committed Apr 16, 2024
2 parents d4a7383 + 09d05a2 commit 4824179
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions typing-app/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export async function login(_: LoginActionState, formData: FormData): Promise<Lo
};

cookies().set("user", JSON.stringify(user), { expires, httpOnly: true });

redirect("/game");
} catch (error) {
return { error: "通信に失敗しました" };
}

redirect("/game"); // NOTE: try-catch外でリダイレクトする
}

export async function logout() {
Expand Down
5 changes: 3 additions & 2 deletions typing-app/src/app/game/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import GamePage from "@/components/pages/Game";
import fs from "fs";

const filenames = fs.readdirSync("public/texts/");

export default function Typing() {
const filenames = fs.readdirSync("src/assets/texts/");
const subjectText = fs.readFileSync(
`src/assets/texts/${filenames[Math.floor(Math.random() * filenames.length)]}`,
`public/texts/${filenames[Math.floor(Math.random() * filenames.length)]}`,
"utf-8"
);
const subjectTextOneLine = subjectText.replace(/\n/gm, " ");
Expand Down

0 comments on commit 4824179

Please sign in to comment.