2016-07-16 05:29:42 +08:00
|
|
|
import ko from 'ko';
|
2022-01-01 00:02:32 +08:00
|
|
|
import { koComputable } from 'External/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
|
|
|
|
2022-03-08 07:51:32 +08:00
|
|
|
export class UserSettingsContacts /*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
|
|
|
|
2022-01-01 00:02:32 +08:00
|
|
|
this.saveTrigger = koComputable(() =>
|
2019-07-05 03:19:24 +08:00
|
|
|
[
|
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 =>
|
2022-03-01 17:18:12 +08:00
|
|
|
Remote.saveSettings(null, { ContactsAutosave: value })
|
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
|
|
|
}
|
|
|
|
}
|