Rev 5307 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import { axios } from '../../utils'
import { chatActionTypes } from './chat.types'
export const setHaveNewMessage = async (url, message) => {
return (dispatch) => {
const formData = new FormData()
formData.append('message', emojione.toShort(message))
axios.post(url, formData)
.then(({ data: response }) => {
if (!response.success) {
dispatch(loadFeeds())
return
}
dispatch(setNewMessage(response.data))
})
.catch((error) => {
throw Error(error.message)
})
}
}
export const setNewMessage = (newMessage) => ({
type: 'sendMessage',
payload: newMessage
})
export const setUnreadMessages = (unreadMessages) => ({
type: chatActionTypes.SET_UNREAD_MESSAGES,
payload: unreadMessages
})
export const setShouldAlertNewMessage = (shouldAlertNewMessage) => ({
type: chatActionTypes.SET_SHOULD_ALERT_NEW_MESSAGE,
payload: shouldAlertNewMessage
})