Skip to content

Commit

Permalink
[feature] Add Clear data on browser start option
Browse files Browse the repository at this point in the history
  • Loading branch information
neuralstring committed Sep 12, 2023
1 parent d9ace78 commit 99308e4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/assets/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@
"description": "Value of the option."
},

"optionTitle_clearOnBrowserStart": {
"message": "Clear data on browser start",
"description": "Title of the option."
},

"optionTitle_notifyOnSuccess": {
"message": "Show notification on success",
"description": "Title of the option."
Expand Down
10 changes: 10 additions & 0 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ async function clearDataType(dataType, options = null, enDataTypes = null) {
}

const dataTypes = {};
// All *SELECTED* DataTypes
if (dataType === 'allDataTypes') {
// if enDataTypes is null
if (!enDataTypes) {
enDataTypes = await getEnabledDataTypes(options);
}
Expand Down Expand Up @@ -327,6 +329,13 @@ function addMessageListener() {
browser.runtime.onMessage.addListener(onMessage);
}

async function startup() {
const options = await storage.get(optionKeys);
if (options.clearOnBrowserStart) {
await clearDataType('allDataTypes');
}
}

async function setupUI() {
await queue.add(setBrowserAction);
}
Expand All @@ -337,6 +346,7 @@ async function setup() {
await initStorage();
}

await startup();
await setupUI();
}

Expand Down
7 changes: 7 additions & 0 deletions src/options/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
>
</vn-select>
</div>
<div class="option">
<vn-switch
:label="getText('optionTitle_clearOnBrowserStart')"
v-model="options.clearOnBrowserStart"
></vn-switch>
</div>
<div class="option">
<vn-switch
:label="getText('optionTitle_notifyOnSuccess')"
Expand Down Expand Up @@ -214,6 +220,7 @@ export default {
closeTabs: '',
closePinnedTabs: false,
reloadTabs: '',
clearOnBrowserStart: false,
notifyOnSuccess: false,
showDataTypeIcons: false,
confirmDataRemoval: false,
Expand Down
1 change: 1 addition & 0 deletions src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const optionKeys = [
'closeTabs',
'closePinnedTabs',
'reloadTabs',
'clearOnBrowserStart',
'notifyOnSuccess',
'showDataTypeIcons',
'confirmDataRemoval',
Expand Down

0 comments on commit 99308e4

Please sign in to comment.