Changeset View
Changeset View
Standalone View
Standalone View
web/navigation-panels/app-switcher.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { useDispatch } from 'react-redux'; | import { useDispatch } from 'react-redux'; | ||||
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; | import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; | ||||
import { | import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js'; | ||||
mostRecentlyReadThreadSelector, | |||||
unreadCount, | |||||
} from 'lib/selectors/thread-selectors.js'; | |||||
import NavigationPanel from './navigation-panel.react.js'; | import NavigationPanel from './navigation-panel.react.js'; | ||||
import css from './topbar.css'; | import css from './topbar.css'; | ||||
import { updateNavInfoActionType } from '../redux/action-types.js'; | import { updateNavInfoActionType } from '../redux/action-types.js'; | ||||
import { useSelector } from '../redux/redux-utils.js'; | import { useSelector } from '../redux/redux-utils.js'; | ||||
import { navTabSelector } from '../selectors/nav-selectors.js'; | import { navTabSelector } from '../selectors/nav-selectors.js'; | ||||
import { unreadCountInSelectedCommunity } from '../selectors/thread-selectors.js'; | |||||
function AppSwitcher(): React.Node { | function AppSwitcher(): React.Node { | ||||
const activeChatThreadID = useSelector( | const activeChatThreadID = useSelector( | ||||
state => state.navInfo.activeChatThreadID, | state => state.navInfo.activeChatThreadID, | ||||
); | ); | ||||
const mostRecentlyReadThread = useSelector(mostRecentlyReadThreadSelector); | const mostRecentlyReadThread = useSelector(mostRecentlyReadThreadSelector); | ||||
const isActiveThreadCurrentlyUnread = useSelector( | const isActiveThreadCurrentlyUnread = useSelector( | ||||
state => | state => | ||||
Show All 19 Lines | const onClickChat = React.useCallback( | ||||
[ | [ | ||||
dispatch, | dispatch, | ||||
isActiveThreadCurrentlyUnread, | isActiveThreadCurrentlyUnread, | ||||
mostRecentlyReadThread, | mostRecentlyReadThread, | ||||
activeChatThreadID, | activeChatThreadID, | ||||
], | ], | ||||
); | ); | ||||
const boundUnreadCount = useSelector(unreadCount); | const boundUnreadCount = useSelector(unreadCountInSelectedCommunity); | ||||
let chatBadge = null; | let chatBadge = null; | ||||
if (boundUnreadCount > 0) { | if (boundUnreadCount > 0) { | ||||
chatBadge = <span className={css.chatBadge}>{boundUnreadCount}</span>; | chatBadge = <span className={css.chatBadge}>{boundUnreadCount}</span>; | ||||
} | } | ||||
const chatNavigationItem = React.useMemo( | const chatNavigationItem = React.useMemo( | ||||
() => ( | () => ( | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |