File size: 1,808 Bytes
8c4ec99 362ec6c 6b8fc2c 362ec6c 8c4ec99 6b8fc2c 362ec6c 8c4ec99 362ec6c 6b8fc2c 8c4ec99 6b8fc2c 362ec6c 8c4ec99 362ec6c 8c4ec99 362ec6c 6b8fc2c 362ec6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import { IDialog } from '@/interfaces/database/chat';
import chatService from '@/services/chatService';
import { message } from 'antd';
import { DvaModel } from 'umi';
export interface ChatModelState {
name: string;
dialogList: IDialog[];
}
const model: DvaModel<ChatModelState> = {
namespace: 'chatModel',
state: {
name: 'kate',
dialogList: [],
},
reducers: {
save(state, action) {
return {
...state,
...action.payload,
};
},
setDialogList(state, { payload }) {
return {
...state,
dialogList: payload,
};
},
},
effects: {
*getDialog({ payload }, { call, put }) {
const { data } = yield call(chatService.getDialog, payload);
},
*setDialog({ payload }, { call, put }) {
const { data } = yield call(chatService.setDialog, payload);
if (data.retcode === 0) {
yield put({ type: 'listDialog' });
message.success('Created successfully !');
}
},
*listDialog({ payload }, { call, put }) {
const { data } = yield call(chatService.listDialog, payload);
yield put({ type: 'setDialogList', payload: data.data });
},
*listConversation({ payload }, { call, put }) {
const { data } = yield call(chatService.listConversation, payload);
},
*getConversation({ payload }, { call, put }) {
const { data } = yield call(chatService.getConversation, payload);
},
*setConversation({ payload }, { call, put }) {
const { data } = yield call(chatService.setConversation, payload);
},
*completeConversation({ payload }, { call, put }) {
const { data } = yield call(chatService.completeConversation, payload);
},
},
};
export default model;
|