Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix Space notifications on Firefox Android

Anand Baburajane8cd856ed702
diff --git a/web/apps/space/src/services/spaceWebPush.ts b/web/apps/space/src/services/spaceWebPush.ts
index 7f58d6f02f..548afbd4cb 100644
--- a/web/apps/space/src/services/spaceWebPush.ts
+++ b/web/apps/space/src/services/spaceWebPush.ts
@@ -221,8 +221,8 @@ const subscriptionDetails = (
return { endpoint: serialized.endpoint, p256dh, auth };
};
-const sameBytes = (left: ArrayBuffer | null, right: ArrayBuffer) => {
- if (left?.byteLength != right.byteLength) return false;
+const sameBytes = (left: ArrayBuffer, right: ArrayBuffer) => {
+ if (left.byteLength != right.byteLength) return false;
const leftBytes = new Uint8Array(left);
const rightBytes = new Uint8Array(right);
return leftBytes.every((value, index) => value == rightBytes[index]);
@@ -231,12 +231,13 @@ const sameBytes = (left: ArrayBuffer | null, right: ArrayBuffer) => {
const currentSubscription = async (prepared: PreparedSpaceWebPush) => {
const subscription =
await prepared.registration.pushManager.getSubscription();
+ // Firefox Android omits this key when restoring a valid subscription.
+ const applicationServerKey =
+ subscription?.options.applicationServerKey ?? null;
if (
!subscription ||
- sameBytes(
- subscription.options.applicationServerKey,
- base64URLKey(prepared.publicKey),
- )
+ !applicationServerKey ||
+ sameBytes(applicationServerKey, base64URLKey(prepared.publicKey))
) {
return subscription;
}