2016-07-16 05:29:42 +08:00
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-03-16 23:06:16 +08:00
|
|
|
import { SettingsGet } from 'Common/Globals';
|
2021-03-11 05:41:35 +08:00
|
|
|
import { ContactUserStore } from 'Stores/User/Contact';
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-09-23 02:17:44 +08:00
|
|
|
export class ContactsUserSettings /*extends AbstractViewSettings*/ {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2021-03-16 23:06:16 +08:00
|
|
|
this.contactsAutosave = ko.observable(!!SettingsGet('ContactsAutosave'));
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
this.allowContactsSync = ContactUserStore.allowSync;
|
|
|
|
this.enableContactsSync = ContactUserStore.enableSync;
|
|
|
|
this.contactsSyncUrl = ContactUserStore.syncUrl;
|
|
|
|
this.contactsSyncUser = ContactUserStore.syncUser;
|
|
|
|
this.contactsSyncPass = ContactUserStore.syncPass;
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.saveTrigger = ko
|
|
|
|
.computed(() =>
|
|
|
|
[
|
2021-03-11 05:41:35 +08:00
|
|
|
ContactUserStore.enableSync() ? '1' : '0',
|
|
|
|
ContactUserStore.syncUrl(),
|
|
|
|
ContactUserStore.syncUser(),
|
|
|
|
ContactUserStore.syncPass()
|
2019-07-05 03:19:24 +08:00
|
|
|
].join('|')
|
|
|
|
)
|
2021-02-10 19:12:36 +08:00
|
|
|
.extend({ debounce: 500 });
|
2016-07-16 05:29:42 +08:00
|
|
|
|
2021-03-16 18:38:40 +08:00
|
|
|
this.contactsAutosave.subscribe(value =>
|
2016-07-16 05:29:42 +08:00
|
|
|
Remote.saveSettings(null, {
|
2021-03-25 04:26:40 +08:00
|
|
|
ContactsAutosave: value ? 1 : 0
|
2021-03-16 18:38:40 +08:00
|
|
|
})
|
|
|
|
);
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-03-16 18:38:40 +08:00
|
|
|
this.saveTrigger.subscribe(() =>
|
2021-12-03 06:15:24 +08:00
|
|
|
Remote.request('SaveContactsSyncData', null, {
|
|
|
|
Enable: ContactUserStore.enableSync() ? 1 : 0,
|
|
|
|
Url: ContactUserStore.syncUrl(),
|
|
|
|
User: ContactUserStore.syncUser(),
|
|
|
|
Password: ContactUserStore.syncPass()
|
|
|
|
})
|
2021-03-16 18:38:40 +08:00
|
|
|
);
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
|
|
|
}
|