Commit 362709e0 by Sixong.Zhu

update detail name

parent 1f004f4f
......@@ -91,7 +91,7 @@ export const enum MessageType {
Voice = "voice",
GeneralOrderMsg = "general_order_msg",
Withdraw = "withdraw",
Action = "action"
Action = "action",
}
export const enum MessageHandled {
......@@ -129,6 +129,7 @@ export type MessageRequestResult = readonly Message[];
export interface BaseChatItemBusinessData {
model_name: string;
obj_id: string;
detail_name?: string;
}
export interface BaseChatItem extends BaseChatItemBusinessData {
......
......@@ -31,7 +31,7 @@ function uniqueMessages(
messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY>
) {
const arr = [...messages];
return unique(arr, function(item, all) {
return unique(arr, function (item, all) {
return all.findIndex((k) => k.id === item.id);
});
}
......@@ -327,7 +327,7 @@ export default {
state[ChatStore.STATE_CHAT_SENDING_MESSAGES] = [...current];
}
},
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function() {
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function () {
const setTimeoutId: { [key: string]: number } = {};
return (
state: ChatStoreState,
......@@ -386,6 +386,25 @@ export default {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ commit, state }) {
let cache = await dbController.getChatList();
for (const item of cache) {
if (item.business_data && !item.detail_name) {
const d = JSON.parse(
item.business_data
) as BaseChatItemBusinessData;
if (d) {
if (d.detail_name) {
item.detail_name = d.detail_name;
}
if (!item.obj_id && d.obj_id) {
item.obj_id = d.obj_id;
}
if (!item.model_name && d.model_name) {
item.model_name = d.model_name;
}
}
}
}
const buildUnreadMessage = (items: ChatType[]) => {
let sum = 0;
items.forEach((i) => (sum += i.unread_msg_count));
......@@ -760,7 +779,7 @@ export default {
}
commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function(item, all) {
unique(newChatMembers, function (item, all) {
return all.findIndex((k) => k.eid === item.eid);
})
);
......
......@@ -47,6 +47,8 @@ export interface Chat {
chat_id: number;
catalog: string;
biz_type_id: number;
business_data?: string;
detail_name?: string;
}
export interface Message {
......
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