mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-14 19:54:43 +08:00
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import ko from 'ko';
|
|
import { koComputable } from 'External/ko';
|
|
|
|
import { SettingsGet } from 'Common/Globals';
|
|
import { ContactUserStore } from 'Stores/User/Contact';
|
|
import Remote from 'Remote/User/Fetch';
|
|
|
|
export class ContactsUserSettings /*extends AbstractViewSettings*/ {
|
|
constructor() {
|
|
this.contactsAutosave = ko.observable(!!SettingsGet('ContactsAutosave'));
|
|
|
|
this.allowContactsSync = ContactUserStore.allowSync;
|
|
this.enableContactsSync = ContactUserStore.enableSync;
|
|
this.contactsSyncUrl = ContactUserStore.syncUrl;
|
|
this.contactsSyncUser = ContactUserStore.syncUser;
|
|
this.contactsSyncPass = ContactUserStore.syncPass;
|
|
|
|
this.saveTrigger = koComputable(() =>
|
|
[
|
|
ContactUserStore.enableSync() ? '1' : '0',
|
|
ContactUserStore.syncUrl(),
|
|
ContactUserStore.syncUser(),
|
|
ContactUserStore.syncPass()
|
|
].join('|')
|
|
)
|
|
.extend({ debounce: 500 });
|
|
|
|
this.contactsAutosave.subscribe(value =>
|
|
Remote.saveSettings(null, { ContactsAutosave: value })
|
|
);
|
|
|
|
this.saveTrigger.subscribe(() =>
|
|
Remote.request('SaveContactsSyncData', null, {
|
|
Enable: ContactUserStore.enableSync() ? 1 : 0,
|
|
Url: ContactUserStore.syncUrl(),
|
|
User: ContactUserStore.syncUser(),
|
|
Password: ContactUserStore.syncPass()
|
|
})
|
|
);
|
|
}
|
|
}
|