Commit f1cbe413 by Sixong.Zhu

update setup

parent 9878c185
...@@ -53,7 +53,7 @@ export default class ChatList extends Vue { ...@@ -53,7 +53,7 @@ export default class ChatList extends Vue {
protected parseMesage(data: ChatItem) { protected parseMesage(data: ChatItem) {
if (data.last_msg_sender && data.last_msg_sender !== "0") { if (data.last_msg_sender && data.last_msg_sender !== "0") {
if (!this.userNames[data.last_msg_sender]) { if (this.userNames[data.last_msg_sender] === undefined) {
this.updateUserName({ id: data.last_msg_sender, name: "" }); this.updateUserName({ id: data.last_msg_sender, name: "" });
this.invoker this.invoker
.model("user") .model("user")
...@@ -65,7 +65,7 @@ export default class ChatList extends Vue { ...@@ -65,7 +65,7 @@ export default class ChatList extends Vue {
name: userInfo.row.first_name.display as string, name: userInfo.row.first_name.display as string,
}); });
}) })
.catch(() => { }); .catch(() => {});
} }
} }
if (data.last_msg_content === "") { if (data.last_msg_content === "") {
......
...@@ -222,8 +222,12 @@ ...@@ -222,8 +222,12 @@
private get messageBody(): { eid?: string; oid?: string; msg: any } { private get messageBody(): { eid?: string; oid?: string; msg: any } {
if (this.data) { if (this.data) {
const msg = this.data.msg;
try { try {
if (msg.startsWith("{")) {
return { ...this.data, msg: JSON.parse(this.data.msg) }; return { ...this.data, msg: JSON.parse(this.data.msg) };
}
return { ...this.data, msg: this.data.msg };
} catch { } catch {
return { return {
...this.data, ...this.data,
......
...@@ -390,7 +390,9 @@ export default { ...@@ -390,7 +390,9 @@ export default {
let sum = 0; let sum = 0;
items.forEach((i) => (sum += i.unread_msg_count)); items.forEach((i) => (sum += i.unread_msg_count));
state[ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT] = sum; state[ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT] = sum;
return items; return items.sort((x, y) =>
x.last_msg_ts < y.last_msg_ts ? 1 : -1
);
}; };
if (cache && cache.length) { if (cache && cache.length) {
......
...@@ -11,7 +11,9 @@ const userMapping: UserMapping = {}; ...@@ -11,7 +11,9 @@ const userMapping: UserMapping = {};
export const getUserMapping = () => userMapping; export const getUserMapping = () => userMapping;
export async function getUserInfo(eid: string) { export async function getUserInfo(eid: string) {
if (userMapping[eid] != null) return userMapping[eid]; if (userMapping[eid]) {
return userMapping[eid];
}
const info = await Chat.getSdk().model("user").detail(eid).query(); const info = await Chat.getSdk().model("user").detail(eid).query();
const data = { const data = {
name: info.row.first_name.value as string, name: info.row.first_name.value as string,
......
...@@ -70,11 +70,10 @@ class Chat { ...@@ -70,11 +70,10 @@ class Chat {
if (this._sdk) { if (this._sdk) {
const s = this._sdk(); const s = this._sdk();
return dbController.setup( return dbController.setup(
s.global.uid + s.global.uid + "-" + (s.global.initData.orgId || 0)
"-" +
(s.global.initData.orgId || 0)
); );
} }
return Promise.reject();
} }
public resetup(org: () => string | number) { public resetup(org: () => string | number) {
......
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