Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #11 from mauri870/master
Browse files Browse the repository at this point in the history
Fix notifications behaviour
  • Loading branch information
devfake authored Jul 12, 2017
2 parents 8b4052d + cc88dd1 commit 0701339
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions client/app/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,28 @@ let notification = new Vue({

methods: {
songPlayed () {
this.notify(
`♫ ${this.currentTrack.title}`,
`By: ${this.currentTrack.username} on ${this.currentTrack.genre}`
);
let vm = this;
let oldTrackTitle = vm.currentTrack.title;
setTimeout(function () {
if (vm.$store.state.player.currentTrack.title === oldTrackTitle) {
vm.notify(
`♫ ${vm.currentTrack.title}`,
`By: ${vm.currentTrack.username} on ${vm.currentTrack.genre}`
);
}
}, 5000);
},

notify(title, body, silent = true, icon = '../assets/img/icon.png') {
Notification.requestPermission();
let n = new Notification(
return new Notification(
title,
{
icon,
body,
silent
}
);

setTimeout(n.close.bind(n), 5000);
}
}
});
Expand Down

0 comments on commit 0701339

Please sign in to comment.