Skip to content

Commit 619c6a9

Browse files
committed
Added optional chaining to initDefaultVal() in settings.load() for easier cross-maintenance
1 parent f21b9aa commit 619c6a9

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

chatgpt-auto-continue/chromium/extension/lib/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ window.settings = {
5656
return Promise.all(keys.map(async key => // resolve promise when all keys load
5757
config[key] = (await chrome.storage.local.get(key))[key] ?? initDefaultVal(key)))
5858
function initDefaultVal(key) {
59-
return this.controls[key]?.defaultVal
60-
?? this.controls[key]?.type == 'slider' ? 100
61-
: this.controls[key]?.type == 'toggle'
59+
return this.controls?.[key]?.defaultVal
60+
?? this.controls?.[key]?.type == 'slider' ? 100
61+
: this.controls?.[key]?.type == 'toggle'
6262
}
6363
},
6464

chatgpt-auto-continue/firefox/extension/lib/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ window.settings = {
5656
return Promise.all(keys.map(async key => // resolve promise when all keys load
5757
config[key] = (await chrome.storage.local.get(key))[key] ?? initDefaultVal(key)))
5858
function initDefaultVal(key) {
59-
return this.controls[key]?.defaultVal
60-
?? this.controls[key]?.type == 'slider' ? 100
61-
: this.controls[key]?.type == 'toggle'
59+
return this.controls?.[key]?.defaultVal
60+
?? this.controls?.[key]?.type == 'slider' ? 100
61+
: this.controls?.[key]?.type == 'toggle'
6262
}
6363
},
6464

chatgpt-infinity/chromium/extension/lib/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ window.settings = {
8585
return Promise.all(keys.map(async key => // resolve promise when all keys load
8686
config[key] = (await chrome.storage.local.get(key))[key] ?? initDefaultVal(key)))
8787
function initDefaultVal(key) {
88-
return this.controls[key]?.defaultVal
89-
?? this.controls[key]?.type == 'slider' ? 100
90-
: this.controls[key]?.type == 'toggle'
88+
return this.controls?.[key]?.defaultVal
89+
?? this.controls?.[key]?.type == 'slider' ? 100
90+
: this.controls?.[key]?.type == 'toggle'
9191
}
9292
},
9393

chatgpt-infinity/firefox/extension/lib/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ window.settings = {
8585
return Promise.all(keys.map(async key => // resolve promise when all keys load
8686
config[key] = (await chrome.storage.local.get(key))[key] ?? initDefaultVal(key)))
8787
function initDefaultVal(key) {
88-
return this.controls[key]?.defaultVal
89-
?? this.controls[key]?.type == 'slider' ? 100
90-
: this.controls[key]?.type == 'toggle'
88+
return this.controls?.[key]?.defaultVal
89+
?? this.controls?.[key]?.type == 'slider' ? 100
90+
: this.controls?.[key]?.type == 'toggle'
9191
}
9292
},
9393

chatgpt-widescreen/chromium/extension/lib/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ window.settings = {
142142
config[key] = result[`${env.site}_${key}`] ?? result[key] ?? initDefaultVal(key)
143143
}))
144144
function initDefaultVal(key) {
145-
return this.controls[key]?.defaultVal
146-
?? this.controls[key]?.type == 'slider' ? 100
147-
: this.controls[key]?.type == 'toggle'
145+
return this.controls?.[key]?.defaultVal
146+
?? this.controls?.[key]?.type == 'slider' ? 100
147+
: this.controls?.[key]?.type == 'toggle'
148148
}
149149
},
150150

chatgpt-widescreen/firefox/extension/lib/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ window.settings = {
142142
config[key] = result[`${env.site}_${key}`] ?? result[key] ?? initDefaultVal(key)
143143
}))
144144
function initDefaultVal(key) {
145-
return this.controls[key]?.defaultVal
146-
?? this.controls[key]?.type == 'slider' ? 100
147-
: this.controls[key]?.type == 'toggle'
145+
return this.controls?.[key]?.defaultVal
146+
?? this.controls?.[key]?.type == 'slider' ? 100
147+
: this.controls?.[key]?.type == 'toggle'
148148
}
149149
},
150150

0 commit comments

Comments
 (0)