Merge pull request #77 from JDonadio/fix/notifications

Fix notifications shown
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-07 15:15:55 -03:00 committed by GitHub
commit 413c1fc8a3
2 changed files with 19 additions and 7 deletions

View File

@ -19,7 +19,7 @@
</a>
</div>
<div class="list card">
<div class="list card" ng-if="notifications[0]">
<a class="item item-icon-right item-heading" ui-sref="tabs.activity" translate>
Recent Activity
<i class="icon nav-item-arrow-right"></i>
@ -28,7 +28,7 @@
<ion-spinner icon="lines"></ion-spinner>
<div translate>Updating activity. Please stand by</div>
</span>
<a ng-if="notifications[0]" class="item" ng-repeat="x in notifications" ng-click="x.action()">
<a class="item" ng-repeat="x in notifications" ng-click="x.action()">
<span ng-include="'views/includes/walletActivity.html'"></span>
</a>
</div>

View File

@ -30,7 +30,7 @@ angular.module('copayApp.services')
root.updateWalletSettings = function(wallet) {
var defaults = configService.getDefaults();
configService.whenAvailable(function(config){
configService.whenAvailable(function(config) {
wallet.usingCustomBWS = config.bwsFor && config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
wallet.name = (config.aliasFor && config.aliasFor[wallet.id]) || wallet.credentials.walletName;
wallet.color = (config.colorFor && config.colorFor[wallet.id]) || '#4A90E2';
@ -77,7 +77,7 @@ angular.module('copayApp.services')
var opts = opts || {};
var walletId = wallet.credentials.walletId;
if ((root.wallet[walletId] && root.wallet[walletId].started) && !opts.force) {
if ((root.wallet[walletId] && root.wallet[walletId].started) && !opts.force) {
return false;
}
@ -762,7 +762,7 @@ angular.module('copayApp.services')
var TIME_STAMP = 60 * 60 * 24 * 7;
var MAX = 100;
var ignored = {
var typeFilter1 = {
'NewBlock': 1,
'BalanceUpdated': 1,
'NewOutgoingTxByThirdParty': 1,
@ -771,6 +771,12 @@ angular.module('copayApp.services')
'TxProposalFinallyRejected': 1,
};
var typeFilter2 = {
'TxProposalAcceptedBy': 1,
'TxProposalRejectedBy': 1,
'NewTxProposal': 1,
}
var w = root.getWallets();
if (lodash.isEmpty(w)) return cb();
@ -868,9 +874,15 @@ angular.module('copayApp.services')
$log.warn('Error updating notifications:' + err);
} else {
var n = lodash.filter(wallet.cachedActivity.n, function(x) {
return !ignored[x.type];
return !typeFilter1[x.type];
});
if (wallet.n == 1) {
var n = lodash.filter(n, function(x) {
return !typeFilter2[x.type];
});
}
var idToName = {};
if (wallet.cachedStatus) {
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {
@ -911,7 +923,7 @@ angular.module('copayApp.services')
txps = txps.concat(x.pendingTxps);
});
txps = lodash.sortBy(txps, 'pendingForUs', 'createdOn');
txps = lodash.compact(lodash.flatten(txps)).slice(0,MAX);
txps = lodash.compact(lodash.flatten(txps)).slice(0, MAX);
var n = txps.length;
return cb(null, txps, n);
};