...
|
...
|
@@ -30,20 +30,45 @@ const { |
|
|
SUBJECT_REPLY_FAILURE,
|
|
|
SUBJECT_REPLY_UPDATE,
|
|
|
|
|
|
GO_TO_LIKE_LIST,
|
|
|
SUBJECT_DO_NOTHING,
|
|
|
SUBJECT_LIKE_SUCCESS,
|
|
|
SUBJECT_UNLIKE_SUCCESS,
|
|
|
SUBJECT_LIKE_REQUEST,
|
|
|
SUBJECT_UNLIKE_REQUEST,
|
|
|
|
|
|
SUBJECT_DEL_COMMENT_REQUEST,
|
|
|
SUBJECT_DEL_COMMENT_SUCCESS,
|
|
|
SUBJECT_DEL_COMMENT_FAILURE,
|
|
|
SUBJECT_SHARE_DATA_PREPARED,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
export function goToLikeList(postId, likeCount) {
|
|
|
Actions.LikeList({title: `共有${likeCount}个赞`});
|
|
|
export function deleteComment(sid, id) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {subject, user} = getState();
|
|
|
let uid = user.profile.uid;
|
|
|
let item = subject.items.get(sid);
|
|
|
let commentsArray = item.commentList.toJS();
|
|
|
let newArray = [];
|
|
|
for (var i = 0; i < commentsArray.length; i++) {
|
|
|
let commentItem = commentsArray[i];
|
|
|
if (commentItem.commentId != id) {
|
|
|
newArray.push(commentItem);
|
|
|
}
|
|
|
}
|
|
|
dispatch(commitDeleteComment(sid, newArray));
|
|
|
new PostingService().deleteComment(id, uid).then(json => {
|
|
|
Alert.alert('提示','删除成功');
|
|
|
}).catch(error => {
|
|
|
Alert.alert('提示','删除成功');
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commitDeleteComment(sid, newArray) {
|
|
|
return {
|
|
|
type: GO_TO_LIKE_LIST,
|
|
|
payload: postId,
|
|
|
};
|
|
|
type: SUBJECT_DEL_COMMENT_REQUEST,
|
|
|
payload: {sid, newArray},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function subjectLikeRequest(sid,json) {
|
...
|
...
|
@@ -55,8 +80,8 @@ export function subjectLikeRequest(sid,json) { |
|
|
|
|
|
export function subjectLike(sid,postId) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(subjectLikeRequest(sid,postId));
|
|
|
let {user} = getState();
|
|
|
dispatch(subjectLikeRequest(sid,user.profile.avatar));
|
|
|
return new HomeService().postLike(postId, user.profile.uid)
|
|
|
.then(json => {
|
|
|
dispatch({
|
...
|
...
|
@@ -79,8 +104,8 @@ export function subjectUnlikeRequest(sid,json) { |
|
|
|
|
|
export function subjectUnlike(sid,postId) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(subjectUnlikeRequest(sid,postId));
|
|
|
let {user} = getState();
|
|
|
dispatch(subjectUnlikeRequest(sid,user.profile.avatar));
|
|
|
return new HomeService().postUnlike(postId, user.profile.uid)
|
|
|
.then(json => {
|
|
|
dispatch({
|
...
|
...
|
@@ -113,18 +138,14 @@ export function onRightPressed(sid) { |
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
let params = {
|
|
|
postsId: item.id,
|
|
|
appType: 1,
|
|
|
}
|
|
|
new PostingService().getShareUrl(params).then(json => {
|
|
|
let {subject} = getState();
|
|
|
let item = subject.items.get(sid);
|
|
|
let {subject} = getState();
|
|
|
let item = subject.items.get(sid);
|
|
|
if (item.shareUrl.length) {
|
|
|
let blockAry = item.blocks.toJS();
|
|
|
let content = '';
|
|
|
let contentStr = '';
|
|
|
for (var i = 0; i < blockAry.length; i++) {
|
|
|
if (blockAry[i].templateKey == 'text') {
|
|
|
content = blockAry[i].contentData||'';
|
|
|
contentStr = blockAry[i].contentData||'';
|
|
|
break;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -145,21 +166,43 @@ export function onRightPressed(sid) { |
|
|
.replace('{height}', '320');
|
|
|
}
|
|
|
}
|
|
|
let title = item.postsTitle||contentStr||'潮流社区';
|
|
|
let content = item.authorInfo.nickName||''+'在潮流社区发布的潮流主题帖很赞,快来看看!'
|
|
|
let shareInfo = {
|
|
|
title: subject.postsTitle||'',
|
|
|
title,
|
|
|
content,
|
|
|
'picUrl':newSrc,
|
|
|
linkUrl: json.shareUrl,
|
|
|
picUrl:newSrc,
|
|
|
linkUrl: item.shareUrl,
|
|
|
}
|
|
|
dispatch(doShare(sid,shareInfo));
|
|
|
}).catch(error => {
|
|
|
} else {
|
|
|
Alert.alert('提示','获取分享信息失败');
|
|
|
})
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function prepareShareData(sid, postId) {
|
|
|
return dispatch => {
|
|
|
let params = {
|
|
|
postsId: postId,
|
|
|
appType: 1,
|
|
|
};
|
|
|
new PostingService().getShareUrl(params).then(json => {
|
|
|
dispatch(shareDataPrepared(sid, json.shareUrl));
|
|
|
}).catch(error => {
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function shareDataPrepared(sid, shareUrl) {
|
|
|
return {
|
|
|
type: SUBJECT_SHARE_DATA_PREPARED,
|
|
|
payload: {sid, shareUrl},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function onRight(sid) {
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING',
|
...
|
...
|
@@ -168,10 +211,7 @@ export function onRight(sid) { |
|
|
}
|
|
|
|
|
|
export function doShare(sid,shareInfo) {
|
|
|
|
|
|
console.log(shareInfo);
|
|
|
NativeModules.YH_CommunityHelper.showShare(shareInfo);
|
|
|
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING',
|
|
|
payload: sid,
|
...
|
...
|
@@ -186,13 +226,10 @@ export function doDelete(sid,postsId) { |
|
|
Actions.pop();
|
|
|
new PostingService().deletePost(postsId).then(json => {
|
|
|
Alert.alert('提示','删除成功');
|
|
|
console.log('......del success ....... ' + json);
|
|
|
}).catch(error => {
|
|
|
Alert.alert('提示','删除失败');
|
|
|
console.log('....error.......... ' +error);
|
|
|
})
|
|
|
}}]);
|
|
|
console.log('deleted.............');
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING',
|
|
|
payload:sid,
|
...
|
...
|
@@ -346,7 +383,7 @@ export function commentsRequestSuccess(sid,json) { |
|
|
}
|
|
|
let newObj={
|
|
|
commentId: id||'',
|
|
|
cidTo: postInfo.authorUid||'',
|
|
|
cidTo: reply.uid||'',
|
|
|
timeago: timeagoStr||'',
|
|
|
headIcon: reply.headIcon||'',
|
|
|
nickName: reply.nickName||'',
|
...
|
...
|
@@ -364,6 +401,10 @@ export function commentsRequestSuccess(sid,json) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
function createFakeComment() {
|
|
|
|
|
|
}
|
|
|
|
|
|
export function commentsRequestFailure(sid,error) {
|
|
|
return {
|
|
|
type: SUBJECT_COMMENTS_FAILURE,
|
...
|
...
|
@@ -378,7 +419,7 @@ export function assetsSelected(sid,assets) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentWithParams(sid,params) {
|
|
|
export function commentWithParams(sid,params, newList) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(startComment(sid));
|
|
|
let {subject} = getState();
|
...
|
...
|
@@ -390,13 +431,13 @@ export function commentWithParams(sid,params) { |
|
|
|
|
|
new PostingService().uploadImageAsset(asset)
|
|
|
.then(response => {
|
|
|
dispatch(updateCommentProgress(sid,response, params));
|
|
|
dispatch(updateCommentProgress(sid,response, params, newList));
|
|
|
}).catch(error => {
|
|
|
dispatch(commentFail(sid,error));
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
dispatch(commitComment(sid,params));
|
|
|
dispatch(commitComment(sid,params, newList));
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -408,18 +449,21 @@ export function startComment(sid) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commitComment(sid,params) {
|
|
|
export function commitComment(sid,params, newList) {
|
|
|
return dispatch => {
|
|
|
new PostingService().commitReply(params)
|
|
|
.then(response => {
|
|
|
dispatch(commentSuccess(sid,response));
|
|
|
Alert.alert('提示','回复成功');
|
|
|
newList[0].commentId = response.id;
|
|
|
dispatch(commentSuccess(sid,response, newList));
|
|
|
}).catch(error => {
|
|
|
Alert.alert('提示','回复失败');
|
|
|
dispatch(commentFail(sid,error));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function updateCommentProgress(sid, url, params) {
|
|
|
export function updateCommentProgress(sid, url, params, newList) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {subject} = getState();
|
|
|
let item = subject.items.get(sid);
|
...
|
...
|
@@ -440,7 +484,7 @@ export function updateCommentProgress(sid, url, params) { |
|
|
...params,
|
|
|
images: item.assetsUrlStr,
|
|
|
}
|
|
|
dispatch(commitComment(sid,newParams));
|
|
|
dispatch(commitComment(sid,newParams, newList));
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -453,10 +497,10 @@ export function commentImageStateChanged(payloadData) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentSuccess(sid,json) {
|
|
|
export function commentSuccess(sid,json, newList) {
|
|
|
return {
|
|
|
type: SUBJECT_REPLY_SUCCESS,
|
|
|
payload: {sid, json},
|
|
|
payload: {sid, json, newList},
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|