From cc88dd1678e8e91c547ffc15d4e7f025f9eddab6 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Nunes Date: Mon, 18 Jul 2016 10:21:59 -0300 Subject: [PATCH] Update notification behaviour for open one per music after 5s --- client/app/notification.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/app/notification.js b/client/app/notification.js index 60fcd8b..2f2a088 100644 --- a/client/app/notification.js +++ b/client/app/notification.js @@ -13,15 +13,21 @@ 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, @@ -29,8 +35,6 @@ let notification = new Vue({ silent } ); - - setTimeout(n.close.bind(n), 5000); } } });