Skip to content

Commit

Permalink
Update v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
easonwong-de committed Aug 28, 2023
1 parent 86564fd commit 585f559
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ const update_debounce = addDebounce(update);

var updateToggle = true;
var updateInterval = setInterval(update, 2500);
browser.runtime.onMessage.addListener(controller);
browser.runtime.onMessageExternal.addListener(controller);
browser.runtime.onMessage.addListener(onMessage);
browser.runtime.onMessageExternal.addListener(onMessage);

function controller(message) {
function onMessage(message) {
switch (message) {
case "TPOH_ON":
clearInterval(updateInterval);
updateToggle = true;
setTimeout(update_debounce, 100);
update_debounce();
updateInterval = setInterval(update, 2500);
break;
case "TPOH_OFF":
clearInterval(updateInterval);
updateToggle = false;
break;
case "TPOH_UPDATE":
if (updateToggle) setTimeout(update_debounce, 100);
/* if (updateToggle) update_debounce(); */
break;
default:
break;
Expand Down

0 comments on commit 585f559

Please sign in to comment.