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

Fix notifications behaviour #11

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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