Skip to content

Commit

Permalink
Do not loop notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen McCann committed Mar 8, 2019
1 parent eacdaf6 commit fc1d742
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Player {
this.isPlaying = false;
this.audioProcess = null;
this.shouldPlayAgain = true;
this.showNotification = true;

this.icons = getIconsByTheme();
this.updateAvailable = false;
Expand Down Expand Up @@ -94,7 +95,8 @@ class Player {
});
}

// Process was stopped without error
// Callback - if we get here audio process finished without error
// This is the "loop", if shouldPlayAgain is true then play whatever this.track is
if (this.shouldPlayAgain) {
this.play();
}
Expand All @@ -103,7 +105,15 @@ class Player {
this.isPlaying = true;
this.shouldPlayAgain = true;
this.tray.setImage(this.icons.stopIcon);
showNotification({ title: "Now playing", body: getTrackName(this.track) });

if (this.showNotification) {
showNotification({
title: "Now playing",
body: getTrackName(this.track)
});
}

this.showNotification = false;
}

stop({ skipToNewTrack } = {}) {
Expand All @@ -120,6 +130,7 @@ class Player {
}

this.isPlaying = false;
this.showNotification = true;
this.tray.setImage(this.icons.playIcon);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { app, globalShortcut, systemPreferences, Tray } = require("electron");
const log = require("electron-log");
const isDev = require("electron-is-dev");

const Player = require("./Player");
const { checkForUpdates } = require("./updater");
Expand Down

0 comments on commit fc1d742

Please sign in to comment.