mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-29 15:26:09 +00:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import ko from 'ko';
|
|
|
|
import { AppUserStore } from 'Stores/User/App';
|
|
import { ContactUserStore } from 'Stores/User/Contact';
|
|
import Remote from 'Remote/User/Fetch';
|
|
|
|
export class ContactsUserSettings {
|
|
constructor() {
|
|
this.contactsAutosave = AppUserStore.contactsAutosave;
|
|
|
|
this.allowContactsSync = ContactUserStore.allowSync;
|
|
this.enableContactsSync = ContactUserStore.enableSync;
|
|
this.contactsSyncUrl = ContactUserStore.syncUrl;
|
|
this.contactsSyncUser = ContactUserStore.syncUser;
|
|
this.contactsSyncPass = ContactUserStore.syncPass;
|
|
|
|
this.saveTrigger = ko
|
|
.computed(() =>
|
|
[
|
|
ContactUserStore.enableSync() ? '1' : '0',
|
|
ContactUserStore.syncUrl(),
|
|
ContactUserStore.syncUser(),
|
|
ContactUserStore.syncPass()
|
|
].join('|')
|
|
)
|
|
.extend({ debounce: 500 });
|
|
}
|
|
|
|
onBuild() {
|
|
this.contactsAutosave.subscribe((value) => {
|
|
Remote.saveSettings(null, {
|
|
'ContactsAutosave': value ? '1' : '0'
|
|
});
|
|
});
|
|
|
|
this.saveTrigger.subscribe(() => {
|
|
Remote.saveContactsSyncData(
|
|
null,
|
|
ContactUserStore.enableSync(),
|
|
ContactUserStore.syncUrl(),
|
|
ContactUserStore.syncUser(),
|
|
ContactUserStore.syncPass()
|
|
);
|
|
});
|
|
}
|
|
}
|