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.

48 lines
1.1 KiB

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