2016-09-01 23:13:02 +10:00
|
|
|
import api from '../api'
|
|
|
|
|
|
|
|
export const FOLLOW_CHANGE = 'FOLLOW_CHANGE';
|
|
|
|
export const FOLLOW_SUBMIT = 'FOLLOW_SUBMIT';
|
|
|
|
export const FOLLOW_SUBMIT_REQUEST = 'FOLLOW_SUBMIT_REQUEST';
|
|
|
|
export const FOLLOW_SUBMIT_SUCCESS = 'FOLLOW_SUBMIT_SUCCESS';
|
|
|
|
export const FOLLOW_SUBMIT_FAIL = 'FOLLOW_SUBMIT_FAIL';
|
|
|
|
|
2016-09-03 22:01:10 +10:00
|
|
|
export function changeFollow(text) {
|
2016-09-01 23:13:02 +10:00
|
|
|
return {
|
|
|
|
type: FOLLOW_CHANGE,
|
|
|
|
text: text
|
|
|
|
};
|
2016-09-13 03:20:55 +10:00
|
|
|
};
|
2016-09-01 23:13:02 +10:00
|
|
|
|
2016-09-03 22:01:10 +10:00
|
|
|
export function submitFollow() {
|
2016-09-01 23:13:02 +10:00
|
|
|
return function (dispatch, getState) {
|
2016-09-03 22:01:10 +10:00
|
|
|
dispatch(submitFollowRequest());
|
2016-09-01 23:13:02 +10:00
|
|
|
|
|
|
|
api(getState).post('/api/follows', {
|
|
|
|
uri: getState().getIn(['follow', 'text'])
|
|
|
|
}).then(function (response) {
|
2016-09-03 22:01:10 +10:00
|
|
|
dispatch(submitFollowSuccess(response.data));
|
2016-09-01 23:13:02 +10:00
|
|
|
}).catch(function (error) {
|
2016-09-03 22:01:10 +10:00
|
|
|
dispatch(submitFollowFail(error));
|
2016-09-01 23:13:02 +10:00
|
|
|
});
|
|
|
|
};
|
2016-09-13 03:20:55 +10:00
|
|
|
};
|
2016-09-01 23:13:02 +10:00
|
|
|
|
2016-09-03 22:01:10 +10:00
|
|
|
export function submitFollowRequest() {
|
2016-09-01 23:13:02 +10:00
|
|
|
return {
|
|
|
|
type: FOLLOW_SUBMIT_REQUEST
|
|
|
|
};
|
2016-09-13 03:20:55 +10:00
|
|
|
};
|
2016-09-01 23:13:02 +10:00
|
|
|
|
2016-09-03 22:01:10 +10:00
|
|
|
export function submitFollowSuccess(account) {
|
2016-09-01 23:13:02 +10:00
|
|
|
return {
|
|
|
|
type: FOLLOW_SUBMIT_SUCCESS,
|
|
|
|
account: account
|
|
|
|
};
|
2016-09-13 03:20:55 +10:00
|
|
|
};
|
2016-09-01 23:13:02 +10:00
|
|
|
|
2016-09-03 22:01:10 +10:00
|
|
|
export function submitFollowFail(error) {
|
2016-09-01 23:13:02 +10:00
|
|
|
return {
|
|
|
|
type: FOLLOW_SUBMIT_FAIL,
|
|
|
|
error: error
|
|
|
|
};
|
2016-09-13 03:20:55 +10:00
|
|
|
};
|