mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-10-26 06:19:36 +00:00
fix browser notification persistence
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content" />
|
||||
<meta name="theme-color" content="hsl(152 39% 30%)" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials" />
|
||||
<link rel="apple-touch-icon" href="/images/pwa-icon-192.png" />
|
||||
<link rel="preload" href="/static/public/static/fonts/Geist-Variable.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="/static/public/static/fonts.css">
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user