Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3511984
D7327.id24969.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7327.id24969.diff
View Options
diff --git a/web/app.react.js b/web/app.react.js
--- a/web/app.react.js
+++ b/web/app.react.js
@@ -23,7 +23,6 @@
createLoadingStatusSelector,
combineLoadingStatuses,
} from 'lib/selectors/loading-selectors.js';
-import { unreadCount } from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
@@ -42,6 +41,7 @@
import UpdateModalHandler from './modals/update-modal.react.js';
import SettingsSwitcher from './navigation-panels/settings-switcher.react.js';
import Topbar from './navigation-panels/topbar.react.js';
+import useBadgeHandler from './push-notif/badge-handler.react.js';
import { PushNotificationsHandler } from './push-notif/push-notifs-handler.js';
import { updateNavInfoActionType } from './redux/action-types.js';
import DeviceIDUpdater from './redux/device-id-updater.js';
@@ -58,7 +58,6 @@
import Splash from './splash/splash.react.js';
import './typography.css';
import css from './style.css';
-import getTitle from './title/getTitle.js';
import { type NavInfo } from './types/nav-types.js';
import { canonicalURLFromReduxState, navInfoFromURL } from './url-utils.js';
@@ -309,11 +308,7 @@
!!state.threadStore.threadInfos[activeChatThreadID]?.currentUser.unread,
);
- const boundUnreadCount = useSelector(unreadCount);
- React.useEffect(() => {
- document.title = getTitle(boundUnreadCount);
- electron?.setBadge(boundUnreadCount === 0 ? null : boundUnreadCount);
- }, [boundUnreadCount]);
+ useBadgeHandler();
const dispatch = useDispatch();
const modalContext = useModalContext();
diff --git a/web/push-notif/badge-handler.react.js b/web/push-notif/badge-handler.react.js
new file mode 100644
--- /dev/null
+++ b/web/push-notif/badge-handler.react.js
@@ -0,0 +1,20 @@
+// @flow
+
+import * as React from 'react';
+import { useSelector } from 'react-redux';
+
+import { unreadCount } from 'lib/selectors/thread-selectors.js';
+
+import electron from '../electron.js';
+import getTitle from '../title/getTitle.js';
+
+function useBadgeHandler() {
+ const boundUnreadCount = useSelector(unreadCount);
+
+ React.useEffect(() => {
+ document.title = getTitle(boundUnreadCount);
+ electron?.setBadge(boundUnreadCount === 0 ? null : boundUnreadCount);
+ }, [boundUnreadCount]);
+}
+
+export default useBadgeHandler;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 5:43 PM (18 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690499
Default Alt Text
D7327.id24969.diff (2 KB)
Attached To
Mode
D7327: [web] Extract useBadgeHandler
Attached
Detach File
Event Timeline
Log In to Comment