2016-07-16 05:29:42 +08:00
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import AppStore from 'Stores/User/App';
|
|
|
|
import ContactStore from 'Stores/User/Contact';
|
|
|
|
import Remote from 'Remote/User/Ajax';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
class ContactsUserSettings {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
|
|
|
this.contactsAutosave = AppStore.contactsAutosave;
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
this.allowContactsSync = ContactStore.allowContactsSync;
|
|
|
|
this.enableContactsSync = ContactStore.enableContactsSync;
|
|
|
|
this.contactsSyncUrl = ContactStore.contactsSyncUrl;
|
|
|
|
this.contactsSyncUser = ContactStore.contactsSyncUser;
|
|
|
|
this.contactsSyncPass = ContactStore.contactsSyncPass;
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.saveTrigger = ko
|
|
|
|
.computed(() =>
|
|
|
|
[
|
|
|
|
this.enableContactsSync() ? '1' : '0',
|
|
|
|
this.contactsSyncUrl(),
|
|
|
|
this.contactsSyncUser(),
|
|
|
|
this.contactsSyncPass()
|
|
|
|
].join('|')
|
|
|
|
)
|
2020-08-14 04:58:41 +08:00
|
|
|
.extend({ throttle: 500 });
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
onBuild() {
|
|
|
|
this.contactsAutosave.subscribe((value) => {
|
|
|
|
Remote.saveSettings(null, {
|
2020-07-30 03:49:41 +08:00
|
|
|
'ContactsAutosave': value ? '1' : '0'
|
2016-07-16 05:29:42 +08:00
|
|
|
});
|
2014-10-30 21:59:25 +08:00
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
this.saveTrigger.subscribe(() => {
|
2019-07-05 03:19:24 +08:00
|
|
|
Remote.saveContactsSyncData(
|
|
|
|
null,
|
2016-07-16 05:29:42 +08:00
|
|
|
this.enableContactsSync(),
|
|
|
|
this.contactsSyncUrl(),
|
|
|
|
this.contactsSyncUser(),
|
|
|
|
this.contactsSyncPass()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { ContactsUserSettings, ContactsUserSettings as default };
|