txps1
This commit is contained in:
parent
dd98e5375a
commit
b90e06dd4c
2 changed files with 75 additions and 13 deletions
|
|
@ -6,13 +6,18 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.externalServices = {};
|
$scope.externalServices = {};
|
||||||
$scope.bitpayCardEnabled = true; // TODO
|
$scope.bitpayCardEnabled = true; // TODO
|
||||||
|
|
||||||
var setNotifications = function(notifications) {
|
|
||||||
$scope.notifications = notifications;
|
|
||||||
$timeout(function() {
|
var setPendingTxps = function(txps) {
|
||||||
$scope.$apply();
|
if (!txps) {
|
||||||
}, 1);
|
$scope.txps = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.txps = lodash.sortBy(txps, 'createdOn').reverse();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$scope.updateAllWallets = function() {
|
$scope.updateAllWallets = function() {
|
||||||
$scope.wallets = profileService.getWallets();
|
$scope.wallets = profileService.getWallets();
|
||||||
if (lodash.isEmpty($scope.wallets)) return;
|
if (lodash.isEmpty($scope.wallets)) return;
|
||||||
|
|
@ -33,16 +38,37 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.fetchingNotifications = true;
|
$scope.fetchingNotifications = true;
|
||||||
profileService.getNotifications({
|
|
||||||
|
profileService.getTxps({
|
||||||
limit: 3
|
limit: 3
|
||||||
}, function(err, n) {
|
}, function(err, txps) {
|
||||||
|
console.log('[tab-home.js.44:txps:]',txps); //TODO
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$scope.fetchingNotifications = false;
|
$scope.txps = txps;
|
||||||
setNotifications(n);
|
|
||||||
$ionicScrollDelegate.resize();
|
$ionicScrollDelegate.resize();
|
||||||
|
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
}, 1);
|
||||||
|
|
||||||
|
|
||||||
|
profileService.getNotifications({
|
||||||
|
limit: 3
|
||||||
|
}, function(err, n) {
|
||||||
|
if (err) {
|
||||||
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.fetchingNotifications = false;
|
||||||
|
$scope.notifications = n;
|
||||||
|
$ionicScrollDelegate.resize();
|
||||||
|
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
}, 1);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -62,8 +88,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setNotifications(n);
|
$scope.notifications = n;
|
||||||
$ionicScrollDelegate.resize();
|
$ionicScrollDelegate.resize();
|
||||||
|
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
}, 1);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,12 @@ angular.module('copayApp.services')
|
||||||
if (wallet.cachedActivity)
|
if (wallet.cachedActivity)
|
||||||
wallet.cachedActivity.isValid = false;
|
wallet.cachedActivity.isValid = false;
|
||||||
|
|
||||||
|
|
||||||
|
if (wallet.cachedTxps)
|
||||||
|
wallet.cachedTxps.isValid = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -779,7 +785,7 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function getNotifications(wallet, cb2) {
|
function updateNotifications(wallet, cb2) {
|
||||||
if (isActivityCached(wallet) && !opts.force) return cb2();
|
if (isActivityCached(wallet) && !opts.force) return cb2();
|
||||||
|
|
||||||
wallet.getNotifications({
|
wallet.getNotifications({
|
||||||
|
|
@ -858,7 +864,7 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
lodash.each(w, function(wallet) {
|
lodash.each(w, function(wallet) {
|
||||||
getNotifications(wallet, function(err) {
|
updateNotifications(wallet, function(err) {
|
||||||
j++;
|
j++;
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.warn('Error updating notifications:' + err);
|
$log.warn('Error updating notifications:' + err);
|
||||||
|
|
@ -892,5 +898,31 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
root.getTxps = function(opts, cb) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
|
var w = root.getWallets();
|
||||||
|
if (lodash.isEmpty(w)) return cb();
|
||||||
|
|
||||||
|
var txps = [];
|
||||||
|
|
||||||
|
function process(notifications) {
|
||||||
|
if (!notifications) return [];
|
||||||
|
|
||||||
|
var shown = lodash.sortBy(notifications, 'createdOn').reverse();
|
||||||
|
shown = shown.splice(0, opts.limit || MAX);
|
||||||
|
return shown;
|
||||||
|
};
|
||||||
|
|
||||||
|
lodash.each(w, function(x) {
|
||||||
|
if (x.pendingTxps)
|
||||||
|
txps = txps.concat(x.pendingTxps);
|
||||||
|
});
|
||||||
|
txps = lodash.sortBy(txps, 'createdOn');
|
||||||
|
txps = lodash.compact(lodash.flatten(notifications)).slice(0,MAX);
|
||||||
|
return cb(null, process(txps));
|
||||||
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue