Skip to content

Commit

Permalink
Allow notification sound to be played once for every check instead of…
Browse files Browse the repository at this point in the history
… once per 30 seconds.

Notification checks down to 30sec.
  • Loading branch information
FMaz008 committed May 8, 2024
1 parent 78ee85e commit 54a3c14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions page/notifications.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var lastSoundPlayedAt = 0; //Date.now();
var muteSound = false;
var appSettings = [];
if (typeof browser === "undefined") {
var browser = chrome;
Expand Down Expand Up @@ -60,6 +60,7 @@ window.onload = function () {
addItem(data);
}
if (data.type == "newItemCheck") {
muteSound = false;
//Display a notification that we have checked for items.
let note = new ScreenNotification();
note.template = "view/notification_loading.html";
Expand Down Expand Up @@ -228,9 +229,9 @@ function formatDate(date) {

function playSoundIfEnabled() {
if (appSettings.general.newItemMonitorNotificationSound) {
if (Date.now() - lastSoundPlayedAt > 30000) {
if (!muteSound) {
// Don't play the notification sound again within 30 sec.
lastSoundPlayedAt = Date.now();
muteSound = true;
const audioElement = new Audio(browser.runtime.getURL("resource/sound/notification.mp3"));
audioElement.addEventListener("ended", function () {
// Remove the audio element from the DOM
Expand Down
2 changes: 1 addition & 1 deletion scripts/vh_service_worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const DEBUG_MODE = false;
var appSettings = [];
var vineCountry = null;
var newItemCheckInterval = 45;
var newItemCheckInterval = 30;
const broadcastChannel = new BroadcastChannel("VineHelperChannel");

if (typeof browser === "undefined") {
Expand Down

0 comments on commit 54a3c14

Please sign in to comment.