FIX: Ensure identity is saved before reloading page

FIX: Ensure identity is saved before reloading page

diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
index 8c2dd04..bf340c1 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
@@ -100,10 +100,6 @@ export default {
 
       const saveDbIdentityPromise = identityPromise
         .then(identity => saveDbIdentity(identity))
-        .then(() => {
-          this.appEvents.trigger("encrypt:status-changed");
-          reload();
-        })
         .finally(() => {
           this.setProperties({
             passphrase: "",
@@ -113,7 +109,12 @@ export default {
           });
         });
 
-      return Promise.all([saveIdentityPromise, saveDbIdentityPromise]);
+      return Promise.all([saveIdentityPromise, saveDbIdentityPromise]).then(
+        () => {
+          this.appEvents.trigger("encrypt:status-changed");
+          reload();
+        }
+      );
     },
 
     activateEncrypt() {
diff --git a/assets/javascripts/discourse/controllers/reset-key-pair.js.es6 b/assets/javascripts/discourse/controllers/reset-key-pair.js.es6
index e1784c6..5d2814f 100644
--- a/assets/javascripts/discourse/controllers/reset-key-pair.js.es6
+++ b/assets/javascripts/discourse/controllers/reset-key-pair.js.es6
@@ -21,7 +21,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
           everything: this.everything
         }
       })
-        .then(() => reload())
+        .then(() => {
+          this.appEvents.trigger("encrypt:status-changed");
+          reload();
+        })
         .catch(popupAjaxError);
     }
   }

GitHub sha: ec73bdb1