Simplify save settings

This commit is contained in:
the-djmaze 2022-03-01 10:18:12 +01:00
parent fc60dc94fc
commit f4d98130a5
12 changed files with 66 additions and 162 deletions

View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { SettingsGet } from 'Common/Globals';
import { defaultOptionsAfterRender } from 'Common/Utils';
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
import { addObservablesTo } from 'External/ko';
import Remote from 'Remote/Admin/Fetch';
import { decorateKoCommands } from 'Knoin/Knoin';
@ -22,10 +22,9 @@ export class ContactsAdminSettings extends AbstractViewSettings {
this.testContactsErrorMessage('');
});
addObservablesTo(this, {
enableContacts: !!SettingsGet('ContactsEnable'),
contactsSync: !!SettingsGet('ContactsSync'),
this.addSettings(['ContactsEnable','ContactsSync']);
addObservablesTo(this, {
testing: false,
testContactsSuccess: false,
testContactsError: false,
@ -65,18 +64,6 @@ export class ContactsAdminSettings extends AbstractViewSettings {
})
.extend({ notify: 'always' });
addSubscribablesTo(this, {
enableContacts: value =>
Remote.saveConfig({
ContactsEnable: value ? 1 : 0
}),
contactsSync: value =>
Remote.saveConfig({
ContactsSync: value ? 1 : 0
})
})
decorateKoCommands(this, {
testContactsCommand: self => self.contactsPdoDsn() && self.contactsPdoUser()
});