diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 2ea90ed839205ed58575069c7656662e40eec858..ac5c0aa9421771ec21dca0628a3e72e98c163b9a 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -280,7 +280,7 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state, */ $scope.renewMembership = function(confirm) { - if (!$scope.formData.isMember) { + if (!$scope.formData.isMember && !$scope.formData.requirements.wasMember) { return UIUtils.alert.error("ERROR.ONLY_MEMBER_CAN_EXECUTE_THIS_ACTION"); } if (!confirm && !$scope.formData.requirements.needRenew) { diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 54d0c008770ddf21ed68a9f1c41147302b2e4279..18ca4cc45c9469d206fceeca308c61ab1be0c329 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -248,7 +248,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser if (!data.loaded) return undefined; // undefined if not full loaded return !data.pubkey || (!data.isMember && - (!data.requirements || !data.requirements.pendingMembership) && + (!data.requirements || (!data.requirements.pendingMembership && !data.requirements.wasMember)) && !data.tx.history.length && !data.tx.pendings.length); }, @@ -371,6 +371,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser canMembershipOut: false, needRenew: false, pendingMembership: false, + wasMember: false, certificationCount: 0, needCertifications: false, needCertificationCount: 0, @@ -415,6 +416,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser score += (100000000 * (idty.membershipPendingExpiresIn > 0 ? 1 : 0)); score += (10000000 * (!idty.expired ? 1 : 0)); score += (1000000 * (!idty.outdistanced ? 1 : 0)); + score += (100000 * (idty.wasMember ? 1 : 0)); var certCount = !idty.expired && idty.certifications ? idty.certifications.length : 0; score += (1 * (certCount ? certCount : 0)); score += (1 * (!certCount && idty.membershipPendingExpiresIn > 0 ? idty.membershipPendingExpiresIn/1000 : 0)); @@ -428,10 +430,13 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser // Compute useful fields idty.needSelf = false; - idty.needMembership = (idty.membershipExpiresIn <= 0 && idty.membershipPendingExpiresIn <= 0 ); + idty.wasMember = angular.isDefined(idty.wasMember) ? idty.wasMember : false; // Compat with Duniter 0.9 + idty.needMembership = (idty.membershipExpiresIn <= 0 && idty.membershipPendingExpiresIn <= 0 && !idty.wasMember); idty.needRenew = (!idty.needMembership && idty.membershipExpiresIn <= csSettings.data.timeWarningExpireMembership && - idty.membershipPendingExpiresIn <= 0); + idty.membershipPendingExpiresIn <= 0) || + (idty.wasMember && idty.membershipExpiresIn === 0 && + idty.membershipPendingExpiresIn === 0); idty.canMembershipOut = (idty.membershipExpiresIn > 0); idty.pendingMembership = (idty.membershipExpiresIn <= 0 && idty.membershipPendingExpiresIn > 0); idty.certificationCount = (idty.certifications) ? idty.certifications.length : 0;