Skip to content

Commit 0ab9a48

Browse files
committed
fix(settings): update state handling for settings to prevent default settings from overwriting user settings (#619)
1 parent ff3af2a commit 0ab9a48

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

src/options/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
v-model.number="settings.config.reloadIPStartupDelay"
183183
type="number"
184184
min="0"
185+
autocomplete="off"
185186
class="block form-input"
186187
/>
187188
</div>

src/popup/App.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
name="profile.interval.min"
163163
type="number"
164164
min="1"
165+
autocomplete="off"
165166
class="block w-full form-input text-mini"
166167
/>
167168
</div>
@@ -175,6 +176,7 @@
175176
name="profile.interval.max"
176177
type="number"
177178
min="1"
179+
autocomplete="off"
178180
class="block w-full form-input text-mini"
179181
/>
180182
</div>
@@ -327,6 +329,7 @@
327329
v-model="tmp.rangeFrom"
328330
name="headers.spoofIP.rangeFrom"
329331
class="block w-full form-input text-mini"
332+
autocomplete="off"
330333
:class="{ error: errors.rangeFrom }"
331334
/>
332335
</div>
@@ -338,6 +341,7 @@
338341
v-model="tmp.rangeTo"
339342
name="headers.spoofIP.rangeTo"
340343
class="block w-full form-input text-mini"
344+
autocomplete="off"
341345
:class="{ error: errors.rangeTo }"
342346
/>
343347
</div>
@@ -491,6 +495,7 @@
491495
@input="changeSetting($event)"
492496
name="options.protectKBFingerprint.delay"
493497
:value="settings.options.protectKBFingerprint.delay"
498+
autocomplete="off"
494499
type="number"
495500
min="1"
496501
max="1000"
@@ -1005,6 +1010,12 @@ export default class App extends Vue {
10051010
function(request: any): void {
10061011
if (request.action === 'tempStore') {
10071012
Vue.set(this.tmp, 'store', request.data);
1013+
} else if (request.action === 'updateIPRules') {
1014+
this['$store'].dispatch('syncSettings', { ipRules: request.data });
1015+
} else if (request.action === 'updateWhitelist') {
1016+
this['$store'].dispatch('syncSettings', { whitelist: request.data });
1017+
} else if (request.action === 'save') {
1018+
this['$store'].dispatch('syncSettings', request.data);
10081019
}
10091020
}.bind(this)
10101021
);

src/store/actions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ export const initialize = async ({ commit }) => {
110110
commit(mtypes.INITIALIZE, settings);
111111
};
112112

113+
export const syncSettings = ({ commit }, payload) => {
114+
commit(mtypes.SYNC, payload);
115+
};
116+
113117
export const toggleChameleon = ({ commit }, payload) => {
114118
commit(mtypes.TOGGLE_CHAMELEON, payload);
115119
webext.enableChameleon(payload);

src/store/mutation-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export const INITIALIZE: string = 'INITIALIZE';
44
export const TOGGLE_CHAMELEON: string = 'TOGGLE_CHAMELEON';
55
export const TOGGLE_NOTIFICATIONS: string = 'TOGGLE_NOTIFICATIONS';
66
export const TOGGLE_THEME: string = 'TOGGLE_THEME';
7+
export const SYNC: string = 'SYNC';
78
export const UPDATE_EXCLUSIONS: string = 'UPDATE_EXCLUSIONS';

src/store/mutations.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export default {
3131
[mtypes.TOGGLE_THEME](state, payload) {
3232
state.config.theme = state.config.theme == 'light' ? 'dark' : 'light';
3333
},
34+
[mtypes.SYNC](state, payload) {
35+
stateMerge(state, payload);
36+
},
3437
[mtypes.UPDATE_EXCLUSIONS](state, payload) {
3538
state.excluded = payload;
3639
},

0 commit comments

Comments
 (0)