diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -25,7 +25,10 @@ createLoadingStatusSelector, combineLoadingStatuses, } from 'lib/selectors/loading-selectors'; -import { mostRecentReadThreadSelector } from 'lib/selectors/thread-selectors'; +import { + mostRecentReadThreadSelector, + unreadCount, +} from 'lib/selectors/thread-selectors'; import { isLoggedIn } from 'lib/selectors/user-selectors'; import type { LoadingStatus } from 'lib/types/loading-types'; import type { Dispatch } from 'lib/types/redux-types'; @@ -46,6 +49,7 @@ import Splash from './splash/splash.react'; import './typography.css'; import css from './style.css'; +import getTitle from './title/getTitle'; import { type NavInfo, updateNavInfoActionType } from './types/nav-types'; import { canonicalURLFromReduxState, navInfoFromURL } from './url-utils'; @@ -212,6 +216,11 @@ !!state.threadStore.threadInfos[activeChatThreadID]?.currentUser.unread, ); + const boundUnreadCount = useSelector(unreadCount); + React.useEffect(() => { + document.title = getTitle(boundUnreadCount); + }, [boundUnreadCount]); + const dispatch = useDispatch(); const modalContext = useModalContext(); diff --git a/web/sidebar/app-switcher.react.js b/web/sidebar/app-switcher.react.js --- a/web/sidebar/app-switcher.react.js +++ b/web/sidebar/app-switcher.react.js @@ -12,7 +12,6 @@ import { useSelector } from '../redux/redux-utils'; import SWMansionIcon from '../SWMansionIcon.react'; -import getTitle from '../title/getTitle'; import { updateNavInfoActionType } from '../types/nav-types'; import css from './left-layout-aside.css'; @@ -31,12 +30,6 @@ state => state.currentUserInfo && state.currentUserInfo.id, ); - const boundUnreadCount = useSelector(unreadCount); - - React.useEffect(() => { - document.title = getTitle(boundUnreadCount); - }, [boundUnreadCount]); - const dispatch = useDispatch(); const onClickCalendar = React.useCallback( @@ -71,6 +64,8 @@ ], ); + const boundUnreadCount = useSelector(unreadCount); + invariant(viewerID, 'should be set'); let chatBadge = null; if (boundUnreadCount > 0) {