Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3509318
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/web/push-notif/badge-handler.react.js b/web/push-notif/badge-handler.react.js
index c8ff49a79..6cf5d98a8 100644
--- a/web/push-notif/badge-handler.react.js
+++ b/web/push-notif/badge-handler.react.js
@@ -1,20 +1,33 @@
// @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 connection = useSelector(state => state.connection);
+ const prevConnection = React.useRef();
+
const boundUnreadCount = useSelector(unreadCount);
+ const prevUnreadCount = React.useRef(boundUnreadCount);
React.useEffect(() => {
- document.title = getTitle(boundUnreadCount);
- electron?.setBadge(boundUnreadCount === 0 ? null : boundUnreadCount);
- }, [boundUnreadCount]);
+ if (
+ 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;
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Dec 23, 3:24 AM (10 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690285
Default Alt Text
(1 KB)
Attached To
Mode
rCOMM Comm
Attached
Detach File
Event Timeline
Log In to Comment