mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
* It is now possible to follow a post in order to receive updates about it * Notifications are now sent when updates are published * Post status changes are now tracked * Update sidebar now shows the post status history * Mark a comment as a post update using the comment form * ... more ...
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { connect } from 'react-redux';
|
|
|
|
import { requestPost } from '../actions/Post/requestPost';
|
|
import { requestLikes } from '../actions/Like/requestLikes';
|
|
import { changePostBoard } from '../actions/Post/changePostBoard';
|
|
import { changePostStatus } from '../actions/Post/changePostStatus';
|
|
import { submitFollow } from '../actions/Follow/submitFollow';
|
|
import { requestFollow } from '../actions/Follow/requestFollow';
|
|
import { requestPostStatusChanges } from '../actions/PostStatusChange/requestPostStatusChanges';
|
|
import { postStatusChangeSubmitted } from '../actions/PostStatusChange/submittedPostStatusChange';
|
|
|
|
import { State } from '../reducers/rootReducer';
|
|
|
|
import PostP from '../components/Post/PostP';
|
|
|
|
import { fromJavascriptDateToRailsString } from '../helpers/datetime';
|
|
|
|
const mapStateToProps = (state: State) => ({
|
|
post: state.currentPost.item,
|
|
likes: state.currentPost.likes,
|
|
followed: state.currentPost.followed,
|
|
comments: state.currentPost.comments,
|
|
postStatusChanges: state.currentPost.postStatusChanges,
|
|
});
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
requestPost(postId: number) {
|
|
dispatch(requestPost(postId));
|
|
},
|
|
|
|
requestLikes(postId: number) {
|
|
dispatch(requestLikes(postId));
|
|
},
|
|
|
|
requestFollow(postId: number) {
|
|
dispatch(requestFollow(postId));
|
|
},
|
|
|
|
requestPostStatusChanges(postId: number) {
|
|
dispatch(requestPostStatusChanges(postId));
|
|
},
|
|
|
|
changePostBoard(postId: number, newBoardId: number, authenticityToken: string) {
|
|
dispatch(changePostBoard(postId, newBoardId, authenticityToken));
|
|
},
|
|
|
|
changePostStatus(
|
|
postId: number,
|
|
newPostStatusId: number,
|
|
userFullName: string,
|
|
userEmail: string,
|
|
authenticityToken: string
|
|
) {
|
|
if (isNaN(newPostStatusId)) newPostStatusId = null;
|
|
|
|
dispatch(changePostStatus(postId, newPostStatusId, authenticityToken)).then(res => {
|
|
if (res && res.status !== 204) return;
|
|
|
|
dispatch(postStatusChangeSubmitted({
|
|
postStatusId: newPostStatusId,
|
|
userFullName,
|
|
userEmail,
|
|
updatedAt: fromJavascriptDateToRailsString(new Date()),
|
|
}));
|
|
});
|
|
},
|
|
|
|
submitFollow(postId: number, isFollow: boolean, authenticityToken: string) {
|
|
dispatch(submitFollow(postId, isFollow, authenticityToken));
|
|
},
|
|
});
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps,
|
|
)(PostP); |