Commit
·
02f98b1
1
Parent(s):
2902f73
debug
Browse files
frontend/app/layout.js
CHANGED
@@ -11,8 +11,6 @@ import { RelayAPIProvider } from '@components/RelayAPI';
|
|
11 |
import { ToastProvider } from "@lib/ToastContext";
|
12 |
|
13 |
export default function RootLayout({ children }) {
|
14 |
-
const userID = localStorage.getItem('u_id');
|
15 |
-
|
16 |
return (
|
17 |
<html lang="en">
|
18 |
<body>
|
@@ -36,7 +34,7 @@ export default function RootLayout({ children }) {
|
|
36 |
}}
|
37 |
/>
|
38 |
<NexusAuthWrapper>
|
39 |
-
<RelayAPIProvider
|
40 |
<Sidebar />
|
41 |
{children}
|
42 |
</RelayAPIProvider>
|
|
|
11 |
import { ToastProvider } from "@lib/ToastContext";
|
12 |
|
13 |
export default function RootLayout({ children }) {
|
|
|
|
|
14 |
return (
|
15 |
<html lang="en">
|
16 |
<body>
|
|
|
34 |
}}
|
35 |
/>
|
36 |
<NexusAuthWrapper>
|
37 |
+
<RelayAPIProvider>
|
38 |
<Sidebar />
|
39 |
{children}
|
40 |
</RelayAPIProvider>
|
frontend/components/RelayAPI.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
// RelayAPI.js - Next.js Wrapper for the WebSocket Server
|
2 |
|
3 |
import { useEffect, useState, useCallback, useRef } from "react";
|
4 |
-
import { toast } from "react-toastify";
|
5 |
|
6 |
const useWebSocket = (userId) => {
|
7 |
const [socket, setSocket] = useState(null);
|
@@ -114,7 +113,11 @@ const useWebSocket = (userId) => {
|
|
114 |
return { messages, joinChannel, leaveChannel, broadcast, sendToUser };
|
115 |
};
|
116 |
|
117 |
-
export const RelayAPIProvider = ({ userId, children }) => {
|
|
|
|
|
|
|
|
|
118 |
const contextValue = useWebSocket(userId);
|
119 |
|
120 |
return (
|
|
|
1 |
// RelayAPI.js - Next.js Wrapper for the WebSocket Server
|
2 |
|
3 |
import { useEffect, useState, useCallback, useRef } from "react";
|
|
|
4 |
|
5 |
const useWebSocket = (userId) => {
|
6 |
const [socket, setSocket] = useState(null);
|
|
|
113 |
return { messages, joinChannel, leaveChannel, broadcast, sendToUser };
|
114 |
};
|
115 |
|
116 |
+
export const RelayAPIProvider = ({ userId=null, children }) => {
|
117 |
+
if (userId === null) {
|
118 |
+
userId = localStorage.getItem("u_id");
|
119 |
+
console.log("inside context")
|
120 |
+
}
|
121 |
const contextValue = useWebSocket(userId);
|
122 |
|
123 |
return (
|