pin_statuses.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import api from '../api';
  2. import { importFetchedStatuses } from './importer';
  3. export const PINNED_STATUSES_FETCH_REQUEST = 'PINNED_STATUSES_FETCH_REQUEST';
  4. export const PINNED_STATUSES_FETCH_SUCCESS = 'PINNED_STATUSES_FETCH_SUCCESS';
  5. export const PINNED_STATUSES_FETCH_FAIL = 'PINNED_STATUSES_FETCH_FAIL';
  6. import { me } from '../initial_state';
  7. export function fetchPinnedStatuses() {
  8. return (dispatch, getState) => {
  9. dispatch(fetchPinnedStatusesRequest());
  10. api(getState).get(`/api/v1/accounts/${me}/statuses`, { params: { pinned: true } }).then(response => {
  11. dispatch(importFetchedStatuses(response.data));
  12. dispatch(fetchPinnedStatusesSuccess(response.data, null));
  13. }).catch(error => {
  14. dispatch(fetchPinnedStatusesFail(error));
  15. });
  16. };
  17. };
  18. export function fetchPinnedStatusesRequest() {
  19. return {
  20. type: PINNED_STATUSES_FETCH_REQUEST,
  21. };
  22. };
  23. export function fetchPinnedStatusesSuccess(statuses, next) {
  24. return {
  25. type: PINNED_STATUSES_FETCH_SUCCESS,
  26. statuses,
  27. next,
  28. };
  29. };
  30. export function fetchPinnedStatusesFail(error) {
  31. return {
  32. type: PINNED_STATUSES_FETCH_FAIL,
  33. error,
  34. };
  35. };