VernissageApp / VernissageWeb

Application which is Web component for Vernissage photos sharing platform.
https://vernissage.photos
Apache License 2.0
8 stars 0 forks source link

"Save" button in notification settings modal not working on desktop Safari #118

Open mgrzeca opened 4 days ago

mgrzeca commented 4 days ago

In the notification view, there's a settings button that opens a modal. The "Save" button inside the modal doesn’t work in the desktop version of Safari (though it works fine on iOS). I’ve tested this on both my instance and the official vernissage.photos instance, and the issue is the same on both.

The button gives visual feedback when clicked, but nothing happens, and the notification settings are not saved.

mgrzeca commented 4 days ago

I’ve checked the browser's JavaScript console, and there are no errors or messages displayed when the "Save" button is clicked.

mczachurski commented 4 days ago

I cannot reproduce that issue. Check please if you have "Service worker" enabled in Safari:

Screenshot 2024-10-06 at 16 31 51

Verify also if in the Safari console you switched to see all console messages:

Screenshot 2024-10-06 at 16 39 43

Theoretically, you should not see the "Settings" button when the "Service worker" is disabled, but I don't have any other ideas.

mgrzeca commented 3 days ago

Yes, I have service workers enabled, and the JavaScript console in Safari 18.0 is set to display all messages by default. I’ve also tried disabling Safari’s built-in content blockers and tested with AdGuard turned off, but the issue persists.

Let me know if there’s anything else I should check!

mczachurski commented 3 days ago

I will add more messages during the process of saving notifications in the new version of the application, which might help us identify the issue. I’ll let you know once it’s done.

mczachurski commented 3 days ago

Can you verify what error message do you have now?

And can you verify also what do you have in the Notifications tab in the Safari:

Screenshot 2024-10-07 at 11 06 51
mgrzeca commented 3 days ago
Zrzut ekranu 2024-10-7 o 11 28 31
mgrzeca commented 3 days ago

but for some reason, it works on iOS, and notifications are also working correctly for me on iPhone

mgrzeca commented 3 days ago

I’m getting exactly the same message on the official instance.

mczachurski commented 2 days ago

The code which is responsible for notification subscription looks like that:

const subscription = await this.swPushService.requestSubscription({
    serverPublicKey: this.settingsService.publicSettings.webPushVapidPublicKey
});

const jsonObject = subscription.toJSON();
this.endpoint = jsonObject.endpoint;
this.p256dh = jsonObject.keys?.p256dh;
this.auth = jsonObject.keys?.auth;

if (!this.endpoint || !this.p256dh || !this.auth) {
    this.messageService.showError('Error during generating encryption keys for Web push.');
    return;
}

Basically we have three steps here:

  1. requestSubscription - after that operation you should have question from browser about notification approval,
  2. subscription.toJSON() - then we have to ask for browser generated public keys,
  3. !this.endpoint || !this.p256dh || !this.auth - check if everything has been retrieved from browser,

Seems like the first step is failing somehow (not returning correct PushSubscription object). But for now I don’t know why.