logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

cards.js (1154B)


  1. import api from '../api';
  2. export const STATUS_CARD_FETCH_REQUEST = 'STATUS_CARD_FETCH_REQUEST';
  3. export const STATUS_CARD_FETCH_SUCCESS = 'STATUS_CARD_FETCH_SUCCESS';
  4. export const STATUS_CARD_FETCH_FAIL = 'STATUS_CARD_FETCH_FAIL';
  5. export function fetchStatusCard(id) {
  6. return (dispatch, getState) => {
  7. if (getState().getIn(['cards', id], null) !== null) {
  8. return;
  9. }
  10. dispatch(fetchStatusCardRequest(id));
  11. api(getState).get(`/api/v1/statuses/${id}/card`).then(response => {
  12. if (!response.data.url) {
  13. return;
  14. }
  15. dispatch(fetchStatusCardSuccess(id, response.data));
  16. }).catch(error => {
  17. dispatch(fetchStatusCardFail(id, error));
  18. });
  19. };
  20. };
  21. export function fetchStatusCardRequest(id) {
  22. return {
  23. type: STATUS_CARD_FETCH_REQUEST,
  24. id,
  25. skipLoading: true,
  26. };
  27. };
  28. export function fetchStatusCardSuccess(id, card) {
  29. return {
  30. type: STATUS_CARD_FETCH_SUCCESS,
  31. id,
  32. card,
  33. skipLoading: true,
  34. };
  35. };
  36. export function fetchStatusCardFail(id, error) {
  37. return {
  38. type: STATUS_CARD_FETCH_FAIL,
  39. id,
  40. error,
  41. skipLoading: true,
  42. skipAlert: true,
  43. };
  44. };