Fix notification bug #67

This commit is contained in:
An Phan 2015-12-20 10:07:39 +08:00
parent e536ff6d35
commit 6457528990

View file

@ -94,14 +94,20 @@ export default {
return;
}
var notification = new Notification(`${song.title}`, {
icon: song.album.cover,
body: `${song.album.name} ${song.album.artist.name}`
});
try {
var notification = new Notification(`${song.title}`, {
icon: song.album.cover,
body: `${song.album.name} ${song.album.artist.name}`
});
window.setTimeout(() => {
notification.close();
}, 5000);
notification.onclick = () => window.focus();
// Close the notif after 5 secs.
window.setTimeout(() => notification.close(), 5000);
} catch (e) {
// Notification fails.
// @link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification
}
},
/**