@@ -277,52 +277,54 @@ export const updateCurrentUser = (
277
277
async function continueSettingsUpdate ( ) {
278
278
const editingOtherUser = currentUser . loggedIn && currentUser . id != updatedUser . id ;
279
279
280
- await dispatch ( requestCurrentUser ( ) as any ) ;
280
+ try {
281
+ dispatch ( { type : ACTION_TYPE . USER_DETAILS_UPDATE_REQUEST } ) ;
282
+ const currentUser = await api . users . updateCurrent ( updatedUser , updatedUserPreferences , passwordCurrent , userContexts ) ;
283
+ dispatch ( { type : ACTION_TYPE . USER_DETAILS_UPDATE_RESPONSE_SUCCESS , user : currentUser . data } ) ;
281
284
282
- if ( ! editingOtherUser ) {
283
- // Invalidate tagged caches that are dependent on the current user's settings
284
- dispatch ( questionsApi . util . invalidateTags ( [ 'CanAttemptQuestionType' ] ) as any ) ;
285
- }
285
+ await dispatch ( requestCurrentUser ( ) as any ) ;
286
286
287
- const isFirstLogin = isFirstLoginInPersistence ( ) || false ;
288
- if ( isFirstLogin ) {
289
- persistence . session . remove ( KEY . FIRST_LOGIN ) ;
290
- if ( redirect ) {
291
- history . push ( persistence . pop ( KEY . AFTER_AUTH_PATH ) || '/account' , { firstLogin : isFirstLogin } ) ;
287
+ if ( ! editingOtherUser ) {
288
+ // Invalidate tagged caches that are dependent on the current user's settings
289
+ dispatch ( questionsApi . util . invalidateTags ( [ 'CanAttemptQuestionType' ] ) as any ) ;
292
290
}
293
- } else if ( ! editingOtherUser ) {
294
- dispatch ( showToast ( {
295
- title : "Account settings updated" ,
296
- body : "Your account settings were updated successfully." ,
297
- color : "success" ,
298
- timeout : 5000 ,
299
- closable : false ,
300
- } ) as any ) ;
301
- } else if ( editingOtherUser ) {
302
- redirect && history . push ( '/' ) ;
303
- dispatch ( showToast ( {
304
- title : "Account settings updated" ,
305
- body : "The user's account settings were updated successfully." ,
306
- color : "success" ,
307
- timeout : 5000 ,
308
- closable : false ,
309
- } ) as any ) ;
291
+
292
+ const isFirstLogin = isFirstLoginInPersistence ( ) || false ;
293
+ if ( isFirstLogin ) {
294
+ persistence . session . remove ( KEY . FIRST_LOGIN ) ;
295
+ if ( redirect ) {
296
+ history . push ( persistence . pop ( KEY . AFTER_AUTH_PATH ) || '/account' , { firstLogin : isFirstLogin } ) ;
297
+ }
298
+ } else if ( ! editingOtherUser ) {
299
+ dispatch ( showToast ( {
300
+ title : "Account settings updated" ,
301
+ body : "Your account settings were updated successfully." ,
302
+ color : "success" ,
303
+ timeout : 5000 ,
304
+ closable : false ,
305
+ } ) as any ) ;
306
+ } else if ( editingOtherUser ) {
307
+ if ( redirect ) {
308
+ history . push ( '/' ) ;
309
+ }
310
+ dispatch ( showToast ( {
311
+ title : "Account settings updated" ,
312
+ body : "The user's account settings were updated successfully." ,
313
+ color : "success" ,
314
+ timeout : 5000 ,
315
+ closable : false ,
316
+ } ) as any ) ;
317
+ }
318
+ } catch ( e : any ) {
319
+ dispatch ( { type : ACTION_TYPE . USER_DETAILS_UPDATE_RESPONSE_FAILURE , errorMessage : extractMessage ( e ) } ) ;
310
320
}
311
321
}
312
322
313
323
// Confirm email change
314
324
if ( currentUser . loggedIn && currentUser . id == updatedUser . id && currentUser . email !== updatedUser . email ) {
315
325
showEmailChangeModal ( ) ;
316
326
} else {
317
- try {
318
- dispatch ( { type : ACTION_TYPE . USER_DETAILS_UPDATE_REQUEST } ) ;
319
- const currentUser = await api . users . updateCurrent ( updatedUser , updatedUserPreferences , passwordCurrent , userContexts ) ;
320
- dispatch ( { type : ACTION_TYPE . USER_DETAILS_UPDATE_RESPONSE_SUCCESS , user : currentUser . data } ) ;
321
- continueSettingsUpdate ( ) ;
322
- }
323
- catch ( e : any ) {
324
- dispatch ( { type : ACTION_TYPE . USER_DETAILS_UPDATE_RESPONSE_FAILURE , errorMessage : extractMessage ( e ) } ) ;
325
- }
327
+ continueSettingsUpdate ( ) ;
326
328
}
327
329
} ;
328
330
0 commit comments