Skip to content

Commit

Permalink
fix: profile info is modified and saved,no changed on page edp963#1231
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanhan committed Nov 4, 2019
1 parent f8dab7c commit c509e39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 2 additions & 4 deletions webapp/app/containers/App/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,10 @@ export function uploadAvatarSuccess (path) {
}
}

export function updateProfileSuccess (user) {
export function updateProfileSuccess (payload) {
return {
type: UPDATE_PROFILE_SUCCESS,
payload: {
user
}
payload
}
}

Expand Down
9 changes: 8 additions & 1 deletion webapp/app/containers/App/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
LOAD_DOWNLOAD_LIST,
LOAD_DOWNLOAD_LIST_SUCCESS,
LOAD_DOWNLOAD_LIST_FAILURE,
DOWNLOAD_FILE_SUCCESS
DOWNLOAD_FILE_SUCCESS,
UPDATE_PROFILE_SUCCESS
} from './constants'
import { fromJS } from 'immutable'
import { DownloadStatus } from './types'
Expand Down Expand Up @@ -75,6 +76,12 @@ function appReducer (state = initialState, action) {
localStorage.setItem('loginUser', JSON.stringify(newLoginUser))
return state
.set('loginUser', newLoginUser)
case UPDATE_PROFILE_SUCCESS:
const {id, name, department, description } = payload
const updateUserProfile = {...loginUser, id, name, department, description}
localStorage.setItem('loginUser', JSON.stringify(updateUserProfile))
return state
.set('loginUser', updateUserProfile)
case SHOW_NAVIGATOR:
return state.set('navigator', true)
case HIDE_NAVIGATOR:
Expand Down
1 change: 1 addition & 0 deletions webapp/app/containers/App/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export function* updateProfile (action): IterableIterator<any> {
department
}
})
yield put(updateProfileSuccess(asyncData && asyncData.header && asyncData.header.code === 200 ? {id, name, description, department} : {}))
resolve(asyncData)
} catch (err) {
yield put(updateProfileError())
Expand Down

0 comments on commit c509e39

Please sign in to comment.