diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-01 15:13:02 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-01 15:13:02 +0200 |
commit | 2d57bcf1b7ea3a9df42ae7e1eb9388f978a96312 (patch) | |
tree | 2dfbfbc8e5555d8dedf2760f53824553c53655f7 /app/assets/javascripts/components/actions/follow.jsx | |
parent | c249ceb10c9deb468823b7e4fa2e876be5c99545 (diff) |
Preparing for follow form
Diffstat (limited to 'app/assets/javascripts/components/actions/follow.jsx')
-rw-r--r-- | app/assets/javascripts/components/actions/follow.jsx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/assets/javascripts/components/actions/follow.jsx b/app/assets/javascripts/components/actions/follow.jsx new file mode 100644 index 000000000..1c4e2c66a --- /dev/null +++ b/app/assets/javascripts/components/actions/follow.jsx @@ -0,0 +1,48 @@ +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 + }; +} |