Skip to content

Commit

Permalink
[BugFix] Extension doesn't deactivate itself when the browser is laun…
Browse files Browse the repository at this point in the history
…ched again
  • Loading branch information
Adrien Coppola authored and Adrien Coppola committed Sep 8, 2016
1 parent 49ff26c commit 310962b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ along with Focus Mode. If not, see <http://www.gnu.org/licenses/>.
/* Attach event callback */
chrome.webNavigation.onCommitted.addListener(analyzeUrl);

/* Set the number of blocked attempts*/
storage.local.set({"blocked": 0});

/* deactivated by default */
storage.local.set({"on": false});
storage.local.get("on", function(item){
if(item.on === undefined){
/* deactivated by default & set the number of blocked attempts*/
storage.local.set({"on": false, "blocked": 0});
}
});

/* Load on start */
loadWebsites();
Expand Down
5 changes: 3 additions & 2 deletions js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ along with Focus Mode. If not, see <http://www.gnu.org/licenses/>.

/* Activate or Deactivate the work mode */
function onButtonClick(){
storage.local.get("on", function(item){
storage.local.get(["on", "blocked"], function(item){
console.log(item.on);
var on;

if(item.on === undefined || item.on === false){
Expand All @@ -58,7 +59,7 @@ along with Focus Mode. If not, see <http://www.gnu.org/licenses/>.
on = false;
}

storage.local.set({"on": on});
storage.local.set({"on": on, "blocked": 0});

updateOnButton();
updateIcon();
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name" :"Focus Mode",
"version" :"1.0",
"version" :"1.1",
"description" :"A mode to keep you focused at work !",
"icons": { "128": "images/icon128-2.png" },
"browser_action" : {
Expand Down

0 comments on commit 310962b

Please sign in to comment.