Skip to content

Commit ef6b90e

Browse files
committed
fix: make saved data track if the value has been changed
`opted_in` and `showExtensionInfo`, instead of storing a boolean value, now store an object consisting of a `value` and `changed` keys. `value` indicates which value the user wants for the given option, and `changed` indicates whether the value has been changed from its default value. Adding the `changed` key allows for users to have their options kept the same if the default value is changed. Signed-off-by: Lucas Sta Maria <[email protected]>
1 parent 07580a8 commit ef6b90e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/js/helpers.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,15 @@ async function saveGradesLocally (username, courses) {
223223
user_data["USERDATA_" + username] = { "courses": course_list };
224224

225225
data.user_data = user_data;
226-
data.opted_in = true;
226+
data.opted_in = {
227+
value: true,
228+
changed: false,
229+
};
230+
data.showExtensionInfo = {
231+
value: true,
232+
changed: false,
233+
};
227234
data.most_recent_user = username;
228-
data.showExtensionInfo = true;
229235

230236
browser.storage.local.set(data);
231237
}

src/js/saspowerschoolff.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async function login_page () {
122122
browser.storage.local.get("showExtensionInfo").then(output => {
123123
new (Vue.extend(ExtensionInfo))({
124124
data: {
125-
showInfo: output.showExtensionInfo,
125+
showInfo: output.showExtensionInfo.value,
126126
},
127127
}).$mount('#saspes-info');
128128
});
@@ -132,7 +132,7 @@ async function login_page () {
132132
LastGradesDiv.id = "saspes-last-grades";
133133
document.body.appendChild(LastGradesDiv);
134134

135-
if ((await browser.storage.local.get("opted_in")).opted_in) {
135+
if ((await browser.storage.local.get("opted_in")).opted_in.value) {
136136
(browser.storage.local.get("most_recent_user")).then(output => {
137137
const most_recent_user = output.most_recent_user;
138138
if (most_recent_user !== undefined) {

0 commit comments

Comments
 (0)