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) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: ADMIN_REPORTS_FETCH_REQUEST, params });
|
dispatch({ type: ADMIN_REPORTS_FETCH_REQUEST, params });
|
||||||
return api(getState)
|
return api(getState)
|
||||||
.get('/api/pleroma/admin/reports', params)
|
.get('/api/pleroma/admin/reports', { params })
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
dispatch({ type: ADMIN_REPORTS_FETCH_SUCCESS, data, params });
|
dispatch({ type: ADMIN_REPORTS_FETCH_SUCCESS, data, params });
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||||
import IconWithBadge from 'soapbox/components/icon_with_badge';
|
import IconWithBadge from 'soapbox/components/icon_with_badge';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
count: state.getIn(['admin', 'report_count']),
|
count: state.getIn(['admin', 'open_report_count']),
|
||||||
id: 'gavel',
|
id: 'gavel',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -422,7 +422,8 @@ class UI extends React.PureComponent {
|
||||||
this.props.dispatch(expandHomeTimeline());
|
this.props.dispatch(expandHomeTimeline());
|
||||||
this.props.dispatch(expandNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
// this.props.dispatch(fetchGroups('member'));
|
// 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);
|
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe('admin reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(fromJS({
|
expect(reducer(undefined, {})).toEqual(fromJS({
|
||||||
reports: [],
|
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({
|
const initialState = ImmutableMap({
|
||||||
reports: ImmutableList(),
|
reports: ImmutableList(),
|
||||||
report_count: 0,
|
open_report_count: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function admin(state = initialState, action) {
|
export default function admin(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case ADMIN_REPORTS_FETCH_SUCCESS:
|
case ADMIN_REPORTS_FETCH_SUCCESS:
|
||||||
return state.set('reports', fromJS(action.data.reports))
|
if (action.params && action.params.state === 'open') {
|
||||||
.set('report_count', action.data.total);
|
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:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue