From 161eb17e6f40150bcc3aa491e66d7d2970805708 Mon Sep 17 00:00:00 2001
From: matograine <matograine@zaclys.net>
Date: Wed, 12 Jan 2022 20:12:17 +0100
Subject: [PATCH] reformat display of the license reminder

---
 www/js/controllers/wot-controllers.js | 60 +++++++++++----------------
 1 file changed, 24 insertions(+), 36 deletions(-)

diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js
index a7acf6d76..54667445c 100644
--- a/www/js/controllers/wot-controllers.js
+++ b/www/js/controllers/wot-controllers.js
@@ -757,27 +757,14 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $
               return;
             }
 
-            /* MATOGRAINE FROM HERE WE CAN GROUP IN ONE CERTIFY FUNCTION */
-
-            console.log ("formData : " , $scope.formData)
-
-            $scope.commonCertificationVerifications($scope.formData, wallet)
+            if ( ! $scope.commonCertificationVerifications($scope.formData, wallet) ) {
+              return;
+            }
 
-            // Certification checklist before confirmation
+            // Prepare actions after user confirmation
             let answers_are_right = $q.defer();
-            answers_are_right.promise.then(function(cert_status){
-              if (cert_status == "new_cert") {
-                return UIUtils.alert.confirm(
-                  'ACCOUNT.CERTIFICATION_MODAL.SHORT_LICENSE_REMINDER',
-                  'ACCOUNT.CERTIFICATION_MODAL.REMINDER_TITLE',
-                  {
-                    cssClass: 'positive',
-                    okText: 'COMMON.BTN_OK',
-                    okType: 'button-positive'
-                  }
-                )
-              }
-              return true;
+            answers_are_right.promise.then( function (cert_status) {
+              return $scope.showLicenseReminderIfNewCert(cert_status)
             })
             .then(function(confirm){
               if (! confirm) {return}
@@ -865,6 +852,21 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $
     return true;
   }
 
+  $scope.showLicenseReminderIfNewCert = function (cert_status) {
+    if (cert_status == "new_cert") {
+      return UIUtils.alert.confirm(
+        'ACCOUNT.CERTIFICATION_MODAL.SHORT_LICENSE_REMINDER',
+        'ACCOUNT.CERTIFICATION_MODAL.REMINDER_TITLE',
+        {
+          cssClass: 'positive',
+          okText: 'COMMON.BTN_OK',
+          okType: 'button-positive'
+        }
+      )
+    }
+    return true;
+  }
+
   // Select an identity and certify
   $scope.selectAndCertify = function() {
 
@@ -908,26 +910,12 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $
               return;
             }
 
-            /* MATOGRAINE FROM HERE WE CAN GROUP IN ONE CERTIFY FUNCTION */
-            console.log ("identity : " , identity)
-
             $scope.commonCertificationVerifications(identity, wallet)
 
-            // Certification checklist before confirmation
+            // Prepare actions after user confirmation
             let answers_are_right = $q.defer();
-            answers_are_right.promise.then(function(cert_status){
-              if (cert_status == "new_cert") {
-                return UIUtils.alert.confirm(
-                  'ACCOUNT.CERTIFICATION_MODAL.SHORT_LICENSE_REMINDER',
-                  'ACCOUNT.CERTIFICATION_MODAL.REMINDER_TITLE',
-                  {
-                    cssClass: 'positive',
-                    okText: 'COMMON.BTN_OK',
-                    okType: 'button-positive'
-                  }
-                )
-              }
-              return true;
+            answers_are_right.promise.then( function (cert_status) {
+              return $scope.showLicenseReminderIfNewCert(cert_status)
             })
             .then(function(confirm){
               if (! confirm) {return}
-- 
GitLab