Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
claustra01 committed Aug 15, 2024
1 parent 29da0d3 commit e3bf9e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/hooks/useSocketReciever.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useEffect } from "react";
import { useSocketRefStore } from "../store";
import { PointerSchema, ActionSchema, HitSchema } from "../type/shooting";
import type { ActionSchema, HitSchema, PointerSchema } from "../type/shooting";

export const useSocketReciever = () => {
const socketRef = useSocketRefStore((state) => state.socketRef);

const onMessage = (handler: (data: (PointerSchema | ActionSchema | HitSchema)) => void) => {
const onMessage = (
handler: (data: PointerSchema | ActionSchema | HitSchema) => void,
) => {
useEffect(() => {
const onMessage = (event: MessageEvent) => {
const data = JSON.parse(event.data);
Expand All @@ -17,7 +19,7 @@ export const useSocketReciever = () => {
return () => {
currentSocketRef?.removeEventListener("message", onMessage);
};
}, [socketRef, handler]);
}, [handler]);
};

return { onMessage };
Expand Down
8 changes: 4 additions & 4 deletions src/pages/shooter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { DefaultButton } from "../../components/ui/Button";
import { Modal } from "../../components/ui/Modal";
import { ShooterButton } from "../../components/ui/ShooterButton";
import { useOrientation } from "../../hooks/useOrientation";
import { useSocketReciever } from "../../hooks/useSocketReciever";
import { useSocketRefStore, useUUIDStore } from "../../store";
import { type Schema, event_type, message_type } from "../../type/schema";
import style from "./index.module.css";
import { useSocketReciever } from "../../hooks/useSocketReciever";
import { MessageType } from "../../type/shooting";
import style from "./index.module.css";

const Shooter = () => {
const [isOpen, setIsOpen] = useState(true);
Expand Down Expand Up @@ -74,12 +74,12 @@ const Shooter = () => {

useEffect(() => {
onMessage((data) => {
if (data.message_type == MessageType.Hit && data.id === uuid) {
if (data.message_type === MessageType.Hit && data.id === uuid) {
setScore((prevScore) => prevScore + 1);
console.log(score);
}
});
}, [onMessage])
}, [onMessage, uuid, score]);

const handleClick = () => {
const audio = new Audio("/sound/cork_sound.mp3");
Expand Down
2 changes: 1 addition & 1 deletion src/pages/yatai/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type {
Object3DEventMap,
} from "three";
import { randFloat } from "three/src/math/MathUtils.js";
import { useSocketReciever } from "../../hooks/useSocketReciever";
import { useSocketRefStore } from "../../store";
import {
type ActionSchema,
MessageType,
type Target,
} from "../../type/shooting";
import styles from "./index.module.css";
import { useSocketReciever } from "../../hooks/useSocketReciever";

const YataiStage = memo(() => {
// 土台
Expand Down

0 comments on commit e3bf9e6

Please sign in to comment.