diff --git a/README.md b/README.md index 221a1a9..1ba03a1 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -chat-app: chat room where useres can chat with each other in real time \ No newline at end of file +chat-app: chat room where users can chat with each other in real time \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 9840dee..6375bf3 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,7 +5,7 @@ - chat + Chat Room diff --git a/frontend/src/components/Login.jsx b/frontend/src/components/Login.jsx index d6f5049..ecb0050 100644 --- a/frontend/src/components/Login.jsx +++ b/frontend/src/components/Login.jsx @@ -22,6 +22,9 @@ export default function Login() { // console.log(result) //log if (result.data.stat === "Success") { setUser(result.data.user); + + // localStorage.setItem('user', JSON.stringify(user)); // locally storing the logged in user + navigate("/") // console.log(user); //log alert('login successful: ' + result.data.user) //using result.data.user instead of user because useRecoilState is a asyncronous function taking time in updating the user variable diff --git a/frontend/src/components/MessageRoom.jsx b/frontend/src/components/MessageRoom.jsx index 3591797..4d37ce7 100644 --- a/frontend/src/components/MessageRoom.jsx +++ b/frontend/src/components/MessageRoom.jsx @@ -60,8 +60,11 @@ export default function App() {
-
-
+ + {/* {JSON.parse(localStorage.getItem('user'))} */} + +
+
@@ -87,23 +90,26 @@ export default function App() {
-
-

Chat Room

+

Messeges

- {data_rcv.map((msg, i) => ( -
- {i + 1}.  - [{formatDate(msg.createdTime)}]   - {msg.username} :   - {msg.message} -
- ))} + { + data_rcv.length === 0 ? (
Fetching ...
) + : (data_rcv.map((msg, i) => ( +
+ {i + 1}.  + [{formatDate(msg.createdTime)}]   + {msg.username} :   + {msg.message} +
+ )) + ) + }
diff --git a/frontend/src/components/OnlineUsers.jsx b/frontend/src/components/OnlineUsers.jsx index 5bec9fb..1fea643 100644 --- a/frontend/src/components/OnlineUsers.jsx +++ b/frontend/src/components/OnlineUsers.jsx @@ -28,13 +28,20 @@ const OnlineUsers = React.memo(() => { return ( <> -
+

Online Users Socket Id [{Math.floor(onlineUsersList.length / 2)}]

- {memoizedUsers} + { + onlineUsersList.length === 0 ? (
Fetching ...
) : + ( +
+ {memoizedUsers} +
+ ) + }