2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
class AccountUserStore {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2020-10-27 18:09:24 +08:00
|
|
|
ko.addObservablesTo(this, {
|
|
|
|
email: '',
|
|
|
|
parentEmail: '',
|
|
|
|
signature: ''
|
|
|
|
});
|
2015-02-19 03:52:52 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accounts = ko.observableArray([]);
|
2020-08-14 04:58:41 +08:00
|
|
|
this.accounts.loading = ko.observable(false).extend({ throttle: 100 });
|
2015-02-02 04:46:23 +08:00
|
|
|
|
2020-10-03 05:54:15 +08:00
|
|
|
this.getEmailAddresses = () => this.accounts().map(item => item ? item.email : null).filter(v => v);
|
2015-02-02 04:46:23 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accountsUnreadCount = ko.computed(() => 0);
|
2017-06-25 03:26:27 +08:00
|
|
|
// this.accountsUnreadCount = ko.computed(() => {
|
|
|
|
// let result = 0;
|
2020-07-22 20:49:18 +08:00
|
|
|
// this.accounts().forEach(item => {
|
2017-06-25 03:26:27 +08:00
|
|
|
// if (item)
|
|
|
|
// {
|
|
|
|
// result += item.count();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// return result;
|
|
|
|
// });
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
populate() {
|
2020-09-04 18:05:17 +08:00
|
|
|
this.email(rl.settings.get('Email'));
|
|
|
|
this.parentEmail(rl.settings.get('ParentEmail'));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isRootAccount() {
|
2020-07-28 23:20:14 +08:00
|
|
|
return !this.parentEmail();
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|
2015-01-28 06:16:00 +08:00
|
|
|
|
2016-09-13 04:50:21 +08:00
|
|
|
export default new AccountUserStore();
|