Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3347737
D12915.diff
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
D12915.diff
View Options
diff --git a/web/push-notif/push-notifs-handler.js b/web/push-notif/push-notifs-handler.js
--- a/web/push-notif/push-notifs-handler.js
+++ b/web/push-notif/push-notifs-handler.js
@@ -119,6 +119,19 @@
),
[dispatch],
);
+
+ // Handle invalid device token
+ const localToken = useSelector(
+ state => state.tunnelbrokerDeviceToken.localToken,
+ );
+ const prevLocalToken = React.useRef(localToken);
+ React.useEffect(() => {
+ if (prevLocalToken.current && !localToken) {
+ electron?.fetchDeviceToken?.();
+ }
+
+ prevLocalToken.current = localToken;
+ }, [localToken]);
}
function useCreatePushSubscription(): () => Promise<void> {
@@ -271,6 +284,27 @@
navigator.serviceWorker?.removeEventListener('message', callback);
}, [dispatch, supported]);
+ // Handle invalid device token
+ const localToken = useSelector(
+ state => state.tunnelbrokerDeviceToken.localToken,
+ );
+ const prevLocalToken = React.useRef(localToken);
+ React.useEffect(() => {
+ if (
+ !navigator.serviceWorker ||
+ !supported ||
+ Notification.permission !== 'granted'
+ ) {
+ return;
+ }
+
+ if (prevLocalToken.current && !localToken) {
+ void createPushSubscription();
+ }
+
+ prevLocalToken.current = localToken;
+ }, [createPushSubscription, localToken, supported]);
+
return null;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 1:08 PM (18 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570746
Default Alt Text
D12915.diff (1 KB)
Attached To
Mode
D12915: [web][desktop] refresh device token after receiving message from Tunnelbroker
Attached
Detach File
Event Timeline
Log In to Comment