Reports counter: Only count open reports
This commit is contained in:
parent
df3bf8142e
commit
fa9421a7c1
5 changed files with 13 additions and 7 deletions
|
@ -25,7 +25,7 @@ export function fetchReports(params) {
|
|||
return (dispatch, getState) => {
|
||||
dispatch({ type: ADMIN_REPORTS_FETCH_REQUEST, params });
|
||||
return api(getState)
|
||||
.get('/api/pleroma/admin/reports', params)
|
||||
.get('/api/pleroma/admin/reports', { params })
|
||||
.then(({ data }) => {
|
||||
dispatch({ type: ADMIN_REPORTS_FETCH_SUCCESS, data, params });
|
||||
}).catch(error => {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
|||
import IconWithBadge from 'soapbox/components/icon_with_badge';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
count: state.getIn(['admin', 'report_count']),
|
||||
count: state.getIn(['admin', 'open_report_count']),
|
||||
id: 'gavel',
|
||||
});
|
||||
|
||||
|
|
|
@ -422,7 +422,8 @@ class UI extends React.PureComponent {
|
|||
this.props.dispatch(expandHomeTimeline());
|
||||
this.props.dispatch(expandNotifications());
|
||||
// this.props.dispatch(fetchGroups('member'));
|
||||
if (isStaff(account)) this.props.dispatch(fetchReports());
|
||||
if (isStaff(account))
|
||||
this.props.dispatch(fetchReports({ state: 'open' }));
|
||||
|
||||
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('admin reducer', () => {
|
|||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toEqual(fromJS({
|
||||
reports: [],
|
||||
report_count: 0,
|
||||
open_report_count: 0,
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,14 +3,19 @@ import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
|||
|
||||
const initialState = ImmutableMap({
|
||||
reports: ImmutableList(),
|
||||
report_count: 0,
|
||||
open_report_count: 0,
|
||||
});
|
||||
|
||||
export default function admin(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case ADMIN_REPORTS_FETCH_SUCCESS:
|
||||
return state.set('reports', fromJS(action.data.reports))
|
||||
.set('report_count', action.data.total);
|
||||
if (action.params && action.params.state === 'open') {
|
||||
return state
|
||||
.set('reports', fromJS(action.data.reports))
|
||||
.set('open_report_count', action.data.total);
|
||||
} else {
|
||||
return state.set('reports', fromJS(action.data.reports));
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue