mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-06 06:52:20 +08:00
71 lines
1.3 KiB
JavaScript
71 lines
1.3 KiB
JavaScript
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
_ = require('_'),
|
|
ko = require('ko'),
|
|
|
|
Settings = require('Storage/Settings')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function AccountUserStore()
|
|
{
|
|
this.email = ko.observable('');
|
|
this.parentEmail = ko.observable('');
|
|
// this.incLogin = ko.observable('');
|
|
// this.outLogin = ko.observable('');
|
|
|
|
this.signature = ko.observable('');
|
|
|
|
this.accounts = ko.observableArray([]);
|
|
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
|
|
|
this.computers();
|
|
}
|
|
|
|
AccountUserStore.prototype.computers = function ()
|
|
{
|
|
this.accountsEmails = ko.computed(function () {
|
|
return _.compact(_.map(this.accounts(), function (oItem) {
|
|
return oItem ? oItem.email : null;
|
|
}));
|
|
}, this);
|
|
|
|
this.accountsUnreadCount = ko.computed(function () {
|
|
|
|
var iResult = 0;
|
|
|
|
// _.each(this.accounts(), function (oItem) {
|
|
// if (oItem)
|
|
// {
|
|
// iResult += oItem.count();
|
|
// }
|
|
// });
|
|
|
|
return iResult;
|
|
|
|
}, this);
|
|
};
|
|
|
|
AccountUserStore.prototype.populate = function ()
|
|
{
|
|
this.email(Settings.settingsGet('Email'));
|
|
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
|
};
|
|
|
|
/**
|
|
* @return {boolean}
|
|
*/
|
|
AccountUserStore.prototype.isRootAccount = function ()
|
|
{
|
|
return '' === this.parentEmail();
|
|
};
|
|
|
|
module.exports = new AccountUserStore();
|
|
|
|
}());
|