diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js
index ac2a6b471..dcd495d89 100644
--- a/src/js/controllers/tab-home.js
+++ b/src/js/controllers/tab-home.js
@@ -242,12 +242,13 @@ angular.module('copayApp.controllers').controller('tabHomeController',
var getNotifications = function() {
profileService.getNotifications({
limit: 3
- }, function(err, n) {
+ }, function(err, notifications, total) {
if (err) {
$log.error(err);
return;
}
- $scope.notifications = n;
+ $scope.notifications = notifications;
+ $scope.notificationsN = total;
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js
index dabffc717..a9416fcf3 100644
--- a/src/js/services/profileService.js
+++ b/src/js/services/profileService.js
@@ -796,8 +796,8 @@ angular.module('copayApp.services')
root.getNotifications = function(opts, cb) {
opts = opts || {};
- var TIME_STAMP = 60 * 60 * 6;
- var MAX = 100;
+ var TIME_STAMP = 60 * 60 * 6;
+ var MAX = 30;
var typeFilter = {
'NewOutgoingTx': 1,
@@ -925,7 +925,8 @@ angular.module('copayApp.services')
if (j == l) {
notifications = lodash.sortBy(notifications, 'createdOn');
notifications = lodash.compact(lodash.flatten(notifications)).slice(0, MAX);
- return cb(null, process(notifications));
+ var total = notifications.length;
+ return cb(null, process(notifications), total);
};
});
});
diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js
index 3537a8a71..236b19ee1 100644
--- a/src/js/services/walletService.js
+++ b/src/js/services/walletService.js
@@ -347,14 +347,16 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
return ret;
};
- var updateLocalTxHistory = function(wallet, progressFn, cb) {
+ var updateLocalTxHistory = function(wallet, opts, cb) {
var FIRST_LIMIT = 5;
var LIMIT = 50;
var requestLimit = FIRST_LIMIT;
var walletId = wallet.credentials.walletId;
var config = configService.getSync().wallet.settings;
- progressFn = progressFn || function() {};
+ var opts = opts || {};
+ var progressFn = opts.progressFn || function() {};
+ var foundLimitTx = false;
var fixTxsUnit = function(txs) {
if (!txs || !txs[0] || !txs[0].amountStr) return;
@@ -387,17 +389,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
progressFn(txsFromLocal, 0);
wallet.completeHistory = txsFromLocal;
- function getNewTxs(newTxs, skip, cb) {
+ function getNewTxs(newTxs, skip, next) {
getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
if (err) {
$log.warn(bwcError.msg(err, 'Server Error')); //TODO
if (err instanceof errors.CONNECTION_ERROR || (err.message && err.message.match(/5../))) {
$log.info('Retrying history download in 5 secs...');
return $timeout(function() {
- return getNewTxs(newTxs, skip, cb);
+ return getNewTxs(newTxs, skip, next);
}, 5000);
};
- return cb(err);
+ return next(err);
}
newTxs = newTxs.concat(processNewTxs(wallet, lodash.compact(res)));
@@ -408,13 +410,29 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
$log.debug('Syncing TXs. Got:' + newTxs.length + ' Skip:' + skip, ' EndingTxid:', endingTxid, ' Continue:', shouldContinue);
+ // TODO Dirty