Fix for reordering wallets on new address creation

This commit is contained in:
ssotomayor 2014-10-30 18:13:47 -03:00
commit 92869a9ce5

View file

@ -1,19 +1,23 @@
'use strict';
angular.module('copayApp.controllers').controller('ReceiveController',
function($scope, $rootScope, $timeout, $modal, controllerUtils) {
function($scope, $rootScope, $timeout, $modal, controllerUtils, notification) {
controllerUtils.redirIfNotComplete();
$scope.loading = false;
$scope.showAll = false;
$scope.isNewAddr = false;
$scope.newAddr = function() {
var w = $rootScope.wallet;
$scope.loading = true;
$scope.isNewAddr = false;
w.generateAddress(null, function() {
$timeout(function() {
controllerUtils.updateAddressList();
$scope.loading = false;
$scope.isNewAddr = true;
notification.info("Info", "New Address was created");
}, 1);
});
};
@ -26,7 +30,7 @@ angular.module('copayApp.controllers').controller('ReceiveController',
$scope.mobileCopy = function(address) {
window.cordova.plugins.clipboard.copy(address);
window.plugins.toast.showShortBottom('Copied to clipboard');
}
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
@ -55,11 +59,13 @@ angular.module('copayApp.controllers').controller('ReceiveController',
$scope.addressList();
};
$scope.limitAddress = function(elements) {
$scope.limitAddress = function(elements, isNewAddr) {
elements = elements.sort(function(a, b) {
return (+a.isChange - +b.isChange);
});
if(!isNewAddr){
elements = elements.sort(function(a, b) {
return (+a.isChange - +b.isChange);
});
}
if (elements.length <= 1 || $scope.showAll) {
return elements;
@ -89,7 +95,7 @@ angular.module('copayApp.controllers').controller('ReceiveController',
'owned': addrinfo.owned
});
}
$scope.addresses = $scope.limitAddress($scope.addresses);
$scope.addresses = $scope.limitAddress($scope.addresses, $scope.isNewAddr);
}
};
}