Skip to content

Commit f015d2e

Browse files
committed
refactor(settings-service): move the default proxy settings to a separate method
1 parent 2691364 commit f015d2e

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/app/services/settings.service.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,23 @@ export class SettingsService {
7171
this.set({ ...defaults, ...settings }); // any existing settings value will override defaults
7272
}
7373

74+
private getDefaultProxySettings() {
75+
return this.browser.isWebExtension
76+
? {
77+
enabled: false,
78+
name: '',
79+
shouldFetchImages: false,
80+
}
81+
: {
82+
enabled: true,
83+
name: CORSProxies[0].name,
84+
shouldFetchImages: false,
85+
};
86+
}
87+
7488
getDefaults() {
7589
return {
76-
proxy: this.browser.isWebExtension
77-
? {
78-
enabled: false,
79-
name: '',
80-
}
81-
: {
82-
enabled: true,
83-
name: CORSProxies[0].name,
84-
shouldFetchImages: false,
85-
},
90+
proxy: this.getDefaultProxySettings(),
8691
openInNewTab:
8792
!this.browser.isWebExtension || this.browser.isFirefox ? true : false,
8893
openLinksInInactiveTabs: true,
@@ -103,7 +108,7 @@ export class SettingsService {
103108
private set(settings: Settings) {
104109
// NOTE: the below proxy type check ensures backward compatibility
105110
this.proxy = isString(settings.proxy)
106-
? this.getDefaults().proxy
111+
? this.getDefaultProxySettings()
107112
: settings.proxy;
108113
this.openInNewTab = settings.openInNewTab;
109114
this.openLinksInInactiveTabs = settings.openLinksInInactiveTabs;

0 commit comments

Comments
 (0)