mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
Added counters of unread messages for additional accounts (#377)
This commit is contained in:
parent
abddb3d828
commit
79233ad83c
19 changed files with 333 additions and 93 deletions
|
|
@ -15,28 +15,43 @@
|
|||
*/
|
||||
function AccountUserStore()
|
||||
{
|
||||
this.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.accounts = ko.observableArray([]);
|
||||
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.collection = ko.observableArray([]);
|
||||
this.collectionEmailNames = ko.observableArray([]).extend({'throttle': 1000});
|
||||
this.collectionEmailNames.skipFirst = true;
|
||||
this.accountsEmailNames = ko.observableArray([]).extend({'throttle': 1000});
|
||||
this.accountsEmailNames.skipFirst = true;
|
||||
|
||||
this.collection.subscribe(function (aList) {
|
||||
this.collectionEmailNames(_.compact(_.map(aList, function (oItem) {
|
||||
this.accounts.subscribe(function (aList) {
|
||||
this.accountsEmailNames(_.compact(_.map(aList, function (oItem) {
|
||||
return oItem ? oItem.email : null;
|
||||
})));
|
||||
}, this);
|
||||
|
||||
this.collectionEmailNames.subscribe(function (aList) {
|
||||
if (this.collectionEmailNames.skipFirst)
|
||||
this.accountsEmailNames.subscribe(function (aList) {
|
||||
if (this.accountsEmailNames.skipFirst)
|
||||
{
|
||||
this.collectionEmailNames.skipFirst = false;
|
||||
this.accountsEmailNames.skipFirst = false;
|
||||
}
|
||||
else if (aList && 1 < aList.length)
|
||||
{
|
||||
Remote.accountSortOrder(null, aList);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.accountsUnreadCount = ko.computed(function () {
|
||||
|
||||
var iResult = 0;
|
||||
|
||||
_.each(this.accounts(), function (oItem) {
|
||||
if (oItem)
|
||||
{
|
||||
iResult += oItem.count();
|
||||
}
|
||||
});
|
||||
|
||||
return iResult;
|
||||
|
||||
}, this);
|
||||
}
|
||||
|
||||
module.exports = new AccountUserStore();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue