snappymail/dev/Stores/User/Account.js

43 lines
886 B
JavaScript
Raw Normal View History

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