diff --git a/frontend/apps/main/index.html b/frontend/apps/main/index.html index f4f773c6..63340480 100644 --- a/frontend/apps/main/index.html +++ b/frontend/apps/main/index.html @@ -6,7 +6,7 @@ - + diff --git a/frontend/apps/main/src/views/account/notifications/NotificationPreferences.test.js b/frontend/apps/main/src/views/account/notifications/NotificationPreferences.test.js index 80a42143..993c69d8 100644 --- a/frontend/apps/main/src/views/account/notifications/NotificationPreferences.test.js +++ b/frontend/apps/main/src/views/account/notifications/NotificationPreferences.test.js @@ -62,6 +62,7 @@ const mount = async (vapidPublicKey = 'test-key') => { data: { email_enabled: true, vapid_public_key: vapidPublicKey, + push_endpoints: ['https://push.example/subscription'], preferences: [ { notification_type: 'new_reply', channel: 'email', enabled: true }, { notification_type: 'new_reply', channel: 'in_app', enabled: false } @@ -119,10 +120,9 @@ describe('notification preferences', () => { expect(email.disabled).toBe(false) }) - it('leaves the push subscription to the app shell', async () => { + it('restores this browser push state from the saved endpoints', async () => { await mount() - expect(root.textContent).toContain('notification.type.newReply') - expect(refresh).not.toHaveBeenCalled() + expect(refresh).toHaveBeenCalledWith('test-key', ['https://push.example/subscription']) }) it('disables browser notifications when push is unavailable', async () => { diff --git a/frontend/apps/main/src/views/account/notifications/NotificationPreferences.vue b/frontend/apps/main/src/views/account/notifications/NotificationPreferences.vue index 057a2f5c..313e293d 100644 --- a/frontend/apps/main/src/views/account/notifications/NotificationPreferences.vue +++ b/frontend/apps/main/src/views/account/notifications/NotificationPreferences.vue @@ -120,6 +120,7 @@ const fetchPreferences = async () => { const { data } = await api.getNotificationPreferences() emailEnabled.value = data.data.email_enabled vapidPublicKey.value = data.data.vapid_public_key + await pushNotifications.refresh(vapidPublicKey.value, data.data.push_endpoints) const byType = {} for (const pref of data.data.preferences) { byType[pref.notification_type] ??= { type: pref.notification_type }