-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] display online status (#252)
* [frontend] useState が client component でのみ利用できるので file を分けた * [frontend] session.ts が client component として読まれ、 cookies を import するところでエラー * [frontend] server component は 全て async にしなければならない * [frontend] use context in UserList * [frontend] display uesr's online status!!!
- Loading branch information
Showing
6 changed files
with
56 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
|
||
export function useOnlineStatus() { | ||
const [onlineStatus, setOnlineStatus] = useState<{ [key: number]: number }>( | ||
{}, | ||
); | ||
return { onlineStatus, setOnlineStatus }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use client"; | ||
|
||
import { useOnlineStatus } from "./lib/hooks/useOnlineStatus"; | ||
import SocketProvider, { OnlineContext } from "./lib/client-socket-provider"; | ||
|
||
export function OnlineProviders({ children }: { children: React.ReactNode }) { | ||
const { onlineStatus, setOnlineStatus } = useOnlineStatus(); | ||
return ( | ||
<> | ||
<OnlineContext.Provider value={onlineStatus}> | ||
{children} | ||
<SocketProvider setOnlineStatus={setOnlineStatus} /> | ||
</OnlineContext.Provider> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters