Skip to content

Commit

Permalink
♻️ Format code with prettier (#264)
Browse files Browse the repository at this point in the history
`npx prettier@latest --write frontend backend --plugin=prettier-plugin-organize-imports`
  • Loading branch information
usatie authored Feb 16, 2024
1 parent 2837e6a commit a2c9378
Show file tree
Hide file tree
Showing 27 changed files with 49 additions and 61 deletions.
6 changes: 3 additions & 3 deletions backend/src/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
import { Server, Socket } from 'socket.io';
import { RoomDeletedEvent } from 'src/common/events/room-deleted.event';
import { RoomEnteredEvent } from 'src/common/events/room-entered.event';
import { RoomLeftEvent } from 'src/common/events/room-left.event';
import { RoomMuteEvent } from 'src/common/events/room-mute.event';
import { RoomUnmuteEvent } from 'src/common/events/room-unmute.event';
import { RoomLeftEvent } from 'src/common/events/room-left.event';
import { RoomUpdateRoleEvent } from 'src/common/events/room-update-role.event';
import { ChatService, UserStatus } from './chat.service';
import { MuteService } from 'src/room/mute/mute.service';
import { v4 } from 'uuid';
import { ChatService, UserStatus } from './chat.service';
import { CreateMessageDto } from './dto/create-message.dto';
import { MessageEntity } from './entities/message.entity';
import { v4 } from 'uuid';

@WebSocketGateway({
cors: {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/chat/chat.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { AuthModule } from 'src/auth/auth.module';
import { MuteService } from 'src/room/mute/mute.service';
import { PrismaModule } from 'src/prisma/prisma.module';
import { MuteService } from 'src/room/mute/mute.service';
import { UserService } from '../user/user.service';
import { ChatController } from './chat.controller';
import { ChatGateway } from './chat.gateway';
Expand Down
2 changes: 1 addition & 1 deletion backend/src/room/guards/enter-room.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
ForbiddenException,
Injectable,
} from '@nestjs/common';
import { RoomService } from '../room.service';
import { compare } from 'bcrypt';
import { RoomService } from '../room.service';

@Injectable()
export class EnterRoomGuard implements CanActivate {
Expand Down
8 changes: 4 additions & 4 deletions backend/src/room/mute/mute.controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
Controller,
Get,
Put,
Body,
Controller,
Delete,
Get,
Param,
ParseIntPipe,
Put,
UseGuards,
} from '@nestjs/common';
import { CreateMuteDto } from './dto/create-mute.dto';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
import { AdminGuard } from '../guards/admin.guard';
import { CreateMuteDto } from './dto/create-mute.dto';
import { MuteService } from './mute.service';

@ApiTags('mute')
Expand Down
2 changes: 1 addition & 1 deletion backend/src/room/mute/mute.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { PrismaModule } from 'src/prisma/prisma.module';
import { MuteService } from './mute.service';
import { MuteController } from './mute.controller';
import { MuteService } from './mute.service';

@Module({
controllers: [MuteController],
Expand Down
2 changes: 1 addition & 1 deletion backend/src/room/mute/mute.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
Injectable,
NotFoundException,
} from '@nestjs/common';
import { CreateMuteDto } from './dto/create-mute.dto';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { RoomMuteEvent } from 'src/common/events/room-mute.event';
import { RoomUnmuteEvent } from 'src/common/events/room-unmute.event';
import { PrismaService } from 'src/prisma/prisma.service';
import { CreateMuteDto } from './dto/create-mute.dto';

@Injectable()
export class MuteService {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { Role, User } from '@prisma/client';
import { hash } from 'bcrypt';
import { RoomCreatedEvent } from 'src/common/events/room-created.event';
import { RoomDeletedEvent } from 'src/common/events/room-deleted.event';
import { RoomEnteredEvent } from 'src/common/events/room-entered.event';
Expand All @@ -16,7 +17,6 @@ import { UpdateUserOnRoomDto } from './dto/update-UserOnRoom.dto';
import { UpdateRoomDto } from './dto/update-room.dto';
import { UserOnRoomEntity } from './entities/UserOnRoom.entity';
import { RoomEntity } from './entities/room.entity';
import { hash } from 'bcrypt';

@Injectable()
export class RoomService {
Expand Down
4 changes: 2 additions & 2 deletions backend/test/chat-gateway.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Role } from '@prisma/client';
import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Role } from '@prisma/client';
import { Socket, io } from 'socket.io-client';
import { AppModule } from 'src/app.module';
import { MessageEntity } from 'src/chat/entities/message.entity';
import { CreateRoomDto } from 'src/room/dto/create-room.dto';
import { constants } from './constants';
import { TestApp, UserEntityWithAccessToken } from './utils/app';
import { CreateRoomDto } from 'src/room/dto/create-room.dto';

async function createNestApp(): Promise<INestApplication> {
const moduleFixture: TestingModule = await Test.createTestingModule({
Expand Down
2 changes: 1 addition & 1 deletion backend/test/online-status.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Socket, io } from 'socket.io-client';
import { AppModule } from 'src/app.module';
import { UserStatus } from 'src/chat/chat.service';
import { TestApp, UserEntityWithAccessToken } from './utils/app';
import { expectOnlineStatusResponse } from './utils/matcher';
import { UserStatus } from 'src/chat/chat.service';

type UserAndSocket = {
user: UserEntityWithAccessToken;
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/explore-rooms/explore-rooms.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";

import RoomCard from "./room-card";
import { useCallback, useEffect } from "react";
import { useRouter } from "next/navigation";
import { DeleteRoomEvent, RoomEntity } from "@/app/lib/dtos";
import { chatSocket as socket } from "@/socket";
import { useRouter } from "next/navigation";
import { useCallback, useEffect } from "react";
import RoomCard from "./room-card";

export function ExploreRooms({ rooms }: { rooms: RoomEntity[] }) {
const router = useRouter();
Expand Down
8 changes: 3 additions & 5 deletions frontend/app/lib/client-socket-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use client";
import { ToastAction } from "@/components/ui/toast";
import { useToast } from "@/components/ui/use-toast";
import { chatSocket } from "@/socket";
import { chatSocket, chatSocket as socket } from "@/socket";
import Link from "next/link";
import { useCallback, useEffect } from "react";
import { usePathname, useRouter } from "next/navigation";
import { useEffect } from "react";
import { useAuthContext } from "./client-auth";
import {
DenyEvent,
Expand All @@ -12,9 +13,6 @@ import {
MessageEvent,
PublicUserEntity,
} from "./dtos";
import { chatSocket as socket } from "@/socket";
import { useRouter } from "next/navigation";
import { usePathname } from "next/navigation";

export default function SocketProvider() {
const { toast } = useToast();
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/lib/hooks/useInviteToGame.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useCallback, useState } from "react";
import { chatSocket as socket } from "@/socket";
import { useCallback, useState } from "react";

export const useInviteToGame = (userId: number) => {
const [isInvitingToGame, setIsInvitingToGame] = useState(false);
Expand Down
7 changes: 3 additions & 4 deletions frontend/app/lib/hooks/useKick.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use client";

import { kickUserOnRoom } from "@/app/lib/actions";
import type { LeaveRoomEvent, UserOnRoomEntity } from "@/app/lib/dtos";
import type { LeaveRoomEvent } from "@/app/lib/dtos";
import { toast } from "@/components/ui/use-toast";
import { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { chatSocket as socket } from "@/socket";
import { usePathname } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
import { useCallback, useEffect, useState } from "react";

const showKickErrorToast = () => {
toast({
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/lib/hooks/useMute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { muteUser, unmuteUser } from "@/app/lib/actions";
import type { PublicUserEntity } from "@/app/lib/dtos";
import { toast } from "@/components/ui/use-toast";
import { useCallback, useEffect, useState } from "react";
import { chatSocket as socket } from "@/socket";
import { useCallback, useEffect, useState } from "react";

interface MuteEvent {
userId: number;
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/lib/hooks/useOnlineStatus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { createContext, useEffect, useState } from "react";
import { chatSocket } from "@/socket";
import { createContext, useEffect, useState } from "react";

export const OnlineContext = createContext<{ [key: number]: number }>({});

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/lib/hooks/useUpdateRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { updateRoomUser } from "@/app/lib/actions";
import type { UserOnRoomEntity } from "@/app/lib/dtos";
import { toast } from "@/components/ui/use-toast";
import { useCallback, useEffect, useState } from "react";
import { chatSocket as socket } from "@/socket";
import { useCallback, useEffect, useState } from "react";

type Role = "ADMINISTRATOR" | "MEMBER";

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/onlineProviders.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { OnlineContext, useOnlineStatus } from "./lib/hooks/useOnlineStatus";
import SocketProvider from "./lib/client-socket-provider";
import { OnlineContext, useOnlineStatus } from "./lib/hooks/useOnlineStatus";

export function OnlineProviders({ children }: { children: React.ReactNode }) {
const onlineStatus = useOnlineStatus();
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/pong/JoinRoomForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import MatchButton from "./MatchButton";
import { v4 } from "uuid";
import { Separator } from "@/components/ui/separator";
import MatchButton from "./MatchButton";

export default function JoinRoomForm({}) {
return (
Expand Down
2 changes: 0 additions & 2 deletions frontend/app/room/[id]/mute-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"use client";

import { muteUser, unmuteUser } from "@/app/lib/actions";
import {
ContextMenuItem,
ContextMenuSub,
ContextMenuSubContent,
ContextMenuSubTrigger,
} from "@/components/ui/context-menu";
import { useState } from "react";

export default function MuteMenu({
isMuted,
Expand Down
14 changes: 7 additions & 7 deletions frontend/app/room/[id]/sidebar-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import type {
RoomEntity,
UserOnRoomEntity,
} from "@/app/lib/dtos";
import { useBlock } from "@/app/lib/hooks/useBlock";
import { useInviteToGame } from "@/app/lib/hooks/useInviteToGame";
import { useKick } from "@/app/lib/hooks/useKick";
import { useMute } from "@/app/lib/hooks/useMute";
import { useUpdateRole } from "@/app/lib/hooks/useUpdateRole";
import { Avatar } from "@/app/ui/user/avatar";
import {
ContextMenu,
Expand All @@ -15,15 +20,10 @@ import {
ContextMenuSeparator,
ContextMenuTrigger,
} from "@/components/ui/context-menu";
import { useCallback, useEffect } from "react";
import { chatSocket as socket } from "@/socket";
import { useRouter } from "next/navigation";
import { useBlock } from "@/app/lib/hooks/useBlock";
import { useInviteToGame } from "@/app/lib/hooks/useInviteToGame";
import { useKick } from "@/app/lib/hooks/useKick";
import { useMute } from "@/app/lib/hooks/useMute";
import { useUpdateRole } from "@/app/lib/hooks/useUpdateRole";
import { useCallback, useEffect } from "react";
import MuteMenu from "./mute-menu";
import { chatSocket as socket } from "@/socket";

function truncateString(str: string | undefined, num: number): string {
if (!str) {
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/room/rooms-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client";
import { useAuthContext } from "@/app/lib/client-auth";
import type { EnterRoomEvent, RoomEntity } from "@/app/lib/dtos";
import { Stack } from "@/components/layout/stack";
import { chatSocket as socket } from "@/socket";
import Link from "next/link";
import { useCallback, useEffect } from "react";
import { usePathname, useRouter } from "next/navigation";
import { useCallback, useEffect } from "react";
import CreateRoomDialog from "./create-room-dialog";
import { useAuthContext } from "@/app/lib/client-auth";
import { chatSocket as socket } from "@/socket";

function RoomButton({
room,
Expand Down
12 changes: 3 additions & 9 deletions frontend/app/ui/auth/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@
import { authenticate } from "@/app/lib/actions";
import { useAuthContext } from "@/app/lib/client-auth";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { useFormState, useFormStatus } from "react-dom";
import { Separator } from "@/components/ui/separator";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { Separator } from "@/components/ui/separator";
import { useFormState, useFormStatus } from "react-dom";

export default function LoginForm() {
return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/ui/room/ban-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { banUser } from "@/app/lib/actions";
import { PublicUserEntity } from "@/app/lib/dtos";
import { Avatar } from "@/app/ui/user/avatar";
import Loader from "@/components/ui/loader";
import { Ban } from "lucide-react";
import { toast } from "@/components/ui/use-toast";
import { Ban } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/ui/room/invite-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { inviteUserToRoom } from "@/app/lib/actions";
import { PublicUserEntity } from "@/app/lib/dtos";
import { Avatar } from "@/app/ui/user/avatar";
import Loader from "@/components/ui/loader";
import { LogIn } from "lucide-react";
import { toast } from "@/components/ui/use-toast";
import { LogIn } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";

Expand Down
1 change: 0 additions & 1 deletion frontend/app/ui/room/invite-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { ScrollArea } from "@/components/ui/scroll-area";
import { LogIn } from "lucide-react";
import InviteItem from "./invite-item";

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/ui/room/unban-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { unbanUser } from "@/app/lib/actions";
import { PublicUserEntity } from "@/app/lib/dtos";
import { Avatar } from "@/app/ui/user/avatar";
import Loader from "@/components/ui/loader";
import { CheckCircle2 } from "lucide-react";
import { toast } from "@/components/ui/use-toast";
import { CheckCircle2 } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/ui/user/user-list.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";

import type { PublicUserEntity } from "@/app/lib/dtos";
import { TooltipProvider } from "@/components/ui/tooltip";
import { Avatar, AvatarSize } from "./avatar";
import { OnlineContext } from "@/app/lib/hooks/useOnlineStatus";
import { TooltipProvider } from "@/components/ui/tooltip";
import { useContext } from "react";
import { Avatar, AvatarSize } from "./avatar";

export default function UserList({
users,
Expand Down

0 comments on commit a2c9378

Please sign in to comment.