Files
astuto/app/javascript/containers/Comments.tsx
Riccardo Graziosi dad382d2b1 Post follow and updates notifications V1 (#111)
* 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 ...
2022-05-28 11:03:36 +02:00

63 lines
1.7 KiB
TypeScript

import { connect } from 'react-redux';
import { requestComments } from '../actions/Comment/requestComments';
import {
toggleCommentReply,
setCommentReplyBody,
toggleCommentIsPostUpdateFlag,
} from '../actions/Comment/handleCommentReplies';
import { toggleCommentIsUpdate } from '../actions/Comment/updateComment';
import { submitComment } from '../actions/Comment/submitComment';
import { State } from '../reducers/rootReducer';
import CommentsP from '../components/Comments/CommentsP';
const mapStateToProps = (state: State) => ({
comments: state.currentPost.comments.items,
replyForms: state.currentPost.comments.replyForms,
areLoading: state.currentPost.comments.areLoading,
error: state.currentPost.comments.error,
});
const mapDispatchToProps = (dispatch) => ({
requestComments(postId: number) {
dispatch(requestComments(postId));
},
toggleCommentReply(commentId: number) {
dispatch(toggleCommentReply(commentId));
},
setCommentReplyBody(commentId: number, body: string) {
dispatch(setCommentReplyBody(commentId, body));
},
toggleCommentIsPostUpdateFlag() {
dispatch(toggleCommentIsPostUpdateFlag(null));
},
toggleCommentIsPostUpdate(
postId: number,
commentId: number,
currentIsPostUpdate: boolean,
authenticityToken: string,
) {
dispatch(toggleCommentIsUpdate(postId, commentId, currentIsPostUpdate, authenticityToken));
},
submitComment(
postId: number,
body: string,
parentId: number,
isPostUpdate: boolean,
authenticityToken: string,
) {
dispatch(submitComment(postId, body, parentId, isPostUpdate, authenticityToken));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(CommentsP);