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 ...
This commit is contained in:
Riccardo Graziosi
2022-05-28 11:03:36 +02:00
committed by GitHub
parent ce7be1b30c
commit dad382d2b1
59 changed files with 1080 additions and 71 deletions

View File

@@ -4,15 +4,23 @@ 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) => ({
@@ -24,14 +32,41 @@ const mapDispatchToProps = (dispatch) => ({
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, authenticityToken: string) {
changePostStatus(
postId: number,
newPostStatusId: number,
userFullName: string,
userEmail: string,
authenticityToken: string
) {
if (isNaN(newPostStatusId)) newPostStatusId = null;
dispatch(changePostStatus(postId, newPostStatusId, authenticityToken));
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));
},
});