Skip to content

Commit

Permalink
Fix notification bug #67
Browse files Browse the repository at this point in the history
  • Loading branch information
An Phan committed Dec 20, 2015
1 parent e536ff6 commit 6457528
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions resources/assets/js/services/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
});

window.setTimeout(() => {
notification.close();
}, 5000);
try {
var notification = new Notification(`♫ ${song.title}`, {
icon: song.album.cover,
body: `${song.album.name}${song.album.artist.name}`
});

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
}
},

/**
Expand Down

0 comments on commit 6457528

Please sign in to comment.