Page MenuHomePhabricator

D7328.diff
No OneTemporary

D7328.diff

diff --git a/web/push-notif/badge-handler.react.js b/web/push-notif/badge-handler.react.js
--- a/web/push-notif/badge-handler.react.js
+++ b/web/push-notif/badge-handler.react.js
@@ -9,12 +9,25 @@
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

Mime Type
text/plain
Expires
Sun, Dec 22, 7:06 AM (6 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690528
Default Alt Text
D7328.diff (1 KB)

Event Timeline