index.ts 612 B

1234567891011121314151617181920212223242526272829
  1. import {
  2. actionSelectChat,
  3. actionGetChatById
  4. } from '../action';
  5. import { startChat,getChatById } from '../../../api-data';
  6. import { TChat } from '../../../typescript/redux/chat/types'
  7. const asyncStartChatById = (id:string) => async (dispatch:any) => {
  8. try {
  9. const data = await startChat<TChat>(id)
  10. data&&dispatch(actionSelectChat(data))
  11. } catch(e) {}
  12. };
  13. const asyncGetChatById = (id:string) => async (dispatch:any) => {
  14. try {
  15. const data = await getChatById<TChat>(id)
  16. data&&dispatch(actionGetChatById(data))
  17. } catch(e) {}
  18. };
  19. export { asyncStartChatById,asyncGetChatById };