diff --git a/app/soapbox/actions/admin.js b/app/soapbox/actions/admin.js index 84ec80362..94d8b2395 100644 --- a/app/soapbox/actions/admin.js +++ b/app/soapbox/actions/admin.js @@ -1,4 +1,5 @@ import api from '../api'; +import { importFetchedStatuses } from 'soapbox/actions/importer'; export const ADMIN_CONFIG_FETCH_REQUEST = 'ADMIN_CONFIG_FETCH_REQUEST'; export const ADMIN_CONFIG_FETCH_SUCCESS = 'ADMIN_CONFIG_FETCH_SUCCESS'; @@ -64,6 +65,7 @@ export function fetchReports(params) { return api(getState) .get('/api/pleroma/admin/reports', { params }) .then(({ data: { reports } }) => { + reports.forEach(report => dispatch(importFetchedStatuses(report.statuses))); dispatch({ type: ADMIN_REPORTS_FETCH_SUCCESS, reports, params }); }).catch(error => { dispatch({ type: ADMIN_REPORTS_FETCH_FAIL, error, params }); diff --git a/app/soapbox/features/admin/reports.js b/app/soapbox/features/admin/reports.js index 1621fbd73..55c638b64 100644 --- a/app/soapbox/features/admin/reports.js +++ b/app/soapbox/features/admin/reports.js @@ -8,6 +8,7 @@ import Column from '../ui/components/column'; import ScrollableList from 'soapbox/components/scrollable_list'; import { fetchReports } from 'soapbox/actions/admin'; import Report from './components/report'; +import { makeGetReport } from 'soapbox/selectors'; const messages = defineMessages({ heading: { id: 'column.admin.reports', defaultMessage: 'Reports' }, @@ -15,9 +16,11 @@ const messages = defineMessages({ }); const mapStateToProps = state => { + const getReport = makeGetReport(); const ids = state.getIn(['admin', 'openReports']); + return { - reports: ids.toList().map(id => state.getIn(['admin', 'reports', id])), + reports: ids.map(id => getReport(state, id)), }; }; diff --git a/app/soapbox/reducers/admin.js b/app/soapbox/reducers/admin.js index 36e5f77fe..9f6000ec8 100644 --- a/app/soapbox/reducers/admin.js +++ b/app/soapbox/reducers/admin.js @@ -57,6 +57,7 @@ function approveUsers(state, users) { function importReports(state, reports) { return state.withMutations(state => { reports.forEach(report => { + report.statuses = report.statuses.map(status => status.id); if (report.state === 'open') { state.update('openReports', orderedSet => orderedSet.add(report.id)); } diff --git a/app/soapbox/selectors/index.js b/app/soapbox/selectors/index.js index 89d20b209..d36839d6e 100644 --- a/app/soapbox/selectors/index.js +++ b/app/soapbox/selectors/index.js @@ -175,3 +175,18 @@ export const makeGetChat = () => { }, ); }; + +export const makeGetReport = () => { + return createSelector( + [ + (state, id) => state.getIn(['admin', 'reports', id]), + (state, id) => state.getIn(['admin', 'reports', id, 'statuses']).map( + statusId => state.getIn(['statuses', statusId])), + ], + + (report, statuses) => { + if (!report) return null; + return report.set('statuses', statuses); + }, + ); +};