From defd9f796806069c850afdd4617049ec0d994bc1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 2 Feb 2013 23:44:52 -0500 Subject: [PATCH] fix timer init Don't keep re-initializing the timer every time the event page gets loaded otherwise we keep clearing the history every 10 minutes rather than once a day. --- javascript/clearhistory.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index 7c9596f..d05a2f6 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -119,10 +119,15 @@ chrome.browserAction.onClicked.addListener(function(tab) { runCleaner(); }); -chrome.alarms.create(CONSTANTS.CLEANER_ALARM, { - // First fire 10 minutes from now. - 'when': Date.now() + (10 * 60 * 1000), - 'periodInMinutes': 24 * 60 +chrome.alarms.get(CONSTANTS.CLEANER_ALARM, function(a) { + if (a) + return; + + chrome.alarms.create(CONSTANTS.CLEANER_ALARM, { + // First fire 10 minutes from now. + 'when': Date.now() + (10 * 60 * 1000), + 'periodInMinutes': 24 * 60 + }); }); chrome.alarms.onAlarm.addListener(function(alarm) { -- 2.39.5