...
|
...
|
@@ -46,16 +46,16 @@ export function goToLikeList(postId, likeCount) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function subjectLikeRequest(json) {
|
|
|
export function subjectLikeRequest(sid,json) {
|
|
|
return {
|
|
|
type: SUBJECT_LIKE_REQUEST,
|
|
|
payload: json
|
|
|
payload: {sid,json}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function subjectLike(postId) {
|
|
|
export function subjectLike(sid,postId) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(subjectLikeRequest(postId));
|
|
|
dispatch(subjectLikeRequest(sid,postId));
|
|
|
let {user} = getState();
|
|
|
return new HomeService().postLike(postId, user.profile.uid)
|
|
|
.then(json => {
|
...
|
...
|
@@ -70,16 +70,16 @@ export function subjectLike(postId) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function subjectUnlikeRequest(json) {
|
|
|
export function subjectUnlikeRequest(sid,json) {
|
|
|
return {
|
|
|
type: SUBJECT_UNLIKE_REQUEST,
|
|
|
payload: json
|
|
|
payload: {sid,json}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function subjectUnlike(postId) {
|
|
|
export function subjectUnlike(sid,postId) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(subjectUnlikeRequest(postId));
|
|
|
dispatch(subjectUnlikeRequest(sid,postId));
|
|
|
let {user} = getState();
|
|
|
return new HomeService().postUnlike(postId, user.profile.uid)
|
|
|
.then(json => {
|
...
|
...
|
@@ -95,11 +95,12 @@ export function subjectUnlike(postId) { |
|
|
}
|
|
|
|
|
|
|
|
|
export function onRightPressed() {
|
|
|
export function onRightPressed(sid) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(onRight());
|
|
|
dispatch(onRight(sid));
|
|
|
let {subject} = getState();
|
|
|
if (subject.LZ && !subject.revieweState) {
|
|
|
let item = subject.items.get(sid);
|
|
|
if (item.LZ && !item.revieweState) {
|
|
|
const BUTTONS = ['删除','取消'];
|
|
|
ActionSheetIOS.showActionSheetWithOptions({
|
|
|
options: BUTTONS,
|
...
|
...
|
@@ -108,17 +109,18 @@ export function onRightPressed() { |
|
|
|
|
|
(buttonIndex) => {
|
|
|
if (buttonIndex == 0) {
|
|
|
dispatch(doDelete(subject.id));
|
|
|
dispatch(doDelete(sid,item.id));
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
let params = {
|
|
|
postsId: subject.id,
|
|
|
postsId: item.id,
|
|
|
appType: 1,
|
|
|
}
|
|
|
new PostingService().getShareUrl(params).then(json => {
|
|
|
let {subject} = getState();
|
|
|
let blockAry = subject.blocks.toJS();
|
|
|
let item = subject.items.get(sid);
|
|
|
let blockAry = item.blocks.toJS();
|
|
|
let content = '';
|
|
|
for (var i = 0; i < blockAry.length; i++) {
|
|
|
if (blockAry[i].templateKey == 'text') {
|
...
|
...
|
@@ -149,10 +151,8 @@ export function onRightPressed() { |
|
|
'picUrl':newSrc,
|
|
|
linkUrl: json.shareUrl,
|
|
|
}
|
|
|
console.log(shareInfo);
|
|
|
dispatch(doShare(shareInfo));
|
|
|
dispatch(doShare(sid,shareInfo));
|
|
|
}).catch(error => {
|
|
|
console.log(error);
|
|
|
Alert.alert('提示','获取分享信息失败');
|
|
|
})
|
|
|
|
...
|
...
|
@@ -160,23 +160,25 @@ export function onRightPressed() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function onRight() {
|
|
|
export function onRight(sid) {
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING'
|
|
|
type:'SUBJECT_DO_NOTHING',
|
|
|
payload:sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function doShare(shareInfo) {
|
|
|
export function doShare(sid,shareInfo) {
|
|
|
|
|
|
console.log(shareInfo);
|
|
|
NativeModules.YH_CommunityHelper.showShare(shareInfo);
|
|
|
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING'
|
|
|
type:'SUBJECT_DO_NOTHING',
|
|
|
payload: sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function doDelete(postsId) {
|
|
|
export function doDelete(sid,postsId) {
|
|
|
|
|
|
Alert.alert('提示','是否确认删除?',
|
|
|
[{text:'否'},
|
...
|
...
|
@@ -192,11 +194,12 @@ export function doDelete(postsId) { |
|
|
}}]);
|
|
|
console.log('deleted.............');
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING'
|
|
|
type:'SUBJECT_DO_NOTHING',
|
|
|
payload:sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function doReport(params) {
|
|
|
export function doReport(sid, params) {
|
|
|
new PostingService().reportPost(params).then(json => {
|
|
|
Alert.alert('提示','举报成功');
|
|
|
}).catch(error => {
|
...
|
...
|
@@ -204,92 +207,100 @@ export function doReport(params) { |
|
|
});
|
|
|
|
|
|
return {
|
|
|
type:'SUBJECT_DO_NOTHING'
|
|
|
type:'SUBJECT_DO_NOTHING',
|
|
|
payload:sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function requestPostContent(postsId) {
|
|
|
export function contentSuccess(sid,json) {
|
|
|
return dispatch => {
|
|
|
dispatch(doRequestContent());
|
|
|
let rightImg = require('../../images/posting/share.png');
|
|
|
if (json.LZ&&!json.revieweState) {
|
|
|
rightImg = require('../../images/posting/more.png');
|
|
|
}
|
|
|
Actions.refresh({key: 'SubjectPost', rightButtonImage:rightImg});
|
|
|
|
|
|
let largeImages = [];
|
|
|
let index=0;
|
|
|
for (var i = 0; i < json.blocks.length; i++) {
|
|
|
let item = json.blocks[i];
|
|
|
if (item.templateKey == 'image') {
|
|
|
let urlStr = item.contentData||'';
|
|
|
let imgWidth = 640;
|
|
|
let imgHeight = imgWidth;
|
|
|
let sizeStr = item.size || '';
|
|
|
if (sizeStr.length) {
|
|
|
let ary=sizeStr.split('x');
|
|
|
let w = parseInt(ary[0]);
|
|
|
let h = parseInt(ary[1]);
|
|
|
if (w&&h) {
|
|
|
imgHeight = imgWidth/w*h;
|
|
|
}
|
|
|
}
|
|
|
let newSrc = urlStr;
|
|
|
if (urlStr.indexOf('imageView') === -1) {
|
|
|
newSrc = urlStr + '?imageView2/' + '1' + '/w/' + imgWidth + '/h/' + imgHeight;
|
|
|
} else {
|
|
|
newSrc = urlStr.replace('{mode}', '1')
|
|
|
.replace('{width}', imgWidth)
|
|
|
.replace('{height}', imgHeight);
|
|
|
}
|
|
|
largeImages.push(newSrc);
|
|
|
json.blocks[i].index=index;
|
|
|
index++;
|
|
|
}
|
|
|
}
|
|
|
json.largeImages = largeImages;
|
|
|
dispatch(contentRequestSuccess(sid,json));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function requestPostContent(sid,postsId) {
|
|
|
return dispatch => {
|
|
|
dispatch(doRequestContent(sid));
|
|
|
let params = {postsId};
|
|
|
new PostingService().getPostContent(params)
|
|
|
.then(json => {
|
|
|
NativeModules.YH_CommunityHelper.uid()
|
|
|
.then(uid => {
|
|
|
json.LZ = (uid == json.authorInfo.uid);
|
|
|
let rightImg = require('../../images/posting/share.png');
|
|
|
if (json.LZ&&!json.revieweState) {
|
|
|
rightImg = require('../../images/posting/more.png');
|
|
|
}
|
|
|
Actions.refresh({key: 'SubjectPost', rightButtonImage:rightImg});
|
|
|
|
|
|
let largeImages = [];
|
|
|
let index=0;
|
|
|
for (var i = 0; i < json.blocks.length; i++) {
|
|
|
let item = json.blocks[i];
|
|
|
if (item.templateKey == 'image') {
|
|
|
let urlStr = item.contentData||'';
|
|
|
let imgWidth = 640;
|
|
|
let imgHeight = imgWidth;
|
|
|
let sizeStr = item.size || '';
|
|
|
if (sizeStr.length) {
|
|
|
let ary=sizeStr.split('x');
|
|
|
let w = parseInt(ary[0]);
|
|
|
let h = parseInt(ary[1]);
|
|
|
if (w&&h) {
|
|
|
imgHeight = imgWidth/w*h;
|
|
|
}
|
|
|
}
|
|
|
let newSrc = urlStr;
|
|
|
if (urlStr.indexOf('imageView') === -1) {
|
|
|
newSrc = urlStr + '?imageView2/' + '1' + '/w/' + imgWidth + '/h/' + imgHeight;
|
|
|
} else {
|
|
|
newSrc = urlStr.replace('{mode}', '1')
|
|
|
.replace('{width}', imgWidth)
|
|
|
.replace('{height}', imgHeight);
|
|
|
}
|
|
|
largeImages.push(newSrc);
|
|
|
json.blocks[i].index=index;
|
|
|
index++;
|
|
|
}
|
|
|
}
|
|
|
json.largeImages = largeImages;
|
|
|
dispatch(contentRequestSuccess(json));
|
|
|
dispatch(contentSuccess(sid,json));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
json.LZ = false;
|
|
|
dispatch(contentRequestSuccess(json));
|
|
|
dispatch(contentSuccess(sid,json));
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(contentRequestFailure(error));
|
|
|
dispatch(contentRequestFailure(sid,error));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function doRequestContent() {
|
|
|
export function doRequestContent(sid) {
|
|
|
return {
|
|
|
type: SUBJECT_CONTENT_REQUEST,
|
|
|
payload: sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function contentRequestSuccess(json) {
|
|
|
export function contentRequestSuccess(sid,json) {
|
|
|
return {
|
|
|
type: SUBJECT_CONTENT_SUCCESS,
|
|
|
payload: json,
|
|
|
payload: {sid,json},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function contentRequestFailure(error) {
|
|
|
export function contentRequestFailure(sid,error) {
|
|
|
return {
|
|
|
type: SUBJECT_CONTENT_FAILURE,
|
|
|
payload: error,
|
|
|
payload: {sid,error},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function requestPostComments(postsId, lastedTime) {
|
|
|
export function requestPostComments(sid, postsId, lastedTime) {
|
|
|
return dispatch => {
|
|
|
dispatch(doRequestComments());
|
|
|
dispatch(doRequestComments(sid));
|
|
|
let params = {
|
|
|
postsId,
|
|
|
lastedTime,
|
...
|
...
|
@@ -297,22 +308,23 @@ export function requestPostComments(postsId, lastedTime) { |
|
|
};
|
|
|
new PostingService().getPostComments(params)
|
|
|
.then(json => {
|
|
|
dispatch(commentsRequestSuccess(json));
|
|
|
dispatch(commentsRequestSuccess(sid,json));
|
|
|
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(commentsRequestFailure(error));
|
|
|
dispatch(commentsRequestFailure(sid,error));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function doRequestComments() {
|
|
|
export function doRequestComments(sid) {
|
|
|
return {
|
|
|
type: SUBJECT_COMMENTS_REQUEST,
|
|
|
payload: sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentsRequestSuccess(json) {
|
|
|
export function commentsRequestSuccess(sid,json) {
|
|
|
let {list} = json;
|
|
|
let newList = [];
|
|
|
list && list.map((obj,i)=> {
|
...
|
...
|
@@ -348,82 +360,87 @@ export function commentsRequestSuccess(json) { |
|
|
json.list = newList;
|
|
|
return {
|
|
|
type: SUBJECT_COMMENTS_SUCCESS,
|
|
|
payload: json,
|
|
|
payload: {sid,json},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentsRequestFailure(error) {
|
|
|
export function commentsRequestFailure(sid,error) {
|
|
|
return {
|
|
|
type: SUBJECT_COMMENTS_FAILURE,
|
|
|
payload: error,
|
|
|
payload: {sid,error},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function assetsSelected(assets) {
|
|
|
export function assetsSelected(sid,assets) {
|
|
|
return {
|
|
|
type: SUBJECT_ASSETS_SELECTED,
|
|
|
payload: assets,
|
|
|
payload: {sid,assets},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentWithParams(params) {
|
|
|
export function commentWithParams(sid,params) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(startComment());
|
|
|
dispatch(startComment(sid));
|
|
|
let {subject} = getState();
|
|
|
let assets = subject.assets.toJS();
|
|
|
let item = subject.items.get(sid);
|
|
|
let assets = item.assets.toJS();
|
|
|
if (assets.length) {
|
|
|
for (let i = 0; i < assets.length; i++) {
|
|
|
let asset = assets[i]
|
|
|
|
|
|
new PostingService().uploadImageAsset(asset)
|
|
|
.then(response => {
|
|
|
dispatch(updateCommentProgress(response, params));
|
|
|
dispatch(updateCommentProgress(sid,response, params));
|
|
|
}).catch(error => {
|
|
|
dispatch(commentFail(error));
|
|
|
dispatch(commentFail(sid,error));
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
dispatch(commitComment(params));
|
|
|
dispatch(commitComment(sid,params));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function startComment() {
|
|
|
export function startComment(sid) {
|
|
|
return {
|
|
|
type: SUBJECT_REPLY_REQUEST,
|
|
|
payload: sid,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commitComment(params) {
|
|
|
export function commitComment(sid,params) {
|
|
|
return dispatch => {
|
|
|
new PostingService().commitReply(params)
|
|
|
.then(response => {
|
|
|
dispatch(commentSuccess(response));
|
|
|
dispatch(commentSuccess(sid,response));
|
|
|
}).catch(error => {
|
|
|
dispatch(commentFail(error));
|
|
|
dispatch(commentFail(sid,error));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function updateCommentProgress(url, params) {
|
|
|
export function updateCommentProgress(sid, url, params) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {subject} = getState();
|
|
|
let {assetsUrlStr, assetFinishCount} = subject;
|
|
|
let item = subject.items.get(sid);
|
|
|
let {assetsUrlStr, assetFinishCount} = item;
|
|
|
let newStr = assetsUrlStr + url + ',';
|
|
|
let newCount = assetFinishCount + 1;
|
|
|
let payloadData = {
|
|
|
sid,
|
|
|
newStr,
|
|
|
newCount,
|
|
|
};
|
|
|
dispatch(commentImageStateChanged(payloadData));
|
|
|
dispatch(() => {
|
|
|
let {subject} = getState();
|
|
|
if (subject.assetFinishCount == subject.assets.toJS().length) {
|
|
|
let item = subject.items.get(sid);
|
|
|
if (item.assetFinishCount == item.assets.toJS().length) {
|
|
|
let newParams = {
|
|
|
...params,
|
|
|
images: subject.assetsUrlStr,
|
|
|
images: item.assetsUrlStr,
|
|
|
}
|
|
|
dispatch(commitComment(newParams));
|
|
|
dispatch(commitComment(sid,newParams));
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -436,16 +453,16 @@ export function commentImageStateChanged(payloadData) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentSuccess(json) {
|
|
|
export function commentSuccess(sid,json) {
|
|
|
return {
|
|
|
type: SUBJECT_REPLY_SUCCESS,
|
|
|
payload: json,
|
|
|
payload: {sid, json},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function commentFail (error) {
|
|
|
export function commentFail (sid,error) {
|
|
|
return {
|
|
|
type: SUBJECT_COMMENTS_FAILURE,
|
|
|
payload: error,
|
|
|
type: SUBJECT_REPLY_FAILURE,
|
|
|
payload: {sid,error},
|
|
|
}
|
|
|
} |
...
|
...
|
|