Fix bug YH-3253. reviewed by redding.
Showing
1 changed file
with
37 additions
and
22 deletions
@@ -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,17 +94,24 @@ export function subjectLikeRequest(sid,json) { | @@ -93,17 +94,24 @@ 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(); |
96 | - dispatch(subjectLikeRequest(sid,user.profile.avatar)); | ||
97 | - return new HomeService().postLike(postId, user.profile.uid,forumCode) | ||
98 | - .then(json => { | ||
99 | - dispatch({ | ||
100 | - type: SUBJECT_LIKE_SUCCESS | ||
101 | - }) | ||
102 | - __DEV__ && console.log(json); | ||
103 | - }) | ||
104 | - .catch(error => { | ||
105 | - __DEV__ && console.log(error); | ||
106 | - }); | 97 | + let operation = () => { |
98 | + dispatch(subjectLikeRequest(sid,user.profile.avatar)); | ||
99 | + return new HomeService().postLike(postId, user.profile.uid,forumCode) | ||
100 | + .then(json => { | ||
101 | + dispatch({ | ||
102 | + type: SUBJECT_LIKE_SUCCESS | ||
103 | + }) | ||
104 | + __DEV__ && console.log(json); | ||
105 | + }) | ||
106 | + .catch(error => { | ||
107 | + __DEV__ && console.log(error); | ||
108 | + }); | ||
109 | + } | ||
110 | + if (user.profile.uid !== 0) { | ||
111 | + operation(); | ||
112 | + } else { | ||
113 | + dispatch(loginThenSyncUserInfo(operation)); | ||
114 | + } | ||
107 | }; | 115 | }; |
108 | } | 116 | } |
109 | 117 | ||
@@ -117,17 +125,24 @@ export function subjectUnlikeRequest(sid,json) { | @@ -117,17 +125,24 @@ 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(); |
120 | - dispatch(subjectUnlikeRequest(sid,user.profile.avatar)); | ||
121 | - return new HomeService().postUnlike(postId, user.profile.uid, forumCode) | ||
122 | - .then(json => { | ||
123 | - dispatch({ | ||
124 | - type: UBJECT_UNLIKE_SUCCESS | ||
125 | - }) | ||
126 | - __DEV__ && console.log(json); | ||
127 | - }) | ||
128 | - .catch(error => { | ||
129 | - __DEV__ && console.log(error); | ||
130 | - }); | 128 | + let operation = () => { |
129 | + dispatch(subjectUnlikeRequest(sid,user.profile.avatar)); | ||
130 | + return new HomeService().postUnlike(postId, user.profile.uid, forumCode) | ||
131 | + .then(json => { | ||
132 | + dispatch({ | ||
133 | + type: UBJECT_UNLIKE_SUCCESS | ||
134 | + }) | ||
135 | + __DEV__ && console.log(json); | ||
136 | + }) | ||
137 | + .catch(error => { | ||
138 | + __DEV__ && console.log(error); | ||
139 | + }); | ||
140 | + } | ||
141 | + if (user.profile.uid !== 0) { | ||
142 | + operation(); | ||
143 | + } else { | ||
144 | + dispatch(loginThenSyncUserInfo(operation)); | ||
145 | + } | ||
131 | }; | 146 | }; |
132 | } | 147 | } |
133 | 148 |
-
Please register or login to post a comment