|
@@ -64,8 +64,6 @@ export function fetchUserFavArticleList() { |
|
@@ -64,8 +64,6 @@ export function fetchUserFavArticleList() { |
64
|
}
|
64
|
}
|
65
|
return new MineGuangService(app.serviceHost).getUserFavArticleList(params)
|
65
|
return new MineGuangService(app.serviceHost).getUserFavArticleList(params)
|
66
|
.then(json => {
|
66
|
.then(json => {
|
67
|
- console.log('------mine guang');
|
|
|
68
|
- console.log(json);
|
|
|
69
|
if (favArticleList && favArticleList.size) {
|
67
|
if (favArticleList && favArticleList.size) {
|
70
|
favArticleList = favArticleList.toJS();
|
68
|
favArticleList = favArticleList.toJS();
|
71
|
}
|
69
|
}
|
|
@@ -75,8 +73,6 @@ export function fetchUserFavArticleList() { |
|
@@ -75,8 +73,6 @@ export function fetchUserFavArticleList() { |
75
|
dispatch(fetchSimpleArticleList(json.data))
|
73
|
dispatch(fetchSimpleArticleList(json.data))
|
76
|
})
|
74
|
})
|
77
|
.catch(error => {
|
75
|
.catch(error => {
|
78
|
- console.log('------error');
|
|
|
79
|
- console.log(error);
|
|
|
80
|
dispatch(fetchUserFavArticleListFailure(error));
|
76
|
dispatch(fetchUserFavArticleListFailure(error));
|
81
|
})
|
77
|
})
|
82
|
}
|
78
|
}
|
|
@@ -112,16 +108,10 @@ export function fetchSimpleArticleList(favArticleList) { |
|
@@ -112,16 +108,10 @@ export function fetchSimpleArticleList(favArticleList) { |
112
|
return new MineGuangService(app.serviceHost).getSimpleArticleList(params)
|
108
|
return new MineGuangService(app.serviceHost).getSimpleArticleList(params)
|
113
|
.then(json => {
|
109
|
.then(json => {
|
114
|
//将请求到的文章相关数据合并到favArticleList
|
110
|
//将请求到的文章相关数据合并到favArticleList
|
115
|
- console.log('------mine guang');
|
|
|
116
|
- console.log(json);
|
|
|
117
|
let newFavArticleList = mergeSimpleArticleToFavList(favArticleList,json.artList);
|
111
|
let newFavArticleList = mergeSimpleArticleToFavList(favArticleList,json.artList);
|
118
|
- console.log('------merged');
|
|
|
119
|
- console.log(newFavArticleList);
|
|
|
120
|
dispatch(updateUserFavArticleList(newFavArticleList));
|
112
|
dispatch(updateUserFavArticleList(newFavArticleList));
|
121
|
})
|
113
|
})
|
122
|
.catch(error => {
|
114
|
.catch(error => {
|
123
|
- console.log('------error');
|
|
|
124
|
- console.log(error);
|
|
|
125
|
})
|
115
|
})
|
126
|
}
|
116
|
}
|
127
|
|
117
|
|
|
@@ -157,28 +147,28 @@ function mergeSimpleArticleToFavList(favArticleList,simpleArticleList) { |
|
@@ -157,28 +147,28 @@ function mergeSimpleArticleToFavList(favArticleList,simpleArticleList) { |
157
|
return favArticleList;
|
147
|
return favArticleList;
|
158
|
}
|
148
|
}
|
159
|
|
149
|
|
160
|
-export function onPressLike(article_id, isLike) {
|
150
|
+export function onPressLike(article_id,rowID) {
|
161
|
return (dispatch, getState) => {
|
151
|
return (dispatch, getState) => {
|
162
|
let {app, mineGuang} = getState();
|
152
|
let {app, mineGuang} = getState();
|
163
|
-
|
|
|
164
|
- let likeRequest = (article_id, uid, isLike) => {
|
|
|
165
|
- // dispatch(likeArticle({article_id, isLike}));
|
|
|
166
|
- //
|
|
|
167
|
- // if (isLike) {
|
|
|
168
|
- // return new ListService(app.serviceHost).setArticleFavorite(article_id, uid)
|
|
|
169
|
- // }else {
|
|
|
170
|
- // return new ListService(app.serviceHost).cancleArticleFavorite(article_id, uid)
|
|
|
171
|
- // }
|
153
|
+ let {userFavArticleList} = mineGuang;
|
|
|
154
|
+ let {favArticleList} = userFavArticleList;
|
|
|
155
|
+ let likeRequest = (article_id, uid) => {
|
|
|
156
|
+ if (!favArticleList || favArticleList.size == 0) {
|
|
|
157
|
+ return;
|
|
|
158
|
+ }
|
|
|
159
|
+ let newFavArticleList = favArticleList.delete(rowID);
|
|
|
160
|
+ dispatch(updateUserFavArticleList(newFavArticleList));
|
|
|
161
|
+ return new MineGuangService(app.serviceHost).cancelFavorite({article_id,uid});
|
172
|
}
|
162
|
}
|
173
|
|
163
|
|
174
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
164
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
175
|
.then(uid => {
|
165
|
.then(uid => {
|
176
|
- likeRequest(article_id, uid, isLike);
|
166
|
+ likeRequest(article_id, uid);
|
177
|
})
|
167
|
})
|
178
|
.catch(error => {
|
168
|
.catch(error => {
|
179
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
169
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
180
|
.then(uid => {
|
170
|
.then(uid => {
|
181
|
- likeRequest(article_id, uid, isLike);
|
171
|
+ likeRequest(article_id, uid);
|
182
|
})
|
172
|
})
|
183
|
.catch(error => {
|
173
|
.catch(error => {
|
184
|
|
174
|
|