2020-08-24 19:26:42 -07:00
|
|
|
import api from '../api';
|
2020-08-25 10:38:21 -07:00
|
|
|
import { importFetchedChats } from 'soapbox/actions/importer';
|
2020-08-24 19:26:42 -07:00
|
|
|
|
|
|
|
export const CHATS_FETCH_REQUEST = 'CHATS_FETCH_REQUEST';
|
|
|
|
export const CHATS_FETCH_SUCCESS = 'CHATS_FETCH_SUCCESS';
|
|
|
|
export const CHATS_FETCH_FAIL = 'CHATS_FETCH_FAIL';
|
|
|
|
|
|
|
|
export function fetchChats() {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: CHATS_FETCH_REQUEST });
|
|
|
|
return api(getState).get('/api/v1/pleroma/chats').then(({ data }) => {
|
2020-08-25 10:38:21 -07:00
|
|
|
dispatch(importFetchedChats(data));
|
2020-08-24 19:26:42 -07:00
|
|
|
dispatch({ type: CHATS_FETCH_SUCCESS, data });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: CHATS_FETCH_FAIL, error });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|