Commit ccd1ce05 by Sixong.Zhu

update data contact

parent 2dd1a102
...@@ -212,11 +212,8 @@ export default class ModelChatList extends Vue { ...@@ -212,11 +212,8 @@ export default class ModelChatList extends Vue {
return { return {
id: it.id.value, id: it.id.value,
chat_id: it.ImChatId.value, chat_id: it.ImChatId.value,
business_data: { model_name: it.ModelName.value,
model_name: it.ModelName.value, obj_id: it.ObjId.value,
obj_id: it.ObjId.value,
detail_name: "",
},
last_msg_sender: it.LastSpeakUid.value, last_msg_sender: it.LastSpeakUid.value,
last_msg_content: it.LastMsgContent.value, last_msg_content: it.LastMsgContent.value,
last_msg_ts: it.LastMsgTime.value, last_msg_ts: it.LastMsgTime.value,
...@@ -294,8 +291,8 @@ export default class ModelChatList extends Vue { ...@@ -294,8 +291,8 @@ export default class ModelChatList extends Vue {
private async goToChatRoom(data: ChatType) { private async goToChatRoom(data: ChatType) {
await this._createChat({ await this._createChat({
modelName: data.business_data.model_name, modelName: data.model_name,
selectedListId: data.business_data.obj_id, selectedListId: data.obj_id,
uids: [], uids: [],
showByPage: true, showByPage: true,
}); });
...@@ -344,10 +341,9 @@ export default class ModelChatList extends Vue { ...@@ -344,10 +341,9 @@ export default class ModelChatList extends Vue {
const length = chats.length; const length = chats.length;
let count = 0; let count = 0;
chats.forEach((chat) => { chats.forEach((chat) => {
const { model_name, obj_id } = chat.business_data;
this.sdk this.sdk
.model(model_name) .model(chat.model_name)
.chat(+obj_id, this.global.org.id.toString()) .chat(+chat.obj_id, this.global.org.id.toString())
.startChat() .startChat()
.finally(() => { .finally(() => {
count++; count++;
......
...@@ -63,7 +63,8 @@ export default class ChatList extends Vue { ...@@ -63,7 +63,8 @@ export default class ChatList extends Vue {
id: data.last_msg_sender, id: data.last_msg_sender,
name: userInfo.row.first_name.display as string, name: userInfo.row.first_name.display as string,
}); });
}); })
.catch(() => {});
} }
} }
if (data.last_msg_content === "") { if (data.last_msg_content === "") {
......
...@@ -76,16 +76,12 @@ export default class WorkFlow extends Vue { ...@@ -76,16 +76,12 @@ export default class WorkFlow extends Vue {
private readonly startProcessIns!: startProcessDialog; private readonly startProcessIns!: startProcessDialog;
@Prop({ @Prop({
type: String,
required: true, required: true,
}) })
private readonly model_name!: string; private readonly model_name!: string;
@Prop({ @Prop({ required: true })
type: String, private readonly id!: string | number;
required: true,
})
private readonly id!: string;
@Prop({ @Prop({
type: String, type: String,
......
...@@ -8,14 +8,18 @@ class ChatCacheDatabaseController { ...@@ -8,14 +8,18 @@ class ChatCacheDatabaseController {
private readonly messageDatabases = new Map<string, IDBDatabase>(); private readonly messageDatabases = new Map<string, IDBDatabase>();
private uid = ""; private uid = "";
private readonly version = 1; private readonly listVersion = 1;
private readonly msgVersion = 1;
private readonly chatListKey = "chat-list"; private readonly chatListKey = "chat-list";
private readonly chatMessageKey = "chat-message"; private readonly chatMessageKey = "chat-message";
public setup(uid: string) { public setup(uid: string) {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
if (uid && indexedDB) { if (uid && indexedDB) {
const r = indexedDB.open((this.uid = uid), this.version); const r = indexedDB.open(
"u-" + (this.uid = uid),
this.listVersion
);
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this; const that = this;
const setupDb = () => { const setupDb = () => {
...@@ -56,7 +60,7 @@ class ChatCacheDatabaseController { ...@@ -56,7 +60,7 @@ class ChatCacheDatabaseController {
if (!t) { if (!t) {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
if (this.uid && indexedDB) { if (this.uid && indexedDB) {
const r = indexedDB.open(k, this.version); const r = indexedDB.open(k, this.msgVersion);
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this; const that = this;
const setupDb = () => { const setupDb = () => {
......
...@@ -160,22 +160,19 @@ export interface BaseChatItem { ...@@ -160,22 +160,19 @@ export interface BaseChatItem {
last_msg_ts: number; last_msg_ts: number;
members_updated: number; members_updated: number;
user_updated: number; user_updated: number;
model_name: string;
obj_id: string;
} }
export interface RawChatItem extends BaseChatItem { export interface RawChatItem extends BaseChatItem {
ext: string; ext: string;
business_data: string;
last_msg_content: string; last_msg_content: string;
business_data?: string;
} }
export interface TransferedChatItem extends BaseChatItem { export interface TransferedChatItem extends BaseChatItem {
chat_id: number; chat_id: number;
ext: string; ext: string;
business_data: {
detail_name: string;
model_name: string;
obj_id: string;
};
last_msg_content: { text?: string }; last_msg_content: { text?: string };
} }
......
...@@ -75,18 +75,15 @@ async function preCacheImgs(msgs: any[]) { ...@@ -75,18 +75,15 @@ async function preCacheImgs(msgs: any[]) {
} }
function buildChatItem(chat: RawChatItem) { function buildChatItem(chat: RawChatItem) {
let business_data; if (!chat.model_name && chat.business_data) {
if (chat.business_data) { const b = JSON.parse(chat.business_data) as {
business_data = JSON.parse(chat.business_data); model_name: string;
obj_id: string;
};
chat.model_name = b.model_name;
b.obj_id && (chat.obj_id = b.obj_id);
} }
if (business_data?.model_name == null) { return { ...chat, chat_id: chat.id } as ChatType;
business_data = null;
}
return {
...chat,
chat_id: chat.id,
business_data,
} as ChatType;
} }
const filterActiveChats = (items: RawChatItem[]) => { const filterActiveChats = (items: RawChatItem[]) => {
...@@ -485,13 +482,11 @@ export default { ...@@ -485,13 +482,11 @@ export default {
state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]; state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID];
if (uniplatId == null) return; if (uniplatId == null) return;
try { try {
const { business_data } = const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
const data = await sdk() const data = await sdk()
.model(business_data.model_name) .model(chat.model_name)
.chat(Number(business_data.obj_id), orgId()) .chat(Number(chat.obj_id), orgId())
.sendMsg(params.msgType, params.msg); .sendMsg(params.msgType, params.msg);
await dispatch(ChatStore.ACTION_GET_FRESH_MESSAGE); await dispatch(ChatStore.ACTION_GET_FRESH_MESSAGE);
return data; return data;
} catch (error) { } catch (error) {
...@@ -616,29 +611,15 @@ export default { ...@@ -616,29 +611,15 @@ export default {
state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? []; state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? [];
let wantedChatRoom = chatList.find((k) => k.chat_id === chatId); let wantedChatRoom = chatList.find((k) => k.chat_id === chatId);
if ( if (!wantedChatRoom) {
wantedChatRoom == null ||
wantedChatRoom.business_data == null
) {
const data = await xim.fetchChat(chatId); const data = await xim.fetchChat(chatId);
if (!data) { if (!data) {
return; return;
} }
const chat = data.args[0]; const chat = data.args[0];
let business_data;
if (chat.business_data) {
business_data = JSON.parse(chat.business_data);
}
if (business_data?.model_name == null) {
business_data = null;
}
if (!business_data) {
return;
}
wantedChatRoom = { wantedChatRoom = {
...chat, ...chat,
chat_id: chat.id, chat_id: chat.id,
business_data,
} as ChatType; } as ChatType;
commit(ChatStore.MUTATION_SAVE_SINGLE_CHAT, wantedChatRoom); commit(ChatStore.MUTATION_SAVE_SINGLE_CHAT, wantedChatRoom);
} else { } else {
...@@ -654,9 +635,8 @@ export default { ...@@ -654,9 +635,8 @@ export default {
commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_ID, chatId); commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_ID, chatId);
await getChatModelInfo( await getChatModelInfo(
wantedChatRoom.business_data.model_name, wantedChatRoom.model_name,
wantedChatRoom.business_data.obj_id, wantedChatRoom.obj_id
wantedChatRoom.business_data.detail_name
) )
.then((info) => { .then((info) => {
commit( commit(
...@@ -753,10 +733,7 @@ export default { ...@@ -753,10 +733,7 @@ export default {
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0]; const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0];
if (firstChat == null) return; if (firstChat == null) return;
await getChatModelInfo( await getChatModelInfo(firstChat.model_name, firstChat.obj_id);
firstChat.business_data.model_name,
firstChat.business_data.obj_id
);
await dispatch( await dispatch(
ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION,
firstChat.chat_id firstChat.chat_id
...@@ -765,7 +742,7 @@ export default { ...@@ -765,7 +742,7 @@ export default {
async [ChatStore.ACTION_CHAT_START_RECEPTION]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_START_RECEPTION]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id, orgId()).startChat(); await sdk().model(model_name).chat(obj_id, orgId()).startChat();
...@@ -775,7 +752,7 @@ export default { ...@@ -775,7 +752,7 @@ export default {
async [ChatStore.ACTION_CHAT_FINISH_RECEPTION]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_FINISH_RECEPTION]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id, orgId()).finishChat(); await sdk().model(model_name).chat(obj_id, orgId()).finishChat();
...@@ -785,7 +762,7 @@ export default { ...@@ -785,7 +762,7 @@ export default {
async [ChatStore.ACTION_CHAT_USER_EXIT]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_USER_EXIT]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id, orgId()).userExitChat(); await sdk().model(model_name).chat(obj_id, orgId()).userExitChat();
...@@ -795,7 +772,7 @@ export default { ...@@ -795,7 +772,7 @@ export default {
async [ChatStore.ACTION_CHAT_CS_EXIT]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_CS_EXIT]({ getters, dispatch }) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk().model(model_name).chat(obj_id, orgId()).csExitChat(); await sdk().model(model_name).chat(obj_id, orgId()).csExitChat();
...@@ -808,7 +785,7 @@ export default { ...@@ -808,7 +785,7 @@ export default {
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk() await sdk()
...@@ -824,7 +801,7 @@ export default { ...@@ -824,7 +801,7 @@ export default {
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk() await sdk()
...@@ -840,7 +817,7 @@ export default { ...@@ -840,7 +817,7 @@ export default {
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk() await sdk()
...@@ -856,7 +833,7 @@ export default { ...@@ -856,7 +833,7 @@ export default {
) { ) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat;
if (model_name == null) return; if (model_name == null) return;
if (obj_id == null) return; if (obj_id == null) return;
await sdk() await sdk()
......
...@@ -23,11 +23,8 @@ export interface Chat { ...@@ -23,11 +23,8 @@ export interface Chat {
last_msg_sender: string; last_msg_sender: string;
last_msg_content: string; last_msg_content: string;
last_msg_type: string; last_msg_type: string;
business_data: { model_name: string;
model_name: string; obj_id: string;
obj_id: string;
detail_name: string;
};
is_finish: boolean; is_finish: boolean;
is_deleted: boolean; is_deleted: boolean;
is_remove: boolean; is_remove: boolean;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment