mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 04:04:50 +08:00
ea48f5060b
isUnd(*) to native undefined === * isFunc to native typeof * === 'function' isObject to native typeof * === 'object' microtime() to native Date().getTime(); noop to native ()=>{} noopFalse to native ()=>false noopTrue to native ()=>true boolToAjax to native *?'1':'0' Underscore.js to native
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import ko from 'ko';
|
|
|
|
import { Magics } from 'Common/Enums';
|
|
|
|
import AppStore from 'Stores/User/App';
|
|
import ContactStore from 'Stores/User/Contact';
|
|
import Remote from 'Remote/User/Ajax';
|
|
|
|
class ContactsUserSettings {
|
|
constructor() {
|
|
this.contactsAutosave = AppStore.contactsAutosave;
|
|
|
|
this.allowContactsSync = ContactStore.allowContactsSync;
|
|
this.enableContactsSync = ContactStore.enableContactsSync;
|
|
this.contactsSyncUrl = ContactStore.contactsSyncUrl;
|
|
this.contactsSyncUser = ContactStore.contactsSyncUser;
|
|
this.contactsSyncPass = ContactStore.contactsSyncPass;
|
|
|
|
this.saveTrigger = ko
|
|
.computed(() =>
|
|
[
|
|
this.enableContactsSync() ? '1' : '0',
|
|
this.contactsSyncUrl(),
|
|
this.contactsSyncUser(),
|
|
this.contactsSyncPass()
|
|
].join('|')
|
|
)
|
|
.extend({ throttle: Magics.Time500ms });
|
|
}
|
|
|
|
onBuild() {
|
|
this.contactsAutosave.subscribe((value) => {
|
|
Remote.saveSettings(null, {
|
|
'ContactsAutosave': value ? '1' : '0'
|
|
});
|
|
});
|
|
|
|
this.saveTrigger.subscribe(() => {
|
|
Remote.saveContactsSyncData(
|
|
null,
|
|
this.enableContactsSync(),
|
|
this.contactsSyncUrl(),
|
|
this.contactsSyncUser(),
|
|
this.contactsSyncPass()
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
export { ContactsUserSettings, ContactsUserSettings as default };
|