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
71
app/javascript/reducers/postStatusChangesReducer.ts
Normal file
71
app/javascript/reducers/postStatusChangesReducer.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import {
|
||||
PostStatusChangesRequestActionTypes,
|
||||
POST_STATUS_CHANGES_REQUEST_START,
|
||||
POST_STATUS_CHANGES_REQUEST_SUCCESS,
|
||||
POST_STATUS_CHANGES_REQUEST_FAILURE,
|
||||
} from "../actions/PostStatusChange/requestPostStatusChanges";
|
||||
|
||||
import {
|
||||
PostStatusChangeSubmitted,
|
||||
POST_STATUS_CHANGE_SUBMITTED
|
||||
} from '../actions/PostStatusChange/submittedPostStatusChange';
|
||||
|
||||
import IPostStatusChange from "../interfaces/IPostStatusChange";
|
||||
|
||||
export interface PostStatusChangesState {
|
||||
items: Array<IPostStatusChange>;
|
||||
areLoading: boolean;
|
||||
error: string;
|
||||
}
|
||||
|
||||
const initialState: PostStatusChangesState = {
|
||||
items: [],
|
||||
areLoading: false,
|
||||
error: '',
|
||||
};
|
||||
|
||||
const postStatusChangesReducer = (
|
||||
state = initialState,
|
||||
action:
|
||||
PostStatusChangesRequestActionTypes |
|
||||
PostStatusChangeSubmitted
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case POST_STATUS_CHANGES_REQUEST_START:
|
||||
return {
|
||||
...state,
|
||||
areLoading: true,
|
||||
};
|
||||
|
||||
case POST_STATUS_CHANGES_REQUEST_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
items: action.postStatusChanges.map(postStatusChange => ({
|
||||
postStatusId: postStatusChange.post_status_id,
|
||||
userFullName: postStatusChange.user_full_name,
|
||||
userEmail: postStatusChange.user_email,
|
||||
updatedAt: postStatusChange.updated_at,
|
||||
})),
|
||||
areLoading: false,
|
||||
error: '',
|
||||
};
|
||||
|
||||
case POST_STATUS_CHANGES_REQUEST_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
areLoading: false,
|
||||
error: action.error,
|
||||
};
|
||||
|
||||
case POST_STATUS_CHANGE_SUBMITTED:
|
||||
return {
|
||||
...state,
|
||||
items: [action.postStatusChange, ...state.items],
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default postStatusChangesReducer;
|
||||
Reference in New Issue
Block a user