Merge pull request #5005 from cmgustavo/bug/recent-transactions-01
Fix recent transactions. Show the latest transactions within 6 hours
This commit is contained in:
commit
aa887dfc5e
6 changed files with 56 additions and 127 deletions
|
|
@ -26,7 +26,10 @@ angular.module('copayApp.controllers').controller('activityController',
|
||||||
|
|
||||||
$scope.openNotificationModal = function(n) {
|
$scope.openNotificationModal = function(n) {
|
||||||
if (n.txid) {
|
if (n.txid) {
|
||||||
openTxModal(n);
|
$state.transitionTo('tabs.wallet.tx-details', {
|
||||||
|
txid: n.txid,
|
||||||
|
walletId: n.walletId
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var txp = lodash.find($scope.txps, {
|
var txp = lodash.find($scope.txps, {
|
||||||
id: n.txpId
|
id: n.txpId
|
||||||
|
|
@ -46,35 +49,4 @@ angular.module('copayApp.controllers').controller('activityController',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var openTxModal = function(n) {
|
|
||||||
var wallet = profileService.getWallet(n.walletId);
|
|
||||||
|
|
||||||
ongoingProcess.set('loadingTxInfo', true);
|
|
||||||
walletService.getTx(wallet, n.txid, function(err, tx) {
|
|
||||||
ongoingProcess.set('loadingTxInfo', false);
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
$log.error(err);
|
|
||||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tx) {
|
|
||||||
$log.warn('No tx found');
|
|
||||||
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.wallet = wallet;
|
|
||||||
$scope.btx = lodash.cloneDeep(tx);
|
|
||||||
$state.transitionTo('tabs.wallet.tx-details', {
|
|
||||||
txid: $scope.btx.txid,
|
|
||||||
walletId: $scope.walletId
|
|
||||||
});
|
|
||||||
|
|
||||||
walletService.getTxNote(wallet, n.txid, function(err, note) {
|
|
||||||
if (err) $log.warn('Could not fetch transaction note: ' + err);
|
|
||||||
$scope.btx.note = note;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
wallet = profileService.getWallet(n.walletId);
|
wallet = profileService.getWallet(n.walletId);
|
||||||
|
|
||||||
if (n.txid) {
|
if (n.txid) {
|
||||||
openTxModal(n);
|
$state.transitionTo('tabs.wallet.tx-details', {
|
||||||
|
txid: n.txid,
|
||||||
|
walletId: n.walletId
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var txp = lodash.find($scope.txps, {
|
var txp = lodash.find($scope.txps, {
|
||||||
id: n.txpId
|
id: n.txpId
|
||||||
|
|
@ -65,37 +68,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var openTxModal = function(n) {
|
|
||||||
wallet = profileService.getWallet(n.walletId);
|
|
||||||
|
|
||||||
ongoingProcess.set('loadingTxInfo', true);
|
|
||||||
walletService.getTx(wallet, n.txid, function(err, tx) {
|
|
||||||
ongoingProcess.set('loadingTxInfo', false);
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
$log.error(err);
|
|
||||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tx) {
|
|
||||||
$log.warn('No tx found');
|
|
||||||
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.wallet = wallet;
|
|
||||||
$scope.btx = lodash.cloneDeep(tx);
|
|
||||||
$state.transitionTo('tabs.wallet.tx-details', {
|
|
||||||
txid: $scope.btx.txid,
|
|
||||||
walletId: $scope.walletId
|
|
||||||
});
|
|
||||||
|
|
||||||
walletService.getTxNote(wallet, n.txid, function(err, note) {
|
|
||||||
if (err) $log.warn('Could not fetch transaction note: ' + err);
|
|
||||||
$scope.btx.note = note;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.openWallet = function(wallet) {
|
$scope.openWallet = function(wallet) {
|
||||||
if (!wallet.isComplete()) {
|
if (!wallet.isComplete()) {
|
||||||
return $state.go('tabs.copayers', {
|
return $state.go('tabs.copayers', {
|
||||||
|
|
@ -117,6 +89,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.txpsN = n;
|
$scope.txpsN = n;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$ionicScrollDelegate.resize();
|
$ionicScrollDelegate.resize();
|
||||||
|
$scope.$apply();
|
||||||
}, 100);
|
}, 100);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
@ -141,25 +114,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!$scope.recentTransactionsEnabled) return;
|
|
||||||
$scope.fetchingNotifications = true;
|
|
||||||
profileService.getNotifications({
|
|
||||||
limit: 3
|
|
||||||
}, function(err, n) {
|
|
||||||
if (err) {
|
|
||||||
$log.error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$scope.fetchingNotifications = false;
|
|
||||||
$scope.notifications = n;
|
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
$ionicScrollDelegate.resize();
|
|
||||||
$scope.$apply();
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateWallet = function(wallet) {
|
var updateWallet = function(wallet) {
|
||||||
|
|
@ -171,20 +125,22 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
}
|
}
|
||||||
wallet.status = status;
|
wallet.status = status;
|
||||||
updateTxps();
|
updateTxps();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (!$scope.recentTransactionsEnabled) return;
|
var getNotifications = function() {
|
||||||
|
profileService.getNotifications({
|
||||||
$scope.fetchingNotifications = true;
|
limit: 3
|
||||||
profileService.getNotifications({
|
}, function(err, n) {
|
||||||
limit: 3
|
if (err) {
|
||||||
}, function(err, notifications) {
|
$log.error(err);
|
||||||
$scope.fetchingNotifications = false;
|
return;
|
||||||
if (err) {
|
}
|
||||||
$log.error(err);
|
$scope.notifications = n;
|
||||||
return;
|
$timeout(function() {
|
||||||
}
|
$ionicScrollDelegate.resize();
|
||||||
$scope.notifications = notifications;
|
$scope.$apply();
|
||||||
});
|
}, 100);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -242,7 +198,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
updateAllWallets();
|
updateAllWallets();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.enter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
updateAllWallets();
|
updateAllWallets();
|
||||||
|
|
||||||
addressbookService.list(function(err, ab) {
|
addressbookService.list(function(err, ab) {
|
||||||
|
|
@ -254,11 +210,13 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||||
var wallet = profileService.getWallet(walletId);
|
var wallet = profileService.getWallet(walletId);
|
||||||
updateWallet(wallet);
|
updateWallet(wallet);
|
||||||
|
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||||
}),
|
}),
|
||||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||||
$log.debug('Got action for wallet ' + walletId);
|
$log.debug('Got action for wallet ' + walletId);
|
||||||
var wallet = profileService.getWallet(walletId);
|
var wallet = profileService.getWallet(walletId);
|
||||||
updateWallet(wallet);
|
updateWallet(wallet);
|
||||||
|
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -279,6 +237,8 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.nextStepEnabled = buyAndSellEnabled || amazonEnabled || bitpayCardEnabled;
|
$scope.nextStepEnabled = buyAndSellEnabled || amazonEnabled || bitpayCardEnabled;
|
||||||
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
|
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
|
||||||
|
|
||||||
|
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||||
|
|
||||||
if ($scope.bitpayCardEnabled) bitpayCardCache();
|
if ($scope.bitpayCardEnabled) bitpayCardCache();
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$ionicScrollDelegate.resize();
|
$ionicScrollDelegate.resize();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $ionicHistory, $scope, $stateParams, walletService, lodash, gettextCatalog, profileService, externalLinkService, popupService) {
|
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $ionicHistory, $scope, walletService, lodash, gettextCatalog, profileService, configService, externalLinkService, popupService, ongoingProcess) {
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.title = gettextCatalog.getString('Transaction');
|
$scope.title = gettextCatalog.getString('Transaction');
|
||||||
|
|
@ -9,11 +9,13 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
$scope.copayerId = $scope.wallet.credentials.copayerId;
|
$scope.copayerId = $scope.wallet.credentials.copayerId;
|
||||||
$scope.isShared = $scope.wallet.credentials.n > 1;
|
$scope.isShared = $scope.wallet.credentials.n > 1;
|
||||||
|
|
||||||
walletService.getTx($scope.wallet, $stateParams.txid, function(err, tx) {
|
ongoingProcess.set('loadingTxInfo', true);
|
||||||
|
walletService.getTx($scope.wallet, data.stateParams.txid, function(err, tx) {
|
||||||
|
ongoingProcess.set('loadingTxInfo', false);
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.warn('Could not get tx');
|
$log.warn('Could not get tx');
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
return;
|
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not found'));
|
||||||
}
|
}
|
||||||
$scope.btx = tx;
|
$scope.btx = tx;
|
||||||
if ($scope.btx.action != 'invalid') {
|
if ($scope.btx.action != 'invalid') {
|
||||||
|
|
|
||||||
|
|
@ -795,7 +795,7 @@ angular.module('copayApp.services')
|
||||||
root.getNotifications = function(opts, cb) {
|
root.getNotifications = function(opts, cb) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
var TIME_STAMP = 60 * 60 * 24 * 7;
|
var TIME_STAMP = 60 * 60 * 6;
|
||||||
var MAX = 100;
|
var MAX = 100;
|
||||||
|
|
||||||
var typeFilter = {
|
var typeFilter = {
|
||||||
|
|
@ -861,26 +861,25 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
var finale = shown; // GROUPING DISABLED!
|
var finale = shown; // GROUPING DISABLED!
|
||||||
|
|
||||||
// var finale = [],
|
var finale = [],
|
||||||
// prev;
|
prev;
|
||||||
//
|
|
||||||
//
|
|
||||||
// // Item grouping... DISABLED.
|
// Item grouping... DISABLED.
|
||||||
//
|
|
||||||
// // REMOVE (if we want 1-to-1 notification) ????
|
// REMOVE (if we want 1-to-1 notification) ????
|
||||||
// lodash.each(shown, function(x) {
|
lodash.each(shown, function(x) {
|
||||||
// if (prev && prev.walletId === x.walletId && prev.txpId && prev.txpId === x.txpId && prev.creatorId && prev.creatorId === x.creatorId) {
|
if (prev && prev.walletId === x.walletId && prev.txpId && prev.txpId === x.txpId && prev.creatorId && prev.creatorId === x.creatorId) {
|
||||||
// prev.types.push(x.type);
|
prev.types.push(x.type);
|
||||||
// prev.data = lodash.assign(prev.data, x.data);
|
prev.data = lodash.assign(prev.data, x.data);
|
||||||
// prev.txid = prev.txid || x.txid;
|
prev.txid = prev.txid || x.txid;
|
||||||
// prev.amountStr = prev.amountStr || x.amountStr;
|
prev.amountStr = prev.amountStr || x.amountStr;
|
||||||
// prev.creatorName = prev.creatorName || x.creatorName;
|
prev.creatorName = prev.creatorName || x.creatorName;
|
||||||
// } else {
|
} else {
|
||||||
// finale.push(x);
|
finale.push(x);
|
||||||
// prev = x;
|
prev = x;
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
|
|
||||||
var u = bwcService.getUtils();
|
var u = bwcService.getUtils();
|
||||||
lodash.each(finale, function(x) {
|
lodash.each(finale, function(x) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<ion-view>
|
<ion-view>
|
||||||
<ion-nav-bar class="bar-royal">
|
<ion-nav-bar class="bar-royal">
|
||||||
<ion-nav-title>
|
<ion-nav-title>
|
||||||
{{'Recent Activity'|translate}}
|
{{'Recent Transactions'|translate}}
|
||||||
</ion-nav-title>
|
</ion-nav-title>
|
||||||
<ion-nav-back-button>
|
<ion-nav-back-button>
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<div ng-if="fetchingNotifications" class="updatingHistory">
|
<div ng-if="fetchingNotifications" class="updatingHistory">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
||||||
<div translate>Updating activity. Please stand by</div>
|
<div translate>Updating... Please stand by</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item" ng-show="!notifications[0]">
|
<div class="item" ng-show="!notifications[0]">
|
||||||
<span translate>No recent activity</span>
|
<span translate>No recent transactions</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,6 @@
|
||||||
<span translate>Recent Transactions</span>
|
<span translate>Recent Transactions</span>
|
||||||
<i class="icon bp-arrow-right"></i>
|
<i class="icon bp-arrow-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<span ng-if="fetchingNotifications" class="item text-center">
|
|
||||||
<ion-spinner icon="lines"></ion-spinner>
|
|
||||||
<div translate>Updating activity...</div>
|
|
||||||
</span>
|
|
||||||
<a class="item item-sub activity" ng-repeat="notification in notifications" ng-click="openNotificationModal(notification)">
|
<a class="item item-sub activity" ng-repeat="notification in notifications" ng-click="openNotificationModal(notification)">
|
||||||
<span ng-include="'views/includes/walletActivity.html'"></span>
|
<span ng-include="'views/includes/walletActivity.html'"></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue