2016-09-01 04:21:48 -07:00
|
|
|
import api from '../api'
|
|
|
|
|
|
|
|
export const REBLOG_REQUEST = 'REBLOG_REQUEST';
|
|
|
|
export const REBLOG_SUCCESS = 'REBLOG_SUCCESS';
|
|
|
|
export const REBLOG_FAIL = 'REBLOG_FAIL';
|
|
|
|
|
|
|
|
export const FAVOURITE_REQUEST = 'FAVOURITE_REQUEST';
|
|
|
|
export const FAVOURITE_SUCCESS = 'FAVOURITE_SUCCESS';
|
|
|
|
export const FAVOURITE_FAIL = 'FAVOURITE_FAIL';
|
|
|
|
|
|
|
|
export function reblog(status) {
|
|
|
|
return function (dispatch, getState) {
|
|
|
|
dispatch(reblogRequest(status));
|
|
|
|
|
|
|
|
api(getState).post(`/api/statuses/${status.get('id')}/reblog`).then(function (response) {
|
2016-09-01 05:12:11 -07:00
|
|
|
// The reblog API method returns a new status wrapped around the original. In this case we are only
|
|
|
|
// interested in how the original is modified, hence passing it skipping the wrapper
|
|
|
|
dispatch(reblogSuccess(status, response.data.reblog));
|
2016-09-01 04:21:48 -07:00
|
|
|
}).catch(function (error) {
|
|
|
|
dispatch(reblogFail(status, error));
|
|
|
|
});
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
2016-09-26 14:55:21 -07:00
|
|
|
export function unreblog(status) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
api(getState).post(`/api/statuses/${status.get('id')}/unreblog`).then(response => {
|
|
|
|
//
|
|
|
|
}).catch(error => {
|
|
|
|
//
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-09-01 04:21:48 -07:00
|
|
|
export function reblogRequest(status) {
|
|
|
|
return {
|
|
|
|
type: REBLOG_REQUEST,
|
|
|
|
status: status
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
|
|
|
export function reblogSuccess(status, response) {
|
|
|
|
return {
|
|
|
|
type: REBLOG_SUCCESS,
|
|
|
|
status: status,
|
|
|
|
response: response
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
|
|
|
export function reblogFail(status, error) {
|
|
|
|
return {
|
|
|
|
type: REBLOG_FAIL,
|
|
|
|
status: status,
|
|
|
|
error: error
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
|
|
|
export function favourite(status) {
|
|
|
|
return function (dispatch, getState) {
|
|
|
|
dispatch(favouriteRequest(status));
|
|
|
|
|
|
|
|
api(getState).post(`/api/statuses/${status.get('id')}/favourite`).then(function (response) {
|
|
|
|
dispatch(favouriteSuccess(status, response.data));
|
|
|
|
}).catch(function (error) {
|
|
|
|
dispatch(favouriteFail(status, error));
|
|
|
|
});
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
2016-09-26 14:55:21 -07:00
|
|
|
export function unfavourite(status) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
api(getState).post(`/api/statuses/${status.get('id')}/unfavourite`).then(response => {
|
|
|
|
//
|
|
|
|
}).catch(error => {
|
|
|
|
//
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-09-01 04:21:48 -07:00
|
|
|
export function favouriteRequest(status) {
|
|
|
|
return {
|
|
|
|
type: FAVOURITE_REQUEST,
|
|
|
|
status: status
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
|
|
|
export function favouriteSuccess(status, response) {
|
|
|
|
return {
|
|
|
|
type: FAVOURITE_SUCCESS,
|
|
|
|
status: status,
|
|
|
|
response: response
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|
2016-09-01 04:21:48 -07:00
|
|
|
|
|
|
|
export function favouriteFail(status, error) {
|
|
|
|
return {
|
|
|
|
type: FAVOURITE_FAIL,
|
|
|
|
status: status,
|
|
|
|
error: error
|
|
|
|
};
|
2016-09-12 10:20:55 -07:00
|
|
|
};
|