diff --git a/web/push-notif/badge-handler.react.js b/web/push-notif/badge-handler.react.js index 6cf5d98a8..cf446ea87 100644 --- a/web/push-notif/badge-handler.react.js +++ b/web/push-notif/badge-handler.react.js @@ -1,33 +1,34 @@ // @flow import * as React from 'react'; -import { useSelector } from 'react-redux'; +import { connectionSelector } from 'lib/selectors/keyserver-selectors.js'; import { unreadCount } from 'lib/selectors/thread-selectors.js'; import electron from '../electron.js'; +import { useSelector } from '../redux/redux-utils.js'; import getTitle from '../title/getTitle.js'; function useBadgeHandler() { - const connection = useSelector(state => state.connection); + const connection = useSelector(connectionSelector); const prevConnection = React.useRef(); const boundUnreadCount = useSelector(unreadCount); const prevUnreadCount = React.useRef(boundUnreadCount); React.useEffect(() => { if ( - connection.status === 'connected' && + connection?.status === 'connected' && (prevConnection.current?.status !== 'connected' || boundUnreadCount !== prevUnreadCount.current) ) { document.title = getTitle(boundUnreadCount); electron?.setBadge(boundUnreadCount === 0 ? null : boundUnreadCount); } prevConnection.current = connection; prevUnreadCount.current = boundUnreadCount; }, [boundUnreadCount, connection]); } export default useBadgeHandler;