Skip to content

Commit d135516

Browse files
committed
Add default settings to storage after crash with update
1 parent e0bf8af commit d135516

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</div>
6464
</div>
6565
<div id='aboutBlock' hidden>
66-
<div><label id='version'>v0.6.6</label></div>
66+
<div><label id='version'>v0.7.0</label></div>
6767
<div class="margin-top-20">
6868
<label>If experiencing problems, having questions or suggestions, please fill out <a href="https://chrome.google.com/webstore/detail/web-activity-time-tracker/hhfnghjdeddcfegfekjeihfmbjenlomm/support" target="_blank">support
6969
form</a>.</label>

scripts/background.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ function setDefaultSettings() {
6868
storage.saveSettings(SETTINGS_INTERVAL_SAVE_STORAGE, SETTINGS_INTERVAL_SAVE_STORAGE_DEFAULT);
6969
}
7070

71+
function checkSettingsImEmpty() {
72+
chrome.storage.local.getBytesInUse(['inactivity_interval'], function (item) {
73+
if (item == 0){
74+
setDefaultSettings();
75+
}
76+
});
77+
}
78+
7179
function addListener() {
7280
chrome.tabs.onActivated.addListener(function (info) {
7381
chrome.tabs.get(info.tabId, function (tab) {
@@ -81,17 +89,19 @@ function addListener() {
8189
});
8290
});
8391
chrome.runtime.onInstalled.addListener(function (details) {
84-
if (details.reason == "install") {
92+
if (details.reason == 'install') {
8593
setDefaultSettings();
8694
}
95+
if (details.reason == 'update') {
96+
checkSettingsImEmpty();
97+
}
8798
});
8899
}
89100

90101
function loadTabs() {
91-
storage.loadTabs(STORAGE_TABS, function (items)
92-
{
102+
storage.loadTabs(STORAGE_TABS, function (items) {
93103
tabs = [];
94-
for (var i=0; i<items.length; i++){
104+
for (var i = 0; i < items.length; i++) {
95105
tabs.push(new Tab(items[i].url, items[i].favicon, items[i].days, items[i].summaryTime));
96106
}
97107
});

style/chart.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,4 @@ tspan{
3636
.percentageValue{
3737
font-size: 1.8em !important;
3838
font-weight: 600 !important;
39-
}
40-
41-
.backColorChart{
42-
/* background-color: rgb(227, 245, 243); */
4339
}

0 commit comments

Comments
 (0)