Authored by 于良

bug fix http://jira.yoho.cn:8888/browse/YH-2586 review by 阿瑟

... ... @@ -204,7 +204,7 @@ class HomeContainer extends React.Component {
}
_onSaveingTheWorld() {
this.props.actions.goToUser({},this.props.navigationState.name);
this.props.actions.goToUser();
}
render() {
... ...
... ... @@ -54,10 +54,12 @@ export function goToSection(section) {
export function goToUserOrMe(uid) {
return (dispatch, getState) => {
let {user} = getState();
if (uid != 0 && uid == user.profile.uid) {
Actions.User();
dispatch({
type: GO_TO_USER,
});
} else {
Actions.UserThatNotMe();
dispatch({
... ... @@ -68,6 +70,24 @@ export function goToUserOrMe(uid) {
};
}
export function goToUser() {
return (dispatch, getState) => {
let operation = () => {
Actions.User();
return {
type: GO_TO_USER,
};
};
let {user} = getState();
if (user.profile.uid == 0) {
dispatch(loginThenSyncUserInfo(operation));
} else {
dispatch(operation());
}
};
}
export function goToPost(id) {
Actions.SubjectPost();
return {
... ... @@ -258,14 +278,6 @@ export function resetErrorCount() {
};
}
export function goToUser(user, previousScene) {
Actions.User();
return {
type: GO_TO_USER,
payload: {...user, previousScene},
};
}
function parseBNS(json) {
let {resourceList, forumInfo} = json;
let {advertList, textNoticeList} = resourceList;
... ...
... ... @@ -59,6 +59,13 @@ const {
} = require('../../constants/actionTypes').default;
export function goToMessageCenter() {
Actions.MessageCenter();
return {
type: GO_TO_MESSAGE_CENTER,
};
}
export function userDidLogout() {
return {
type: USER_DID_LOGOUT,
... ... @@ -286,13 +293,6 @@ export function reply(ptr = false) {
};
}
export function goToMessageCenter() {
Actions.MessageCenter();
return {
type: GO_TO_MESSAGE_CENTER,
};
}
export function userInfoRequest() {
return {
type: USER_INFO_REQUEST,
... ... @@ -394,8 +394,12 @@ export function loginThenSyncUserInfo(operation=()=>{}) {
return (dispatch, getState) => {
ReactNative.NativeModules.YH_CommunityHelper.login()
.then(uid => {
dispatch(setUid(uid));
dispatch(syncUserWithSSOUid(uid));
/*
* 已在HomeContainer监听了登录成功的事件,
* 故此处可以注释掉了,不再需要手动调用用户信息同步
*/
// dispatch(setUid(uid));
// dispatch(syncUserWithSSOUid(uid));
operation();
})
.catch(error => {
... ...