Rev 5315 | Rev 5317 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import { axios } from '../../utils'
import { conversationActionTypes } from './conversation.types'
export const setNewMessage = (newMessage) => ({
type: conversationActionTypes.SET_NEW_MESSAGE,
payload: newMessage
})
export const setMessages = (unreadMessages) => ({
type: conversationActionTypes.SET_MESSAGES,
payload: unreadMessages
})
export const startLoading = () => ({
type: conversationActionTypes.START_LOADING
})
export const finishLoading = () => ({
type: conversationActionTypes.FINISH_LOADING
})
export const getMessages = (url) => {
return (dispatch) => {
dispatch(startLoading)
axios
.get(url)
.then(({ data: response }) => {
if (response.success) {
dispatch(setMessages(response.data))
}
})
.catch((error) => {
// dispatch(fetchFeedsFailure());
throw Error(error.message)
})
}
}