recent activity
This commit is contained in:
parent
3080cf05dd
commit
0c668f3b83
5 changed files with 89 additions and 83 deletions
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
|
||||
<p class="wallet-activity-note">
|
||||
<!-- {{x.types}} -->
|
||||
<i class="icon ion-record wallet-activity-note-child" ng-style="{'color':x.wallet.color}"></i>
|
||||
<span ng-if="x.creatorName" class="wallet-activity-note-child">{{ x.creatorName}}@</span>
|
||||
<span class="wallet-activity-note-child">{{x.wallet.name}}</span>
|
||||
|
|
|
|||
|
|
@ -17,31 +17,14 @@ angular.module('copayApp.controllers').controller('activityController',
|
|||
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
|
||||
var i = $scope.wallets.length,
|
||||
j = 0;
|
||||
var timeSpan = 60 * 60 * 24 * 7;
|
||||
var notifications = [];
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
|
||||
walletService.getNotifications(wallet, {
|
||||
includeOwn: true,
|
||||
timeSpan: timeSpan,
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
notifications.push(n);
|
||||
if (++j == i) {
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
});
|
||||
profileService.getNotifications(50, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(n);
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
|
||||
|
||||
var setNotifications = function(notifications) {
|
||||
var n = walletService.processNotifications(notifications, 5);
|
||||
var n = walletService.processNotifications(notifications, 3);
|
||||
$scope.notifications = n;
|
||||
$scope.notificationsMore = notifications.length > 5 ? notifications.length - 5 : null;
|
||||
$scope.notificationsMore = notifications.length > 3 ? notifications.length - 3 : null;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
|
|
@ -22,8 +22,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
var timeSpan = 60 * 60 * 24 * 7;
|
||||
var notifications = [];
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
|
|
@ -34,22 +32,19 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
wallet.status = status;
|
||||
});
|
||||
|
||||
walletService.getNotifications(wallet, {
|
||||
timeSpan: timeSpan,
|
||||
includeOwn: true,
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
notifications.push(n);
|
||||
if (++j == i) {
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
profileService.getNotifications(3, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(n);
|
||||
})
|
||||
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -428,8 +428,8 @@ angular.module('copayApp.services')
|
|||
|
||||
// check if exist
|
||||
if (lodash.find(root.profile.credentials, {
|
||||
'walletId': walletData.walletId
|
||||
})) {
|
||||
'walletId': walletData.walletId
|
||||
})) {
|
||||
return cb(gettext('Cannot join the same wallet more that once'));
|
||||
}
|
||||
} catch (ex) {
|
||||
|
|
@ -735,15 +735,76 @@ angular.module('copayApp.services')
|
|||
});
|
||||
} else {}
|
||||
|
||||
return lodash.sortBy(ret, [function(x) {
|
||||
return x.isComplete();
|
||||
}, 'createdOn']);
|
||||
return lodash.sortBy(ret, [
|
||||
function(x) {
|
||||
return x.isComplete();
|
||||
}, 'createdOn'
|
||||
]);
|
||||
};
|
||||
|
||||
root.toggleHideBalanceFlag = function(walletId, cb) {
|
||||
root.wallet[walletId].balanceHidden = !root.wallet[walletId].balanceHidden;
|
||||
storageService.setHideBalanceFlag(walletId, root.wallet[walletId].balanceHidden.toString(), cb);
|
||||
}
|
||||
};
|
||||
|
||||
root.getNotifications = function(limit, cb) {
|
||||
|
||||
var TIME_STAMP = 60 * 60 * 24 * 7;
|
||||
|
||||
var opts = {
|
||||
timeSpan: TIME_STAMP,
|
||||
includeOwn: true,
|
||||
};
|
||||
|
||||
var ignored = {
|
||||
'NewBlock': 1,
|
||||
'BalanceUpdated': 1,
|
||||
'NewOutgoingTxByThirdParty': 1,
|
||||
'NewAddress': 1,
|
||||
'TxProposalFinallyAccepted': 1,
|
||||
'TxProposalFinallyRejected': 1,
|
||||
};
|
||||
|
||||
var w = root.getWallets();
|
||||
if (lodash.isEmpty(w)) return cb();
|
||||
|
||||
var l = w.length,
|
||||
j = 0,
|
||||
notifications = [];
|
||||
lodash.each(w, function(wallet) {
|
||||
wallet.getNotifications(opts, function(err, n) {
|
||||
j++;
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
|
||||
n = lodash.filter(n, function(x) {
|
||||
return !ignored[x.type];
|
||||
});
|
||||
|
||||
var idToName = {};
|
||||
if (wallet.cachedStatus) {
|
||||
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {
|
||||
idToName[c.id] = c.name;
|
||||
});
|
||||
}
|
||||
|
||||
lodash.each(n, function(x) {
|
||||
x.wallet = wallet;
|
||||
if (x.creatorId && wallet.cachedStatus) {
|
||||
x.creatorName = idToName[x.creatorId];
|
||||
};
|
||||
});
|
||||
|
||||
notifications.push(n);
|
||||
if (++j == l) {
|
||||
notifications = lodash.sortBy(notifications,'createdOn');
|
||||
return cb(null, lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -976,40 +976,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.getNotifications = function(wallet, opts, cb) {
|
||||
|
||||
wallet.getNotifications(opts, function(err, notifications) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var ignored = {
|
||||
'NewBlock': 1,
|
||||
'BalanceUpdated': 1,
|
||||
'NewOutgoingTxByThirdParty': 1,
|
||||
'NewAddress': 1,
|
||||
};
|
||||
|
||||
notifications = lodash.filter(notifications, function(x) {
|
||||
return !ignored[x.type];
|
||||
});
|
||||
|
||||
var idToName = {};
|
||||
if (wallet.cachedStatus) {
|
||||
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {
|
||||
idToName[c.id] = c.name;
|
||||
});
|
||||
}
|
||||
|
||||
lodash.each(notifications, function(x) {
|
||||
x.wallet = wallet;
|
||||
if (x.creatorId && wallet.cachedStatus) {
|
||||
x.creatorName = idToName[x.creatorId];
|
||||
};
|
||||
});
|
||||
|
||||
return cb(null, notifications);
|
||||
});
|
||||
};
|
||||
|
||||
root.getEncodedWalletInfo = function(wallet, cb) {
|
||||
|
||||
var derivationPath = wallet.credentials.getBaseAddressDerivationPath();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue