Skip to content

Commit

Permalink
Handle error properly in addToTeam / reAddToTeam (keybase#16299)
Browse files Browse the repository at this point in the history
Otherwise, clicking 'Re-Admit' on someone that needs to be followed does nothing.
  • Loading branch information
akalin-keybase authored Feb 28, 2019
1 parent f401e93 commit a260725
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions shared/actions/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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(
Expand All @@ -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) => {
Expand All @@ -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) => {
Expand Down

0 comments on commit a260725

Please sign in to comment.