From a260725e8c45ae94a8e4e92b114b6e933e5d6092 Mon Sep 17 00:00:00 2001 From: Fred Akalin Date: Thu, 28 Feb 2019 15:07:28 -0800 Subject: [PATCH] Handle error properly in addToTeam / reAddToTeam (#16299) Otherwise, clicking 'Re-Admit' on someone that needs to be followed does nothing. --- shared/actions/teams.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/shared/actions/teams.js b/shared/actions/teams.js index 66e7cf9d9b3d..e5a03bb02236 100644 --- a/shared/actions/teams.js +++ b/shared/actions/teams.js @@ -21,6 +21,7 @@ import * as NotificationsGen from './notifications-gen' import * as ConfigGen from './config-gen' import * as Chat2Gen from './chat2-gen' import * as GregorGen from './gregor-gen' +import * as TrackerGen from './tracker-gen' import {uploadAvatarWaitingKey} from '../constants/profile' import {isMobile} from '../constants/platform' import {chatTab, teamsTab} from '../constants/tabs' @@ -305,6 +306,23 @@ const addToTeamWaitingKeys = (teamname, username) => [ Constants.addMemberWaitingKey(teamname, username), ] +const addReAddErrorHandler = (username, e) => { + // identify error + if (e.code === RPCTypes.constantsStatusCode.scidentifysummaryerror) { + if (isMobile) { + // show profile card on mobile + return ProfileGen.createShowUserProfile({username}) + } else { + // otherwise show tracker popup + return TrackerGen.createGetProfile({ + forceDisplay: true, + ignoreCache: true, + username, + }) + } + } +} + const addToTeam = (_, action) => { const {teamname, username, role, sendChatNotification} = action.payload return RPCTypes.teamsTeamAddMemberRpcPromise( @@ -318,15 +336,7 @@ const addToTeam = (_, action) => { addToTeamWaitingKeys(teamname, username) ) .then(() => {}) - .catch(e => { - // identify error - if (e.code === RPCTypes.constantsStatusCode.scidentifysummaryerror) { - if (isMobile) { - // show profile card on mobile - return ProfileGen.createShowUserProfile({username}) - } - } - }) + .catch(e => addReAddErrorHandler(username, e)) } const reAddToTeam = (state, action) => { @@ -343,15 +353,7 @@ const reAddToTeam = (state, action) => { addToTeamWaitingKeys(teamname, username) ) .then(() => {}) - .catch(e => { - // identify error - if (e.code === RPCTypes.constantsStatusCode.scidentifysummaryerror) { - if (isMobile) { - // show profile card on mobile - return ProfileGen.createShowUserProfile({username}) - } - } - }) + .catch(e => addReAddErrorHandler(username, e)) } const editDescription = (_, action) => {