snappymail/dev/Stores/User/Account.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-01-28 06:16:00 +08:00
import ko from 'ko';
import _ from '_';
2016-08-24 06:17:50 +08:00
import {Magics} from 'Common/Enums';
import * as Settings from 'Storage/Settings';
2016-06-30 08:02:45 +08:00
class AccountUserStore
2016-06-30 08:02:45 +08:00
{
constructor() {
this.email = ko.observable('');
this.parentEmail = ko.observable('');
2015-01-28 06:16:00 +08:00
this.signature = ko.observable('');
2015-02-19 03:52:52 +08:00
this.accounts = ko.observableArray([]);
2016-08-24 06:17:50 +08:00
this.accounts.loading = ko.observable(false).extend({throttle: Magics.Time100ms});
this.computers();
}
computers() {
this.accountsEmails = ko.computed(
() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null))));
this.accountsUnreadCount = ko.computed(() => 0);
// this.accountsUnreadCount = ko.computed(() => {
// let result = 0;
// _.each(this.accounts(), (item) => {
// if (item)
// {
// result += item.count();
// }
// });
// return result;
// });
}
populate() {
this.email(Settings.settingsGet('Email'));
this.parentEmail(Settings.settingsGet('ParentEmail'));
}
/**
* @returns {boolean}
*/
isRootAccount() {
return '' === this.parentEmail();
}
}
2015-01-28 06:16:00 +08:00
export default new AccountUserStore();