From e60fb1dfd77609c21689dc5d3d0ba001229fbed4 Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Tue, 13 Oct 2015 11:31:57 -0400
Subject: Fixing user settings dialog so it desn't ask you to check your email
 unless you changed it

---
 .../user_settings/user_settings_general.jsx          | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'web/react/components/user_settings/user_settings_general.jsx')

diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx
index c23c61948..ac3a2e37b 100644
--- a/web/react/components/user_settings/user_settings_general.jsx
+++ b/web/react/components/user_settings/user_settings_general.jsx
@@ -59,7 +59,7 @@ export default class UserSettingsGeneralTab extends React.Component {
 
         user.username = username;
 
-        this.submitUser(user);
+        this.submitUser(user, false);
     }
     submitNickname(e) {
         e.preventDefault();
@@ -74,7 +74,7 @@ export default class UserSettingsGeneralTab extends React.Component {
 
         user.nickname = nickname;
 
-        this.submitUser(user);
+        this.submitUser(user, false);
     }
     submitName(e) {
         e.preventDefault();
@@ -91,7 +91,7 @@ export default class UserSettingsGeneralTab extends React.Component {
         user.first_name = firstName;
         user.last_name = lastName;
 
-        this.submitUser(user);
+        this.submitUser(user, false);
     }
     submitEmail(e) {
         e.preventDefault();
@@ -115,22 +115,22 @@ export default class UserSettingsGeneralTab extends React.Component {
         }
 
         user.email = email;
-        this.submitUser(user);
+        this.submitUser(user, true);
     }
-    submitUser(user) {
+    submitUser(user, emailUpdated) {
         client.updateUser(user,
-            function updateSuccess() {
+            () => {
                 this.updateSection('');
                 AsyncClient.getMe();
-                const verificationEnabled = global.window.config.SendEmailNotifications === 'true' && global.window.config.RequireEmailVerification === 'true';
+                const verificationEnabled = global.window.config.SendEmailNotifications === 'true' && global.window.config.RequireEmailVerification === 'true' && emailUpdated;
 
                 if (verificationEnabled) {
                     ErrorStore.storeLastError({message: 'Check your email at ' + user.email + ' to verify the address.'});
                     ErrorStore.emitChange();
                     this.setState({emailChangeInProgress: true});
                 }
-            }.bind(this),
-            function updateFailure(err) {
+            },
+            (err) => {
                 var state = this.setupInitialState(this.props);
                 if (err.message) {
                     state.serverError = err.message;
@@ -138,7 +138,7 @@ export default class UserSettingsGeneralTab extends React.Component {
                     state.serverError = err;
                 }
                 this.setState(state);
-            }.bind(this)
+            }
         );
     }
     submitPicture(e) {
-- 
cgit v1.2.3-1-g7c22

