Skip to content

Commit c5461b4

Browse files
committed
Don't try and render null avatars in desktop notifications
as much fun as http://localhost:8080/null is to see
1 parent 98f2d86 commit c5461b4

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

‎src/vector/platform/ElectronPlatform.js‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,12 @@ export default class ElectronPlatform extends VectorBasePlatform {
141141
}
142142

143143
// Notifications in Electron use the HTML5 notification API
144-
const notification = new global.Notification(
145-
title,
146-
{
147-
body: msg,
148-
icon: avatarUrl,
149-
silent: true, // we play our own sounds
150-
},
151-
);
144+
const notifBody = {
145+
body: msg,
146+
silent: true, // we play our own sounds
147+
};
148+
if (avatarUrl) notifBody['icon'] = avatarUrl;
149+
const notification = new global.Notification(title, notifBody);
152150

153151
notification.onclick = () => {
154152
dis.dispatch({

‎src/vector/platform/WebPlatform.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ export default class WebPlatform extends VectorBasePlatform {
7676
}
7777

7878
displayNotification(title: string, msg: string, avatarUrl: string, room: Object) {
79-
const notification = new global.Notification(
80-
title,
81-
{
82-
body: msg,
83-
icon: avatarUrl,
84-
tag: "vector",
85-
silent: true, // we play our own sounds
86-
},
87-
);
79+
const notifBody = {
80+
body: msg,
81+
tag: "vector",
82+
silent: true, // we play our own sounds
83+
};
84+
if (avatarUrl) notifBody['icon'] = avatarUrl;
85+
const notification = new global.Notification(title, notifBody);
8886

8987
notification.onclick = function() {
9088
dis.dispatch({

0 commit comments

Comments
 (0)