Skip to content

Commit d1ea073

Browse files
author
Suhas Hariharan
committed
fixed optins page
Signed-off-by: Suhas Hariharan <[email protected]>
1 parent d5ebec5 commit d1ea073

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/js/views/Options.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ import browser from 'webextension-polyfill';
4545
function defaultOptions () {
4646
return {
4747
id: "Not set yet",
48+
ignoreNextReset: false,
4849
percent_main_page: true,
49-
save_last_grades: true,
50+
save_last_grades: false,
5051
};
5152
}
5253
@@ -55,7 +56,6 @@ export default {
5556
data () {
5657
return {
5758
options: defaultOptions(),
58-
ignoreNextReset: false,
5959
copiedRecently: false,
6060
thirdPartyLibraries: browser.extension.getURL('web_accessible_resources/libraries.txt'),
6161
version: SASPES_VERSION_NAME,
@@ -64,12 +64,12 @@ export default {
6464
watch: {
6565
options: {
6666
deep: true,
67-
handler (val) {
67+
async handler (val) {
6868
if (this.ignoreNextReset) {
6969
this.ignoreNextReset = false;
7070
return;
7171
}
72-
browser.storage.local.set(JSON.parse(JSON.stringify(val)));
72+
await browser.storage.local.set({ "percent_main_page": { changed: true, value: val.percent_main_page }, "opted_in": { changed: true, value: val.save_last_grades } });
7373
},
7474
},
7575
},
@@ -79,14 +79,9 @@ export default {
7979
},
8080
methods: {
8181
async resetData () {
82-
const options = await browser.storage.local.get(defaultOptions());
82+
const stored_options = await browser.storage.local.get(null);
8383
this.ignoreNextReset = true;
84-
this.options = Object.assign({}, this.options, options);
85-
},
86-
copyId () {
87-
this.copiedRecently = true;
88-
navigator.clipboard.writeText(this.options.id);
89-
setTimeout(() => { this.copiedRecently = false; }, 1500);
84+
this.options = { "percent_main_page": stored_options?.percent_main_page?.value || this.options.percent_main_page, "save_last_grades": stored_options?.opted_in?.value || this.options.save_last_grades };
9085
},
9186
},
9287
};

0 commit comments

Comments
 (0)