Commit c81c9fb5 by Sixong.Zhu

update sort

parent 153f4070
Showing with 24 additions and 13 deletions
......@@ -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);
});
}
......@@ -334,7 +334,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,
......@@ -393,6 +393,8 @@ export default {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ commit, state }) {
let cache = await dbController.getChatList();
cache.sort((x, y) => (x.last_msg_ts < y.last_msg_ts ? 1 : -1));
for (const item of cache) {
if (item.business_data && !item.detail_name) {
const d = JSON.parse(
......@@ -836,7 +838,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);
})
);
......@@ -1054,16 +1056,25 @@ export default {
if (cache[id]) {
return Promise.resolve({ id, name: cache[id] });
}
return new Promise<{ id: string; name: string }>((resolve, reject) => {
Chat.getSdk().model("user")
.detail(id)
.query()
.then((userInfo: any) => {
const name = userInfo.row.first_name.display as string;
Vue.set(state[ChatStore.STATE_CHAT_USERNAME], id, name);
resolve({ id, name });
}).catch(reject);
});
return new Promise<{ id: string; name: string }>(
(resolve, reject) => {
Chat.getSdk()
.model("user")
.detail(id)
.query()
.then((userInfo: any) => {
const name = userInfo.row.first_name
.display as string;
Vue.set(
state[ChatStore.STATE_CHAT_USERNAME],
id,
name
);
resolve({ id, name });
})
.catch(reject);
}
);
},
},
getters: {
......
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