Fixed a bug where notifications are displayed twice. Redundant notifications are now removed
This commit is contained in:
parent
52eeac9407
commit
d3a75fb099
2 changed files with 47 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue