Added counters of unread messages for additional accounts (#377)

This commit is contained in:
RainLoop Team 2015-02-02 00:46:23 +04:00
parent abddb3d828
commit 79233ad83c
19 changed files with 333 additions and 93 deletions

View file

@ -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();

View file

@ -59,7 +59,7 @@
return iResult;
}, this);
}, this).extend({'notify': 'always'});
this.enableDesktopNotification = ko.computed({
'owner': this,
@ -117,7 +117,7 @@
this.allowDesktopNotification(false);
}
}
});
}).extend({'notify': 'always'});
if (!this.enableDesktopNotification.valueHasMutated)
{
@ -150,7 +150,8 @@
this.soundNotificationIsSupported(true);
this.buzz = new buzz.sound(Links.sound('new-mail'), {
formats: ['ogg', 'mp3']
'preload': 'none',
'formats': ['mp3', 'ogg']
});
}
else