Commit 20e30833 by Sixong.Zhu

update

parent 4ea0d9d8
...@@ -16,6 +16,7 @@ import { GeneralOrderDirection } from "../model/order-product"; ...@@ -16,6 +16,7 @@ import { GeneralOrderDirection } from "../model/order-product";
class OrderService { class OrderService {
public readonly generalOrder = "general_order_info"; public readonly generalOrder = "general_order_info";
public readonly generalOrderPaymentModel = "general_order_payment_info"; public readonly generalOrderPaymentModel = "general_order_payment_info";
public readonly generalOrderDefaultDetailName = 'userOrderDetail';
private readonly commentModel = "uniplat_model_remark@general_order"; private readonly commentModel = "uniplat_model_remark@general_order";
private readonly fileModel = "general_order_payment_file_info"; private readonly fileModel = "general_order_payment_file_info";
......
...@@ -862,7 +862,7 @@ export default { ...@@ -862,7 +862,7 @@ export default {
await getChatModelInfo( await getChatModelInfo(
wantedChatRoom.model_name, wantedChatRoom.model_name,
wantedChatRoom.obj_id, wantedChatRoom.obj_id,
Chat.isBackend() ? wantedChatRoom.detail_name : '' wantedChatRoom.detail_name
) )
.then((info) => { .then((info) => {
commit( commit(
...@@ -966,7 +966,7 @@ export default { ...@@ -966,7 +966,7 @@ export default {
await getChatModelInfo( await getChatModelInfo(
firstChat.model_name, firstChat.model_name,
firstChat.obj_id, firstChat.obj_id,
Chat.isBackend() ? firstChat.detail_name : '' firstChat.detail_name
); );
await dispatch( await dispatch(
ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION,
......
import Chat from "../xim"; import Chat from "../xim";
import { orderService } from '../service/order';
export type ChatInfo = { export type ChatInfo = {
[eid: string]: any; [eid: string]: any;
...@@ -18,14 +19,28 @@ export interface ChatModelInfoData { ...@@ -18,14 +19,28 @@ export interface ChatModelInfoData {
data: any; data: any;
} }
const model2DetailNameMapping = new Map<string, string>();
function buildCache() {
if (!model2DetailNameMapping.size) {
// 用户端默认不使用chat内置的detailName(这个专属于服务端),所以这里加一层内置转换
if (!Chat.isBackend()) {
model2DetailNameMapping.set(orderService.generalOrder, orderService.generalOrderDefaultDetailName);
}
}
}
export async function getChatModelInfo( export async function getChatModelInfo(
modelName: string, modelName: string,
id: string | number, id: string | number,
detailname?: string, detailname?: string,
forceReload = false forceReload = false
) { ) {
buildCache();
const key = `${modelName}-${id}`; const key = `${modelName}-${id}`;
const detail = detailname ? model2DetailNameMapping.get(modelName) || detailname : detailname;
if (loadingKeys.has(key)) { if (loadingKeys.has(key)) {
return new Promise<ChatModelInfoData>((resolve) => return new Promise<ChatModelInfoData>((resolve) =>
waitingAction.push({ key, resolve }) waitingAction.push({ key, resolve })
...@@ -53,7 +68,7 @@ export async function getChatModelInfo( ...@@ -53,7 +68,7 @@ export async function getChatModelInfo(
loadingKeys.add(key); loadingKeys.add(key);
const info = await Chat.getSdk() const info = await Chat.getSdk()
.model(modelName) .model(modelName)
.detail(id + "", detailname) .detail(id + "", detail)
.query(); .query();
const data = info; const data = info;
chatInfo[key] = data; chatInfo[key] = data;
......
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