Skip to content

Commit

Permalink
[frontend] display uesr's online status!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
kotto5 committed Feb 11, 2024
1 parent 15990b6 commit 5d86086
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 5 additions & 1 deletion frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Toaster } from "@/components/ui/toaster";
import { getMe } from "@/app/lib/actions";
import { JwtPayload } from "@/app/lib/dtos";
import { OnlineProviders } from "./onlineProviders";
import Nav from "./ui/nav";

const inter = Inter({ subsets: ["latin"] });

Expand Down Expand Up @@ -45,7 +46,10 @@ export default async function RootLayout({
>
<AuthProvider payload={payload as JwtPayload} user={user}>
<Toaster />
<OnlineProviders>{children}</OnlineProviders>
<div className="flex flex-col px-16 h-[100vh]">
<Nav />
<OnlineProviders>{children}</OnlineProviders>
</div>
</AuthProvider>
</ThemeProvider>
</body>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/lib/hooks/useOnlineStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState } from "react";

export function useOnlineStatus() {
const [onlineStatus, setOnlineStatus] = useState<{ [key: number]: number }>(
{}
{},
);
return { onlineStatus, setOnlineStatus };
}
6 changes: 1 addition & 5 deletions frontend/app/onlineProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

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

export function OnlineProviders({ children }: { children: React.ReactNode }) {
const { onlineStatus, setOnlineStatus } = useOnlineStatus();
return (
<>
<OnlineContext.Provider value={onlineStatus}>
<div className="flex flex-col px-16 h-[100vh]">
<Nav />
{children}
</div>
{children}
<SocketProvider setOnlineStatus={setOnlineStatus} />
</OnlineContext.Provider>
</>
Expand Down

0 comments on commit 5d86086

Please sign in to comment.