blob: aeb786aa3b4739c8fd3f5125adf5280407629a35 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import api from '../api'
export const FOLLOW_CHANGE = 'FOLLOW_CHANGE';
export const FOLLOW_SUBMIT_REQUEST = 'FOLLOW_SUBMIT_REQUEST';
export const FOLLOW_SUBMIT_SUCCESS = 'FOLLOW_SUBMIT_SUCCESS';
export const FOLLOW_SUBMIT_FAIL = 'FOLLOW_SUBMIT_FAIL';
export function changeFollow(text) {
return {
type: FOLLOW_CHANGE,
text: text
};
};
export function submitFollow() {
return function (dispatch, getState) {
dispatch(submitFollowRequest());
api(getState).post('/api/follows', {
uri: getState().getIn(['follow', 'text'])
}).then(function (response) {
dispatch(submitFollowSuccess(response.data));
}).catch(function (error) {
dispatch(submitFollowFail(error));
});
};
};
export function submitFollowRequest() {
return {
type: FOLLOW_SUBMIT_REQUEST
};
};
export function submitFollowSuccess(account) {
return {
type: FOLLOW_SUBMIT_SUCCESS,
account: account
};
};
export function submitFollowFail(error) {
return {
type: FOLLOW_SUBMIT_FAIL,
error: error
};
};
|