snappymail/dev/Stores/User/Account.js
djmaze aeb5275648 Improved boot.js with existing global window.rl
Put dev/Storage/Settings.js in boots.js global rl.settings
2020-09-04 12:05:17 +02:00

47 lines
980 B
JavaScript

import ko from 'ko';
class AccountUserStore {
constructor() {
this.email = ko.observable('');
this.parentEmail = ko.observable('');
this.signature = ko.observable('');
this.accounts = ko.observableArray([]);
this.accounts.loading = ko.observable(false).extend({ throttle: 100 });
this.computers();
}
computers() {
this.accountsEmails = ko.computed(
() => this.accounts().map(item => (item ? item.email : null)).filter(value => !!value)
);
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();
}
}
export default new AccountUserStore();