Skip to content

Commit e301aa2

Browse files
committed
chore: work on notif icons
1 parent 9fd9bb0 commit e301aa2

File tree

10 files changed

+194
-15
lines changed

10 files changed

+194
-15
lines changed

api/config/custom-environment-variables.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = {
3131
port: 'OBSERVER_PORT'
3232
},
3333
theme: {
34-
logo: 'THEME_LOGO',
3534
notificationIcon: 'THEME_NOTIFICATION_ICON',
3635
notificationBadge: 'THEME_NOTIFICATION_BADGE'
3736
},

api/config/default.cjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ module.exports = {
2929
loopInterval: 4000
3030
},
3131
theme: {
32-
logo: null,
33-
notificationIcon: null,
34-
notificationBadge: null
32+
// notificationIcon: '',
33+
// notificationBadge: ''
3534
},
3635
i18n: {
3736
locales: ['fr', 'en'],

api/config/type/schema.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,12 @@
111111
"theme": {
112112
"type": "object",
113113
"additionalProperties": false,
114-
"required": ["logo", "notificationIcon", "notificationBadge"],
115114
"properties": {
116-
"logo": {
117-
"type": ["string", "null"]
118-
},
119115
"notificationIcon": {
120-
"type": ["string", "null"]
116+
"type": "string"
121117
},
122118
"notificationBadge": {
123-
"type": ["string", "null"]
119+
"type": "string"
124120
}
125121
}
126122
},

api/src/notifications/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const prepareSubscriptionNotification = (event: FullEvent, subscription:
2424
delete localizedEvent.originator
2525
delete localizedEvent.urlParams
2626
const notification: Notification = {
27-
icon: subscription.icon || config.theme.notificationIcon || config.theme.logo || (subscription.origin + '/events/logo-192x192.png'),
27+
icon: subscription.icon || config.theme.notificationIcon || (subscription.origin + '/events/logo-192x192.png'),
2828
locale: subscription.locale,
2929
...localizedEvent,
3030
_id: nanoid(),

api/src/push/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ router.post('/registrations', async (req, res) => {
9090
title: 'Un nouvel appareil recevra vos notifications',
9191
body: `L'appareil ${newRegistration.deviceName} est confirmé comme destinataire de vos notifications.`,
9292
date,
93-
icon: config.theme.notificationIcon || config.theme.logo || (origin + '/events/logo-192x192.png')
93+
icon: config.theme.notificationIcon || (origin + '/events/logo-192x192.png')
9494
}, newRegistration)
9595
if (error) return res.status(500).send(error)
9696
sub.registrations.push(newRegistration)
@@ -118,7 +118,7 @@ router.post('/registrations/:i/_test', async (req, res) => {
118118
recipient: { id: user.id, name: user.name },
119119
title: 'Cet appareil est correctement configuré pour recevoir vos notifications',
120120
date: new Date().toISOString(),
121-
icon: config.theme.notificationIcon || config.theme.logo || (origin + '/events/logo-192x192.png')
121+
icon: config.theme.notificationIcon || (origin + '/events/logo-192x192.png')
122122
}, i)
123123
res.send({ error: errors[0] })
124124
})

ui/public/badge-72x72.png

3.26 KB
Loading

ui/public/badge.svg

Lines changed: 96 additions & 0 deletions
Loading

ui/public/logo-192x192.png

5.01 KB
Loading

ui/public/logo.svg

Lines changed: 90 additions & 0 deletions
Loading

ui/public/push-sw.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ self.addEventListener('push', function (event) {
1515
event.waitUntil(
1616
self.registration.showNotification(data.title, {
1717
body: data.body,
18-
// temporarily comment sending icon as I can't make it work with CSP rules for some unknown reason
19-
// icon: data.icon,
18+
icon: data.icon,
2019
// badge: data.badge,
2120
timestamp: new Date(data.date).getTime(),
2221
vibrate: [300, 100, 400],

0 commit comments

Comments
 (0)