commit
46f8c3a3ac
10 changed files with 228 additions and 185 deletions
|
|
@ -42,7 +42,7 @@
|
||||||
"url": "https://github.com/bitpay/copay/issues"
|
"url": "https://github.com/bitpay/copay/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bitcore-wallet-client": "4.0.0",
|
"bitcore-wallet-client": "4.1.0",
|
||||||
"coveralls": "^2.11.9",
|
"coveralls": "^2.11.9",
|
||||||
"express": "^4.11.2",
|
"express": "^4.11.2",
|
||||||
"fs": "0.0.2",
|
"fs": "0.0.2",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"//":"PLEASE! Do not edit this file directly",
|
"//":"PLEASE! Do not edit this file directly",
|
||||||
"//":" Modify it at app-template/",
|
"//":" Modify it at app-template/",
|
||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "BitPay",
|
"name": "BitPay",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"//":"PLEASE! Do not edit this file directly",
|
"//":"PLEASE! Do not edit this file directly",
|
||||||
"//":" Modify it at app-template/",
|
"//":" Modify it at app-template/",
|
||||||
|
|
||||||
"name": "bitpay",
|
"name": "bitpay",
|
||||||
"description": "The BitPay Bitcoin Wallet",
|
"description": "The BitPay Bitcoin Wallet",
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
"url": "https://github.com/bitpay/copay/issues"
|
"url": "https://github.com/bitpay/copay/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bitcore-wallet-client": "4.0.0",
|
"bitcore-wallet-client": "4.1.0",
|
||||||
"coveralls": "^2.11.9",
|
"coveralls": "^2.11.9",
|
||||||
"express": "^4.11.2",
|
"express": "^4.11.2",
|
||||||
"fs": "0.0.2",
|
"fs": "0.0.2",
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<div ng-if="!fetchingNotifications">
|
<div ng-if="!fetchingNotifications">
|
||||||
<div class="list card">
|
<div class="list card">
|
||||||
<div class="item item-icon-left" ng-repeat="x in notifications" ng-click="x.action()">
|
<div class="item" ng-repeat="x in notifications" ng-click="x.action()">
|
||||||
<span ng-include="'views/includes/walletActivity.html'"></span>
|
<span ng-include="'views/includes/walletActivity.html'"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
<span class="wallet-activity">
|
<span class="wallet-activity">
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-if="x.types.indexOf('NewOutgoingTx')>=0">
|
||||||
|
<span>Payment Sent </span>
|
||||||
|
<div class="wallet-activity-amount">
|
||||||
|
{{x.amountStr}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div ng-if="x.types.indexOf('NewIncomingTx')>=0">
|
<div ng-if="x.types.indexOf('NewIncomingTx')>=0">
|
||||||
<span>Payment Received</span>
|
<span>Payment Received</span>
|
||||||
<div class="wallet-activity-amount">
|
<div class="wallet-activity-amount">
|
||||||
|
|
@ -7,7 +17,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-if="x.types.indexOf('TxProposalRemoved')>=0">
|
<div ng-if="x.types.indexOf('TxProposalRemoved')>=0">
|
||||||
<i class="icon ion-ios-close-empty size-21" ng-style="{'color':x.wallet.color}"></i>
|
<i class="icon ion-ios-close-empty size-21" ng-style="{'color':x.wallet.color}"></i>
|
||||||
Proposal Deleted
|
Proposal Deleted
|
||||||
|
|
@ -19,13 +28,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="x.types.indexOf('TxProposalRemoved') == -1 && x.types.indexOf('TxProposalRejected') == -1">
|
<div ng-if="x.types.indexOf('TxProposalRemoved') == -1 && x.types.indexOf('TxProposalRejected') == -1">
|
||||||
<span ng-if="x.types.indexOf('NewTxProposal')>=0 ">
|
<span ng-if="x.types.indexOf('NewTxProposal')>=0 && x.types.indexOf('NewOutgoingTx')==-1 ">
|
||||||
<i class="icon ion-arrow-up-c size-21" ng-style="{'color':x.wallet.color}"></i>
|
<i class="icon ion-arrow-up-c size-21" ng-style="{'color':x.wallet.color}"></i>
|
||||||
|
|
||||||
{{x.amountStr}}
|
{{x.amountStr}}
|
||||||
<i>{{x.message}}</i>
|
<i>{{x.message}}</i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="x.types.indexOf('TxProposalAcceptedBy')>=0 && x.types.indexOf('NewTxProposal') == -1 ">
|
<span ng-if="x.types.indexOf('TxProposalAcceptedBy')>=0 && x.types.indexOf('NewTxProposal') == -1 && x.types.indexOf('NewOutgoingTx')==-1">
|
||||||
<i class="icon ion-checkmark-round size-21" ng-style="{'color':x.wallet.color}"></i>
|
<i class="icon ion-checkmark-round size-21" ng-style="{'color':x.wallet.color}"></i>
|
||||||
Proposal Accepted
|
Proposal Accepted
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -33,10 +42,10 @@
|
||||||
|
|
||||||
|
|
||||||
<p class="wallet-activity-note">
|
<p class="wallet-activity-note">
|
||||||
|
<!-- {{x.types}} -->
|
||||||
<i class="icon ion-record wallet-activity-note-child" ng-style="{'color':x.wallet.color}"></i>
|
<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 ng-if="x.creatorName" class="wallet-activity-note-child">{{ x.creatorName}}@</span>
|
||||||
<span class="wallet-activity-note-child">{{x.wallet.name}}</span>
|
<span class="wallet-activity-note-child">{{x.wallet.name}}</span>
|
||||||
<time class="wallet-activity-note-child">{{ x.createdOn * 1000 | amTimeAgo}}</time>
|
<time class="wallet-activity-note-child">{{ x.createdOn * 1000 | amTimeAgo}}</time>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
<ion-content class="padding" ng-controller="tabHomeController" ng-init="updateAllWallets(); nextStep()">
|
<ion-content class="padding" ng-controller="tabHomeController" ng-init="updateAllWallets(); nextStep()">
|
||||||
|
|
||||||
<div class="list card" ng-hide="!notifications[0]">
|
<div class="card">
|
||||||
<div class="item item-heading">
|
<div class="item item-divider item-icon-right">
|
||||||
Recent Activity
|
Recent Activity
|
||||||
|
<i class="icon ion-ios-arrow-right" ui-sref="activity"></i>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="fetchingNotifications" class="item text-center">
|
<div ng-if="fetchingNotifications" class="item text-center">
|
||||||
<ion-spinner icon="lines"></ion-spinner>
|
<ion-spinner icon="lines"></ion-spinner>
|
||||||
|
|
@ -17,12 +18,9 @@
|
||||||
<a class="item" ng-repeat="x in notifications" ng-click="x.action()">
|
<a class="item" ng-repeat="x in notifications" ng-click="x.action()">
|
||||||
<span ng-include="'views/includes/walletActivity.html'"></span>
|
<span ng-include="'views/includes/walletActivity.html'"></span>
|
||||||
</a>
|
</a>
|
||||||
|
<div class="item" ng-show="!notifications[0]">
|
||||||
<a class="item text-center" ui-sref="activity" ng-show="notificationsMore">
|
<span translate>Nothing to show here.</span>
|
||||||
|
</div>
|
||||||
<span translate>More</span> ({{notificationsMore}})
|
|
||||||
<span style="font-size:12px;color:gray">(ToDo: Cache, refresh & seft not. 1-1 no here yet)</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,43 +4,19 @@ angular.module('copayApp.controllers').controller('activityController',
|
||||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var setNotifications = function(notifications) {
|
|
||||||
var n = walletService.processNotifications(notifications);
|
|
||||||
|
|
||||||
$scope.notifications = n;
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$apply();
|
|
||||||
}, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$scope.init = function() {
|
$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;
|
$scope.fetchingNotifications = true;
|
||||||
|
profileService.getNotifications(50, function(err, n) {
|
||||||
lodash.each($scope.wallets, function(wallet) {
|
if (err) {
|
||||||
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
walletService.getNotifications(wallet, {
|
return;
|
||||||
timeSpan: timeSpan
|
}
|
||||||
}, function(err, n) {
|
$scope.fetchingNotifications = false;
|
||||||
if (err) {
|
$scope.notifications = n;
|
||||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
$timeout(function() {
|
||||||
return;
|
$scope.$apply();
|
||||||
}
|
}, 1);
|
||||||
notifications.push(n);
|
|
||||||
if (++j == i) {
|
|
||||||
$scope.fetchingNotifications = false;
|
|
||||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
|
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
|
||||||
|
|
||||||
var setNotifications = function(notifications) {
|
var setNotifications = function(notifications) {
|
||||||
var n = walletService.processNotifications(notifications, 5);
|
$scope.notifications = notifications;
|
||||||
$scope.notifications = n;
|
|
||||||
$scope.notificationsMore = notifications.length > 5 ? notifications.length - 5 : null;
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
@ -16,41 +14,35 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.wallets = profileService.getWallets();
|
$scope.wallets = profileService.getWallets();
|
||||||
if (lodash.isEmpty($scope.wallets)) return;
|
if (lodash.isEmpty($scope.wallets)) return;
|
||||||
|
|
||||||
$timeout(function() {
|
var i = $scope.wallets.length;
|
||||||
var i = $scope.wallets.length;
|
var j = 0;
|
||||||
var j = 0;
|
var timeSpan = 60 * 60 * 24 * 7;
|
||||||
var timeSpan = 60 * 60 * 24 * 7;
|
var notifications = [];
|
||||||
var notifications = [];
|
|
||||||
|
|
||||||
$scope.fetchingNotifications = true;
|
lodash.each($scope.wallets, function(wallet) {
|
||||||
|
|
||||||
lodash.each($scope.wallets, function(wallet) {
|
|
||||||
|
|
||||||
walletService.getStatus(wallet, {}, function(err, status) {
|
|
||||||
if (err) {
|
|
||||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wallet.status = status;
|
|
||||||
});
|
|
||||||
|
|
||||||
walletService.getNotifications(wallet, {
|
|
||||||
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)));
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
walletService.getStatus(wallet, {}, function(err, status) {
|
||||||
|
if (err) {
|
||||||
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wallet.status = status;
|
||||||
});
|
});
|
||||||
$scope.$digest();
|
|
||||||
}, 100);
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.fetchingNotifications = true;
|
||||||
|
profileService.getNotifications({
|
||||||
|
limit: 3
|
||||||
|
}, function(err, n) {
|
||||||
|
if (err) {
|
||||||
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.fetchingNotifications = false;
|
||||||
|
setNotifications(n);
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.updateWallet = function(wallet) {
|
$scope.updateWallet = function(wallet) {
|
||||||
|
|
@ -61,9 +53,17 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wallet.status = status;
|
wallet.status = status;
|
||||||
$timeout(function() {
|
|
||||||
$scope.$apply();
|
profileService.getNotifications({
|
||||||
}, 1);
|
limit: 3
|
||||||
|
}, function(err, n) {
|
||||||
|
console.log('[tab-home.js.57]', n); //TODO
|
||||||
|
if (err) {
|
||||||
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setNotifications(n);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('copayApp.services')
|
angular.module('copayApp.services')
|
||||||
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, $ionicHistory) {
|
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, platformInfo, $ionicHistory, txFormatService, $state) {
|
||||||
|
|
||||||
|
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
var isChromeApp = platformInfo.isChromeApp;
|
||||||
|
|
@ -119,6 +119,9 @@ angular.module('copayApp.services')
|
||||||
if (wallet.completeHistory)
|
if (wallet.completeHistory)
|
||||||
wallet.completeHistory.isValid = false;
|
wallet.completeHistory.isValid = false;
|
||||||
|
|
||||||
|
if (wallet.cachedActivity)
|
||||||
|
wallet.cachedActivity.isValid = false;
|
||||||
|
|
||||||
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -130,7 +133,9 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
wallet.initialize({}, function(err) {
|
wallet.initialize({
|
||||||
|
notificationIncludeOwn: true,
|
||||||
|
}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.error('Could not init notifications err:', err);
|
$log.error('Could not init notifications err:', err);
|
||||||
return;
|
return;
|
||||||
|
|
@ -426,8 +431,8 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
// check if exist
|
// check if exist
|
||||||
if (lodash.find(root.profile.credentials, {
|
if (lodash.find(root.profile.credentials, {
|
||||||
'walletId': walletData.walletId
|
'walletId': walletData.walletId
|
||||||
})) {
|
})) {
|
||||||
return cb(gettext('Cannot join the same wallet more that once'));
|
return cb(gettext('Cannot join the same wallet more that once'));
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
@ -733,15 +738,155 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
} else {}
|
} else {}
|
||||||
|
|
||||||
return lodash.sortBy(ret, [function(x) {
|
return lodash.sortBy(ret, [
|
||||||
return x.isComplete();
|
|
||||||
}, 'createdOn']);
|
function(x) {
|
||||||
|
return x.isComplete();
|
||||||
|
}, 'createdOn'
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.toggleHideBalanceFlag = function(walletId, cb) {
|
root.toggleHideBalanceFlag = function(walletId, cb) {
|
||||||
root.wallet[walletId].balanceHidden = !root.wallet[walletId].balanceHidden;
|
root.wallet[walletId].balanceHidden = !root.wallet[walletId].balanceHidden;
|
||||||
storageService.setHideBalanceFlag(walletId, root.wallet[walletId].balanceHidden.toString(), cb);
|
storageService.setHideBalanceFlag(walletId, root.wallet[walletId].balanceHidden.toString(), cb);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
root.getNotifications = function(opts, cb) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
|
var TIME_STAMP = 60 * 60 * 24 * 7;
|
||||||
|
var MAX = 100;
|
||||||
|
|
||||||
|
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 = [];
|
||||||
|
|
||||||
|
|
||||||
|
function isActivityCached(wallet) {
|
||||||
|
return wallet.cachedActivity && wallet.cachedActivity.isValid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function getNotifications(wallet, cb2) {
|
||||||
|
if (isActivityCached(wallet) && !opts.force) return cb2();
|
||||||
|
|
||||||
|
wallet.getNotifications({
|
||||||
|
timeSpan: TIME_STAMP,
|
||||||
|
includeOwn: true,
|
||||||
|
}, function(err, n) {
|
||||||
|
if (err) return cb2(err);
|
||||||
|
|
||||||
|
wallet.cachedActivity = {
|
||||||
|
n: n.slice(-MAX),
|
||||||
|
isValid: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return cb2();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function process(notifications) {
|
||||||
|
if (!notifications) return [];
|
||||||
|
|
||||||
|
var shown = lodash.sortBy(notifications, 'createdOn').reverse();
|
||||||
|
|
||||||
|
shown = shown.splice(0, opts.limit || MAX);
|
||||||
|
|
||||||
|
lodash.each(shown, function(x) {
|
||||||
|
x.txpId = x.data ? x.data.txProposalId : null;
|
||||||
|
x.txid = x.data ? x.data.txid : null;
|
||||||
|
x.types = [x.type];
|
||||||
|
|
||||||
|
if (x.data && x.data.amount)
|
||||||
|
x.amountStr = txFormatService.formatAmountStr(x.data.amount);
|
||||||
|
|
||||||
|
x.action = function() {
|
||||||
|
// TODO?
|
||||||
|
$state.go('wallet.details', {
|
||||||
|
walletId: x.walletId,
|
||||||
|
txpId: x.txpId,
|
||||||
|
txid: x.txid,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// condense
|
||||||
|
var finale = [],
|
||||||
|
prev;
|
||||||
|
|
||||||
|
|
||||||
|
lodash.each(shown, function(x) {
|
||||||
|
if (prev && prev.walletId === x.walletId && prev.txpId && prev.txpId === x.txpId && prev.creatorId && prev.creatorId === x.creatorId) {
|
||||||
|
prev.types.push(x.type);
|
||||||
|
prev.data = lodash.assign(prev.data, x.data);
|
||||||
|
prev.txid = prev.txid || x.txid;
|
||||||
|
prev.amountStr = prev.amountStr || x.amountStr;
|
||||||
|
prev.creatorName = prev.creatorName || x.creatorName;
|
||||||
|
} else {
|
||||||
|
finale.push(x);
|
||||||
|
prev = x;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// messages...
|
||||||
|
|
||||||
|
var u = bwcService.getUtils();
|
||||||
|
lodash.each(finale, function(x) {
|
||||||
|
if (x.data && x.data.message && x.wallet && x.wallet.credentials.sharedEncryptingKey) {
|
||||||
|
// TODO TODO TODO => BWC
|
||||||
|
x.message = u.decryptMessage(x.data.message, x.wallet.credentials.sharedEncryptingKey);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return finale;
|
||||||
|
};
|
||||||
|
|
||||||
|
lodash.each(w, function(wallet) {
|
||||||
|
getNotifications(wallet, function(err) {
|
||||||
|
j++;
|
||||||
|
if (err) {
|
||||||
|
$log.warn('Error updating notifications:' + err);
|
||||||
|
} else {
|
||||||
|
var n = lodash.filter(wallet.cachedActivity.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');
|
||||||
|
notifications = lodash.compact(lodash.flatten(notifications)).slice(0,MAX);
|
||||||
|
return cb(null, process(notifications));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -976,33 +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);
|
|
||||||
|
|
||||||
notifications = lodash.filter(notifications, function(x) {
|
|
||||||
return x.type != 'NewBlock' && x.type != 'BalanceUpdated' && x.type != 'NewOutgoingTxByThirdParty';
|
|
||||||
});
|
|
||||||
|
|
||||||
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) {
|
root.getEncodedWalletInfo = function(wallet, cb) {
|
||||||
|
|
||||||
var derivationPath = wallet.credentials.getBaseAddressDerivationPath();
|
var derivationPath = wallet.credentials.getBaseAddressDerivationPath();
|
||||||
|
|
@ -1036,64 +1009,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.processNotifications = function(notifications, limit) {
|
|
||||||
if (!notifications) return [];
|
|
||||||
|
|
||||||
var shown = lodash.sortBy(notifications, 'createdOn').reverse();
|
|
||||||
|
|
||||||
if (limit)
|
|
||||||
shown = shown.splice(0, limit);
|
|
||||||
|
|
||||||
lodash.each(shown, function(x) {
|
|
||||||
x.txpId = x.data ? x.data.txProposalId : null;
|
|
||||||
x.txid = x.data ? x.data.txid : null;
|
|
||||||
x.types = [x.type];
|
|
||||||
|
|
||||||
if (x.data && x.data.amount)
|
|
||||||
x.amountStr = txFormatService.formatAmountStr(x.data.amount);
|
|
||||||
|
|
||||||
x.action = function() {
|
|
||||||
// TODO?
|
|
||||||
$state.go('wallet.details', {
|
|
||||||
walletId: x.walletId,
|
|
||||||
txpId: x.txpId,
|
|
||||||
txid: x.txid,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// condense
|
|
||||||
var finale = [],
|
|
||||||
prev;
|
|
||||||
|
|
||||||
|
|
||||||
lodash.each(shown, function(x) {
|
|
||||||
if (prev && prev.walletId === x.walletId && prev.txpId && prev.txpId === x.txpId && prev.creatorId && prev.creatorId === x.creatorId) {
|
|
||||||
prev.types.push(x.type);
|
|
||||||
prev.data = lodash.assign(prev.data, x.data);
|
|
||||||
prev.txid = prev.txid || x.txid;
|
|
||||||
prev.amountStr = prev.amountStr || x.amountStr;
|
|
||||||
prev.creatorName = prev.creatorName || x.creatorName;
|
|
||||||
} else {
|
|
||||||
finale.push(x);
|
|
||||||
prev = x;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// messages...
|
|
||||||
|
|
||||||
var u = bwcService.getUtils();
|
|
||||||
lodash.each(finale, function(x) {
|
|
||||||
if (x.data && x.data.message && x.wallet && x.wallet.credentials.sharedEncryptingKey) {
|
|
||||||
// TODO TODO TODO => BWC
|
|
||||||
x.message = u.decryptMessage(x.data.message, x.wallet.credentials.sharedEncryptingKey);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return finale;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
root.setTouchId = function(wallet, enabled, cb) {
|
root.setTouchId = function(wallet, enabled, cb) {
|
||||||
fingerprintService.check(wallet, function(err) {
|
fingerprintService.check(wallet, function(err) {
|
||||||
if (err) return cb(err); {
|
if (err) return cb(err); {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue