Commit e7cdb23f by Sixong.Zhu

update for detail name

parent a33fdcc0
...@@ -100,7 +100,7 @@ export const enum MessageType { ...@@ -100,7 +100,7 @@ export const enum MessageType {
Withdraw = "withdraw", Withdraw = "withdraw",
MyPurchasePlan = "my_purchase_plan", MyPurchasePlan = "my_purchase_plan",
MyWelfare = "my_welfare", MyWelfare = "my_welfare",
QuestionAnswer ="question_answer" QuestionAnswer = "question_answer",
} }
export const enum MessageHandled { export const enum MessageHandled {
...@@ -137,6 +137,7 @@ export type MessageRequestResult = readonly Message[]; ...@@ -137,6 +137,7 @@ export type MessageRequestResult = readonly Message[];
export interface BaseChatItemBusinessData { export interface BaseChatItemBusinessData {
model_name: string; model_name: string;
obj_id: string; obj_id: string;
detail_name?: string;
} }
export interface BaseChatItem extends BaseChatItemBusinessData { export interface BaseChatItem extends BaseChatItemBusinessData {
......
...@@ -83,11 +83,18 @@ async function preCacheImgs(msgs?: any[]) { ...@@ -83,11 +83,18 @@ async function preCacheImgs(msgs?: any[]) {
} }
function buildChatItem(chat: RawChatItem) { function buildChatItem(chat: RawChatItem) {
if (!chat.model_name && chat.business_data) { if (chat.business_data) {
const b = JSON.parse(chat.business_data) as BaseChatItemBusinessData; const b = JSON.parse(chat.business_data) as BaseChatItemBusinessData;
if (!chat.model_name) {
chat.model_name = b.model_name; chat.model_name = b.model_name;
b.obj_id && (chat.obj_id = b.obj_id); b.obj_id && (chat.obj_id = b.obj_id);
} }
b.detail_name &&
!chat.detail_name &&
(chat.detail_name = b.detail_name);
}
return { ...chat, chat_id: chat.id } as ChatType; return { ...chat, chat_id: chat.id } as ChatType;
} }
...@@ -386,6 +393,25 @@ export default { ...@@ -386,6 +393,25 @@ export default {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ commit, state }) { async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ commit, state }) {
let cache = await dbController.getChatList(); 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[]) => { const buildUnreadMessage = (items: ChatType[]) => {
let sum = 0; let sum = 0;
items.forEach((i) => (sum += i.unread_msg_count)); items.forEach((i) => (sum += i.unread_msg_count));
...@@ -923,7 +949,10 @@ export default { ...@@ -923,7 +949,10 @@ export default {
return await Chat.getSdk() return await Chat.getSdk()
.model(currentChat.model_name) .model(currentChat.model_name)
.chat(currentChat.obj_id, orgId()) .chat(currentChat.obj_id, orgId())
.addMember(uids.map((id) => +id), -30) .addMember(
uids.map((id) => +id),
-30
)
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async [ChatStore.ACTION_CHAT_REMOVE_MEMBER]( async [ChatStore.ACTION_CHAT_REMOVE_MEMBER](
......
...@@ -47,6 +47,8 @@ export interface Chat { ...@@ -47,6 +47,8 @@ export interface Chat {
chat_id: number; chat_id: number;
catalog: string; catalog: string;
biz_type_id: number; biz_type_id: number;
business_data?: string;
detail_name?: string;
} }
export interface Message { 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