mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
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:
committed by
GitHub
parent
ce7be1b30c
commit
dad382d2b1
@@ -4,6 +4,7 @@ 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';
|
||||
@@ -32,6 +33,10 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
dispatch(setCommentReplyBody(commentId, body));
|
||||
},
|
||||
|
||||
toggleCommentIsPostUpdateFlag() {
|
||||
dispatch(toggleCommentIsPostUpdateFlag(null));
|
||||
},
|
||||
|
||||
toggleCommentIsPostUpdate(
|
||||
postId: number,
|
||||
commentId: number,
|
||||
@@ -45,9 +50,10 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
postId: number,
|
||||
body: string,
|
||||
parentId: number,
|
||||
isPostUpdate: boolean,
|
||||
authenticityToken: string,
|
||||
) {
|
||||
dispatch(submitComment(postId, body, parentId, authenticityToken));
|
||||
dispatch(submitComment(postId, body, parentId, isPostUpdate, authenticityToken));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user