Skip to content

Commit

Permalink
[feat] delete redundant toast
Browse files Browse the repository at this point in the history
  • Loading branch information
whyNot077 committed Dec 15, 2023
1 parent e5860df commit b15cf6a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
7 changes: 0 additions & 7 deletions project/frontend/src/components/common/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import InviteModal from '../game/InviteModal';
import MatchingModal from '../game/MatchingModal';
import useNotAllowedPong from '../game/notAllowedPong';
import useNewFriend from '../notification/NewFriendToast';
import { Notification } from '../notification/Notification';
import useStore from '../pong/Update';
Expand All @@ -22,7 +21,6 @@ const Navbar = () => {
const socket = getGameSocket();
const router = useRouter();
const { setIsPlayer1 } = useStore();
const { isOpen, closeToast } = useNotAllowedPong();
const { message, closeMessage } = useToast();

useEffect(() => {
Expand All @@ -37,10 +35,6 @@ const Navbar = () => {
};
}, [socket, setIsPlayer1]);

useEffect(() => {
setTimeout(() => closeToast(), 2000);
}, [isOpen, closeToast]);

useEffect(() => {
setTimeout(() => closeMessage(), 2000);
}, [message, closeMessage]);
Expand Down Expand Up @@ -88,7 +82,6 @@ const Navbar = () => {
return (
<>
{message && <div className={css}>{message}</div>}
{isOpen && <div className={css}>게임이 시작되지 않았어요!</div>}
{errorMessage && <div className={css}>{errorMessage}</div>}
{isNewFriendOpen && (
<div className={css}>{friendName}님과 친구가 되었습니다!</div>
Expand Down
17 changes: 0 additions & 17 deletions project/frontend/src/components/game/notAllowedPong.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions project/frontend/src/components/pong/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { avatarToUrl } from '@/app/_internal/util/avatarToUrl';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import useNotAllowedPong from '../game/notAllowedPong';
import usePaddleMovement from './KeyHandle';
import useStore from './Update';
import {
Expand All @@ -17,6 +16,7 @@ import {
SMALL_PADDLE_HEIGHT,
} from './gameConstants';
import { getGameSocket } from './gameSocket';
import useToast from '../common/useToast';

const usePaddleHeight = (type: number) => {
return useMemo(() => {
Expand Down Expand Up @@ -69,14 +69,14 @@ function Board() {
socket.emit('clientReady', socket.id);
}, [socket]);

const { OpenToast } = useNotAllowedPong();
const { openMessage } = useToast();

useEffect(() => {
if (isPlayer1 === undefined) {
router.replace('/game');
OpenToast();
openMessage('게임이 시작되지 않았어요!');
}
}, [isPlayer1, router, OpenToast]);
}, [isPlayer1, router, openMessage]);

/* --------------------- 게임 중단 --------------------- */
const handleDisconnect = useCallback(() => {
Expand Down

0 comments on commit b15cf6a

Please sign in to comment.