You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
8 years ago
|
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';
|
||
|
|
||
|
export function followChange(text) {
|
||
|
return {
|
||
|
type: FOLLOW_CHANGE,
|
||
|
text: text
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export function followSubmit() {
|
||
|
return function (dispatch, getState) {
|
||
|
dispatch(followSubmitRequest());
|
||
|
|
||
|
api(getState).post('/api/follows', {
|
||
|
uri: getState().getIn(['follow', 'text'])
|
||
|
}).then(function (response) {
|
||
|
dispatch(followSubmitSuccess(response.data));
|
||
|
}).catch(function (error) {
|
||
|
dispatch(followSubmitFail(error));
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export function followSubmitRequest() {
|
||
|
return {
|
||
|
type: FOLLOW_SUBMIT_REQUEST
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export function followSubmitSuccess(account) {
|
||
|
return {
|
||
|
type: FOLLOW_SUBMIT_SUCCESS,
|
||
|
account: account
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export function followSubmitFail(error) {
|
||
|
return {
|
||
|
type: FOLLOW_SUBMIT_FAIL,
|
||
|
error: error
|
||
|
};
|
||
|
}
|