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="/">Home</NavItem>
|
||||||
<NavItem to={"/lobby"}>Lobby</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>
|
<NavItem className={"mx-2"} to={"/login"}>Login</NavItem>
|
||||||
:
|
:
|
||||||
<li className={"mx-2"}>
|
<li className={"mx-2"}>
|
||||||
<button onClick={logout} className={"hover:underline"}>Logout</button>
|
<button onClick={logout} className={"hover:underline"}>Logout</button>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|
||||||
{/*TODO show signed in user when signed in, otherwise login button*/}
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
@ -39,11 +39,11 @@ export const thisPlayerAtom = atom(get => {
|
|||||||
}
|
}
|
||||||
return atomValue;
|
return atomValue;
|
||||||
}, (get, set, player: Player | undefined) => {
|
}, (get, set, player: Player | undefined) => {
|
||||||
set(playerAtom, player);
|
|
||||||
if (player)
|
if (player)
|
||||||
sessionStorage.setItem(playerStorage, JSON.stringify(player));
|
sessionStorage.setItem(playerStorage, JSON.stringify(player));
|
||||||
else
|
else
|
||||||
sessionStorage.removeItem(playerStorage);
|
sessionStorage.removeItem(playerStorage);
|
||||||
|
set(playerAtom, player);
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* All dice that have been rolled.
|
* All dice that have been rolled.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user