Authored by 盖剑秋

Fix bug YH-3253. reviewed by redding.

... ... @@ -16,6 +16,7 @@ import {
import timeago from '../../utils/timeago';
import HomeService from '../../services/HomeService';
import SlicedImage from '../../../common/components/SlicedImage';
import {loginThenSyncUserInfo} from '../user/userActions';
const {
SUBJECT_CONTENT_REQUEST,
... ... @@ -93,17 +94,24 @@ export function subjectLikeRequest(sid,json) {
export function subjectLike(sid,postId,forumCode) {
return (dispatch, getState) => {
let {user} = getState();
dispatch(subjectLikeRequest(sid,user.profile.avatar));
return new HomeService().postLike(postId, user.profile.uid,forumCode)
.then(json => {
dispatch({
type: SUBJECT_LIKE_SUCCESS
})
__DEV__ && console.log(json);
})
.catch(error => {
__DEV__ && console.log(error);
});
let operation = () => {
dispatch(subjectLikeRequest(sid,user.profile.avatar));
return new HomeService().postLike(postId, user.profile.uid,forumCode)
.then(json => {
dispatch({
type: SUBJECT_LIKE_SUCCESS
})
__DEV__ && console.log(json);
})
.catch(error => {
__DEV__ && console.log(error);
});
}
if (user.profile.uid !== 0) {
operation();
} else {
dispatch(loginThenSyncUserInfo(operation));
}
};
}
... ... @@ -117,17 +125,24 @@ export function subjectUnlikeRequest(sid,json) {
export function subjectUnlike(sid,postId,forumCode) {
return (dispatch, getState) => {
let {user} = getState();
dispatch(subjectUnlikeRequest(sid,user.profile.avatar));
return new HomeService().postUnlike(postId, user.profile.uid, forumCode)
.then(json => {
dispatch({
type: UBJECT_UNLIKE_SUCCESS
})
__DEV__ && console.log(json);
})
.catch(error => {
__DEV__ && console.log(error);
});
let operation = () => {
dispatch(subjectUnlikeRequest(sid,user.profile.avatar));
return new HomeService().postUnlike(postId, user.profile.uid, forumCode)
.then(json => {
dispatch({
type: UBJECT_UNLIKE_SUCCESS
})
__DEV__ && console.log(json);
})
.catch(error => {
__DEV__ && console.log(error);
});
}
if (user.profile.uid !== 0) {
operation();
} else {
dispatch(loginThenSyncUserInfo(operation));
}
};
}
... ...