mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
Adding pending users and actions to moderation queue call.
This commit is contained in:
@@ -9,6 +9,6 @@
|
||||
export const banUser = (status, userId, commentId) => {
|
||||
return dispatch => {
|
||||
dispatch({type: 'USER_BAN', status, userId, commentId});
|
||||
dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH'});
|
||||
dispatch({type: 'MODERATION_QUEUE_FETCH'});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ class ModerationQueue extends React.Component {
|
||||
|
||||
// Fetch comments and bind singleView key before render
|
||||
componentWillMount () {
|
||||
this.props.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH'});
|
||||
this.props.dispatch({type: 'MODERATION_QUEUE_FETCH'});
|
||||
key('s', () => this.setState({singleView: !this.state.singleView}));
|
||||
key('shift+/', () => this.setState({modalOpen: true}));
|
||||
key('esc', () => this.setState({modalOpen: false}));
|
||||
|
||||
@@ -23,7 +23,7 @@ const initialState = Map({
|
||||
// Handle the comment actions
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case 'COMMENTS_MODERATION_QUEUE_FETCH': return state.set('loading', true);
|
||||
case 'MODERATION_QUEUE_FETCH': return state.set('loading', true);
|
||||
case 'COMMENTS_MODERATION_QUEUE_FETCH_SUCCESS': return replaceComments(action, state);
|
||||
case 'COMMENTS_MODERATION_QUEUE_FAILED': return state.set('loading', false);
|
||||
case 'COMMENT_STATUS_UPDATE': return updateStatus(state, action);
|
||||
|
||||
@@ -12,7 +12,7 @@ import coralApi from '../../../coral-framework/helpers/response';
|
||||
export default store => next => action => {
|
||||
|
||||
switch (action.type) {
|
||||
case 'COMMENTS_MODERATION_QUEUE_FETCH':
|
||||
case 'MODERATION_QUEUE_FETCH':
|
||||
fetchModerationQueueComments(store);
|
||||
break;
|
||||
case 'COMMENT_UPDATE':
|
||||
@@ -34,23 +34,26 @@ const fetchModerationQueueComments = store =>
|
||||
|
||||
Promise.all([
|
||||
coralApi('/queue/comments/pending'),
|
||||
coralApi('/queue/users/pending'),
|
||||
coralApi('/comments?status=rejected'),
|
||||
coralApi('/comments?action_type=flag')
|
||||
])
|
||||
.then(([pending, rejected, flagged]) => {
|
||||
.then(([pendingComments, pendingUsers, rejected, flagged]) => {
|
||||
|
||||
/* Combine seperate calls into a single object */
|
||||
let all = {};
|
||||
all.comments = pending.comments
|
||||
all.comments = pendingComments.comments
|
||||
.concat(rejected.comments)
|
||||
.concat(flagged.comments.map(comment => {
|
||||
comment.flagged = true;
|
||||
return comment;
|
||||
}));
|
||||
all.users = pending.users
|
||||
all.users = pendingComments.users
|
||||
.concat(pendingUsers.users)
|
||||
.concat(rejected.users)
|
||||
.concat(flagged.users);
|
||||
all.actions = pending.actions
|
||||
all.actions = pendingComments.actions
|
||||
.concat(pendingUsers.actions)
|
||||
.concat(rejected.actions)
|
||||
.concat(flagged.actions);
|
||||
return all;
|
||||
|
||||
Reference in New Issue
Block a user