Possibly fix sometimes the Profile menu becomes missing
This commit is contained in:
parent
ce55250943
commit
ec88110e2d
1 changed files with 13 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
import './nav-menu.css';
|
import './nav-menu.css';
|
||||||
|
|
||||||
import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||||
import { useRef, useState } from 'preact/hooks';
|
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||||
import { useLongPress } from 'use-long-press';
|
import { useLongPress } from 'use-long-press';
|
||||||
import { useSnapshot } from 'valtio';
|
import { useSnapshot } from 'valtio';
|
||||||
|
|
||||||
|
@ -16,11 +16,18 @@ import MenuLink from './menu-link';
|
||||||
function NavMenu(props) {
|
function NavMenu(props) {
|
||||||
const snapStates = useSnapshot(states);
|
const snapStates = useSnapshot(states);
|
||||||
const { instance, authenticated } = api();
|
const { instance, authenticated } = api();
|
||||||
const accounts = store.local.getJSON('accounts') || [];
|
|
||||||
const currentAccount = accounts.find(
|
const [currentAccount, setCurrentAccount] = useState();
|
||||||
(account) => account.info.id === store.session.get('currentAccount'),
|
const [moreThanOneAccount, setMoreThanOneAccount] = useState(false);
|
||||||
);
|
|
||||||
const moreThanOneAccount = accounts.length > 1;
|
useEffect(() => {
|
||||||
|
const accounts = store.local.getJSON('accounts') || [];
|
||||||
|
const acc = accounts.find(
|
||||||
|
(account) => account.info.id === store.session.get('currentAccount'),
|
||||||
|
);
|
||||||
|
if (acc) setCurrentAccount(acc);
|
||||||
|
setMoreThanOneAccount(accounts.length > 1);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Home = Following
|
// Home = Following
|
||||||
// But when in multi-column mode, Home becomes columns of anything
|
// But when in multi-column mode, Home becomes columns of anything
|
||||||
|
|
Loading…
Add table
Reference in a new issue