Fixed a bug where notifications are displayed twice. Redundant notifications are now removed

This commit is contained in:
magmahindenburg 2017-06-18 17:45:46 +09:00
commit d3a75fb099
2 changed files with 47 additions and 0 deletions

View file

@ -11,6 +11,30 @@ angular.module('copayApp.controllers').controller('activityController',
$log.error(err);
return;
}
var txIdList = [];
var notificationsBeforeCheck = n.length;
for (var i=0; i<n.length; i++) {
var txId = n[i].txid;
if (txIdList.includes(txId)) {
n.splice(i, 1);
i = i - 1;
} else {
txIdList.push(txId)
}
}
var notificationsAfterCheck = n.length;
var removedNotifications = notificationsBeforeCheck - notificationsAfterCheck;
if (notificationsBeforeCheck != notificationsAfterCheck) {
console.log("Found a redundant notification. Removed " + removedNotifications);
}
console.log(n);
$scope.fetchingNotifications = false;
$scope.notifications = n;

View file

@ -248,6 +248,29 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$log.error(err);
return;
}
var txIdList = [];
var notificationsBeforeCheck = notifications.length;
for (var i=0; i<notifications.length; i++) {
var txId = notifications[i].txid;
if (txIdList.includes(txId)) {
notifications.splice(i, 1);
i = i - 1;
} else {
txIdList.push(txId)
}
}
var notificationsAfterCheck = notifications.length;
var removedNotifications = notificationsBeforeCheck - notificationsAfterCheck;
if (notificationsBeforeCheck != notificationsAfterCheck) {
console.log("Found a redundant notification. Removed " + removedNotifications);
total = total - removedNotifications;
}
$scope.notifications = notifications;
$scope.notificationsN = total;
$timeout(function() {