Fix: onAlarms is registered multiple times (#702)

This commit is contained in:
eight 2019-06-01 17:11:22 +08:00 committed by narcolepticinsomniac
parent 60693e8c3f
commit 0d6c2bdb42

View File

@ -37,6 +37,7 @@
prefs.subscribe(['updateInterval'], schedule);
schedule();
chrome.alarms.onAlarm.addListener(onAlarm);
return {checkAllStyles, checkStyle, STATES};
@ -240,10 +241,8 @@
chrome.alarms.create(ALARM_NAME, {
when: Date.now() + Math.max(MIN_INTERVAL_MS, interval - elapsed),
});
chrome.alarms.onAlarm.addListener(onAlarm);
} else {
chrome.alarms.clear(ALARM_NAME, ignoreChromeError);
chrome.alarms.onAlarm.removeListener(onAlarm);
}
}