File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ import {isFlagEnabled} from 'src/shared/utils/featureFlag'
2828import { useHistory } from 'react-router-dom'
2929import { getErrorMessage } from 'src/utils/api'
3030
31+ // Actions
32+ import { setMe } from 'src/me/actions/creators'
33+ import { MeState } from 'src/me/reducers'
34+
3135export type Props = {
3236 children : JSX . Element
3337}
@@ -158,6 +162,16 @@ export const UserAccountProvider: FC<Props> = React.memo(({children}) => {
158162 // change the name, and reset the active accts:
159163 userAccounts [ activeIndex ] . name = newName
160164 setUserAccounts ( userAccounts )
165+
166+ if (
167+ isFlagEnabled ( 'multiAccount' ) &&
168+ isFlagEnabled ( 'avatarNameForMultiAccountFix' )
169+ ) {
170+ const name = resp . data . name
171+ const id = resp . data . id . toString ( )
172+ // update the state
173+ dispatch ( setMe ( { name, id} as MeState ) )
174+ }
161175 }
162176 } catch ( error ) {
163177 dispatch ( notify ( accountRenameError ( oldName ) ) )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import {Dispatch} from 'react'
55
66// API
77import { getMe as apiGetApiMe } from 'src/client'
8- import { getMe as apiGetQuartzMe } from 'src/client/unityRoutes'
8+ import { getAccounts , getMe as apiGetQuartzMe } from 'src/client/unityRoutes'
99// Utils
1010import { gaEvent , updateReportingContext } from 'src/cloud/utils/reporting'
1111import { isFlagEnabled } from 'src/shared/utils/featureFlag'
@@ -28,12 +28,27 @@ export const getMe = () => async (
2828 getState : GetState
2929) => {
3030 try {
31- const resp = await apiGetApiMe ( { } )
31+ let user
3232
33- if ( resp . status !== 200 ) {
34- throw new Error ( resp . data . message )
33+ if (
34+ isFlagEnabled ( 'multiAccount' ) &&
35+ isFlagEnabled ( 'avatarNameForMultiAccountFix' )
36+ ) {
37+ const resp = await getAccounts ( { } )
38+
39+ if ( resp . status !== 200 ) {
40+ throw new Error ( resp . data . message )
41+ }
42+ user = resp . data . find ( account => account . isActive )
43+ } else {
44+ const resp = await apiGetApiMe ( { } )
45+
46+ if ( resp . status !== 200 ) {
47+ throw new Error ( resp . data . message )
48+ }
49+ user = resp . data
3550 }
36- const user = resp . data
51+
3752 updateReportingContext ( { userID : user . id , userEmail : user . name } )
3853
3954 gaEvent ( 'cloudAppUserDataReady' , {
You can’t perform that action at this time.
0 commit comments