Skip to content

Commit

Permalink
Implemented Default Button Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ke-d committed Feb 1, 2017
1 parent 9df31b4 commit 0661b39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
18 changes: 6 additions & 12 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ function showVisitsInBadge(tabURL,tabID) {

//Sets up the background page on startup
function onStartUp() {
//Holds the promises that must be fulfilled before a promise is returned
let promiseContainer = [];
browser.storage.local.get()
.then(function(items) {
//Checks to see if these settings are in storage, if not create and set the default
Expand All @@ -150,7 +148,7 @@ function onStartUp() {
urlsToRemove = new Set(items.URLS);
}
if(items.daysToKeep === undefined) {
promiseContainer.push(browser.storage.local.set({daysToKeep: 60}));
browser.storage.local.set({daysToKeep: 60});
}

if(items.historyDeletedCounterTotal === undefined) {
Expand All @@ -160,15 +158,15 @@ function onStartUp() {
}

if(items.keepHistorySetting === undefined) {
promiseContainer.push(browser.storage.local.set({keepHistorySetting: false}));
browser.storage.local.set({keepHistorySetting: false});
}

if(items.statLoggingSetting === undefined) {
promiseContainer.push(browser.storage.local.set({statLoggingSetting: true}));
browser.storage.local.set({statLoggingSetting: true});
}

if(items.showVisitsInIconSetting === undefined) {
promiseContainer.push(browser.storage.local.set({showVisitsInIconSetting: true}));
browser.storage.local.set({showVisitsInIconSetting: true});
}

//Create objects based on settings
Expand All @@ -185,19 +183,15 @@ function onStartUp() {
browser.history.onVisitRemoved.removeListener(incrementCounter);
}
}).catch(onError);
return Promise.all(promiseContainer);
}


//Set the defaults
function setDefaults() {
let p1;
let p2 = browser.storage.local.clear()
browser.storage.local.clear()
.then(function() {
p1 = onStartUp();
onStartUp();
});
//Returns a promise once p1 and p2 is done
return Promise.all([p1, p2]);

}

Expand Down
1 change: 0 additions & 1 deletion settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ <h2>Release Notes</h2>
<ul>
<li>Added Default Settings button in Settings</li>
<li>New custom icon and color theme!</li>
<li>Stablity Fixes</li>
</ul>
<span>0.9.0</span>
<ul>
Expand Down
9 changes: 6 additions & 3 deletions settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ document.getElementById("cancelSettings").addEventListener("click", function() {

document.getElementById("defaultSettings").addEventListener("click", function() {
page.setDefaults()
.then(function() {
setTimeout(function() {
restoreSettingValues();
generateTableOfURLS();
toggleAlert(document.getElementById("defaultConfirm"));
});
}, 500);




});

Expand Down Expand Up @@ -161,7 +164,7 @@ function downloadTextFile(arr) {
var hiddenElement = document.createElement("a");
hiddenElement.href = "data:text/plain;charset=utf-8," + encodeURIComponent(txt);
hiddenElement.target = "_target";
hiddenElement.download = "icon_AutoDelete_URLS.txt";
hiddenElement.download = "History_AutoDelete_URLS.txt";

//Firefox just opens the text rather than downloading it. In Chrome the "else" block of code works.
//So this is a work around.
Expand Down

0 comments on commit 0661b39

Please sign in to comment.