diff options
author | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-01-14 14:08:03 +0200 |
---|---|---|
committer | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-01-14 14:08:03 +0200 |
commit | 1f696f34c2ea50b35f166417c4b56b2dac46b340 (patch) | |
tree | 852c0db910f5e92afd9061919cd93c567c143c87 | |
parent | 847ecd9a69efe9e0395f78f3b2e1729d181ec109 (diff) | |
download | epq-web-1f696f34c2ea50b35f166417c4b56b2dac46b340.tar.gz epq-web-1f696f34c2ea50b35f166417c4b56b2dac46b340.tar.bz2 epq-web-1f696f34c2ea50b35f166417c4b56b2dac46b340.zip |
refactored code. Moved non-tsx bits to /src/handlers/
-rw-r--r-- | src/App.tsx | 4 | ||||
-rw-r--r-- | src/Chat/Chat.tsx (renamed from src/Chat/ChatWrapper.tsx) | 4 | ||||
-rw-r--r-- | src/handlers/server.ts (renamed from src/Chat/server.ts) | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/App.tsx b/src/App.tsx index 9542d36..8c4c748 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import ChatWrapper from "./Chat/ChatWrapper"; +import Chat from "./Chat/Chat"; import "./App.css"; import { Message } from "./Chat/types"; import { MessageContainer } from "./Chat/MessageContainer"; @@ -21,7 +21,7 @@ const App = (): React.ReactElement => { return <MessageContainer {...message} />; })} { - <ChatWrapper + <Chat user={username as string} /> } diff --git a/src/Chat/ChatWrapper.tsx b/src/Chat/Chat.tsx index 66e0301..648628e 100644 --- a/src/Chat/ChatWrapper.tsx +++ b/src/Chat/Chat.tsx @@ -15,7 +15,7 @@ const endpoints = { subscription: "/sub/chat", history: "/api/v1/msg/", }; -const ChatWrapper = ({ user }: { user: string }): React.ReactElement => { +const Chat = ({ user }: { user: string }): React.ReactElement => { const [messages, setMessages] = useState<ReactElement[]>([]); let stompClientRef = useRef( new Client({ @@ -117,4 +117,4 @@ const ChatWrapper = ({ user }: { user: string }): React.ReactElement => { </div> ); }; -export default ChatWrapper; +export default Chat; diff --git a/src/Chat/server.ts b/src/handlers/server.ts index d155270..9c0d747 100644 --- a/src/Chat/server.ts +++ b/src/handlers/server.ts @@ -1,5 +1,5 @@ import { Client } from "@stomp/stompjs"; -import { Message, MessageType } from "./types"; +import { Message, MessageType } from "../Chat/types"; const domain = window.location.hostname const port = "8080" const connectionAddress = `ws://${domain}:${port}/ws` |