Fixed thisPlayerAtom giving different result than playerAtom
This commit is contained in:
parent
fc5f553042
commit
51bc754ef1
@ -21,15 +21,13 @@ const NavMenu: FC = () => {
|
||||
<NavItem to="/">Home</NavItem>
|
||||
<NavItem to={"/lobby"}>Lobby</NavItem>
|
||||
{
|
||||
player === undefined ? /* TODO thisPlayerAtom contains a player object, from sessionStorage */
|
||||
player === undefined ?
|
||||
<NavItem className={"mx-2"} to={"/login"}>Login</NavItem>
|
||||
:
|
||||
<li className={"mx-2"}>
|
||||
<button onClick={logout} className={"hover:underline"}>Logout</button>
|
||||
</li>
|
||||
}
|
||||
|
||||
{/*TODO show signed in user when signed in, otherwise login button*/}
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
@ -39,11 +39,11 @@ export const thisPlayerAtom = atom(get => {
|
||||
}
|
||||
return atomValue;
|
||||
}, (get, set, player: Player | undefined) => {
|
||||
set(playerAtom, player);
|
||||
if (player)
|
||||
sessionStorage.setItem(playerStorage, JSON.stringify(player));
|
||||
else
|
||||
sessionStorage.removeItem(playerStorage);
|
||||
set(playerAtom, player);
|
||||
});
|
||||
/**
|
||||
* All dice that have been rolled.
|
||||
|
Loading…
x
Reference in New Issue
Block a user