Authored by 盖剑秋

Fix bug YH-3253. reviewed by redding.

@@ -16,6 +16,7 @@ import { @@ -16,6 +16,7 @@ import {
16 import timeago from '../../utils/timeago'; 16 import timeago from '../../utils/timeago';
17 import HomeService from '../../services/HomeService'; 17 import HomeService from '../../services/HomeService';
18 import SlicedImage from '../../../common/components/SlicedImage'; 18 import SlicedImage from '../../../common/components/SlicedImage';
  19 +import {loginThenSyncUserInfo} from '../user/userActions';
19 20
20 const { 21 const {
21 SUBJECT_CONTENT_REQUEST, 22 SUBJECT_CONTENT_REQUEST,
@@ -93,6 +94,7 @@ export function subjectLikeRequest(sid,json) { @@ -93,6 +94,7 @@ export function subjectLikeRequest(sid,json) {
93 export function subjectLike(sid,postId,forumCode) { 94 export function subjectLike(sid,postId,forumCode) {
94 return (dispatch, getState) => { 95 return (dispatch, getState) => {
95 let {user} = getState(); 96 let {user} = getState();
  97 + let operation = () => {
96 dispatch(subjectLikeRequest(sid,user.profile.avatar)); 98 dispatch(subjectLikeRequest(sid,user.profile.avatar));
97 return new HomeService().postLike(postId, user.profile.uid,forumCode) 99 return new HomeService().postLike(postId, user.profile.uid,forumCode)
98 .then(json => { 100 .then(json => {
@@ -104,6 +106,12 @@ export function subjectLike(sid,postId,forumCode) { @@ -104,6 +106,12 @@ export function subjectLike(sid,postId,forumCode) {
104 .catch(error => { 106 .catch(error => {
105 __DEV__ && console.log(error); 107 __DEV__ && console.log(error);
106 }); 108 });
  109 + }
  110 + if (user.profile.uid !== 0) {
  111 + operation();
  112 + } else {
  113 + dispatch(loginThenSyncUserInfo(operation));
  114 + }
107 }; 115 };
108 } 116 }
109 117
@@ -117,6 +125,7 @@ export function subjectUnlikeRequest(sid,json) { @@ -117,6 +125,7 @@ export function subjectUnlikeRequest(sid,json) {
117 export function subjectUnlike(sid,postId,forumCode) { 125 export function subjectUnlike(sid,postId,forumCode) {
118 return (dispatch, getState) => { 126 return (dispatch, getState) => {
119 let {user} = getState(); 127 let {user} = getState();
  128 + let operation = () => {
120 dispatch(subjectUnlikeRequest(sid,user.profile.avatar)); 129 dispatch(subjectUnlikeRequest(sid,user.profile.avatar));
121 return new HomeService().postUnlike(postId, user.profile.uid, forumCode) 130 return new HomeService().postUnlike(postId, user.profile.uid, forumCode)
122 .then(json => { 131 .then(json => {
@@ -128,6 +137,12 @@ export function subjectUnlike(sid,postId,forumCode) { @@ -128,6 +137,12 @@ export function subjectUnlike(sid,postId,forumCode) {
128 .catch(error => { 137 .catch(error => {
129 __DEV__ && console.log(error); 138 __DEV__ && console.log(error);
130 }); 139 });
  140 + }
  141 + if (user.profile.uid !== 0) {
  142 + operation();
  143 + } else {
  144 + dispatch(loginThenSyncUserInfo(operation));
  145 + }
131 }; 146 };
132 } 147 }
133 148