]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/actions/reports.js
Improve eslint rules (#3147)
[mastodon.git] / app / javascript / mastodon / actions / reports.js
1 import api from '../api';
2
3 export const REPORT_INIT = 'REPORT_INIT';
4 export const REPORT_CANCEL = 'REPORT_CANCEL';
5
6 export const REPORT_SUBMIT_REQUEST = 'REPORT_SUBMIT_REQUEST';
7 export const REPORT_SUBMIT_SUCCESS = 'REPORT_SUBMIT_SUCCESS';
8 export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL';
9
10 export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE';
11 export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE';
12
13 export function initReport(account, status) {
14 return {
15 type: REPORT_INIT,
16 account,
17 status,
18 };
19 };
20
21 export function cancelReport() {
22 return {
23 type: REPORT_CANCEL,
24 };
25 };
26
27 export function toggleStatusReport(statusId, checked) {
28 return {
29 type: REPORT_STATUS_TOGGLE,
30 statusId,
31 checked,
32 };
33 };
34
35 export function submitReport() {
36 return (dispatch, getState) => {
37 dispatch(submitReportRequest());
38
39 api(getState).post('/api/v1/reports', {
40 account_id: getState().getIn(['reports', 'new', 'account_id']),
41 status_ids: getState().getIn(['reports', 'new', 'status_ids']),
42 comment: getState().getIn(['reports', 'new', 'comment']),
43 }).then(response => dispatch(submitReportSuccess(response.data))).catch(error => dispatch(submitReportFail(error)));
44 };
45 };
46
47 export function submitReportRequest() {
48 return {
49 type: REPORT_SUBMIT_REQUEST,
50 };
51 };
52
53 export function submitReportSuccess(report) {
54 return {
55 type: REPORT_SUBMIT_SUCCESS,
56 report,
57 };
58 };
59
60 export function submitReportFail(error) {
61 return {
62 type: REPORT_SUBMIT_FAIL,
63 error,
64 };
65 };
66
67 export function changeReportComment(comment) {
68 return {
69 type: REPORT_COMMENT_CHANGE,
70 comment,
71 };
72 };
This page took 0.098128 seconds and 5 git commands to generate.