Commit a07362f4 by 吴云建

会话优化

parent a18fd1f6
......@@ -168,13 +168,17 @@ export default class ModelChatList extends Vue {
await this.getList();
this.setSource(ChatStore.StateChatSourceDirection.Server);
this.scrollbar.update();
this.$onBeforeDestroy(
await this.sdk.model("UniplatChat").registerOnChange(this.onTransportMessage)
)
await this.sdk.model("UniplatChat").registerOnChange(this.onTransportMessage);
await this.sdk.model("general_order").registerOnChange(this.onTransportMessage);
}
onTransportMessage(e: any) {
let index = e.dataUpdates.findIndex(it => it.action === "startChat" || it.action === "csExitChat" || it.action === "finishChat");
let index = e.dataUpdates.findIndex(it => it.action === "startChat" ||
it.action === "createChat" ||
it.action === "csExitChat" ||
it.action === "finishChat" ||
it.action === "delete" && it.model === "general_order"
);
if (index > -1) {
this.refreshListDebounce();
}
......
......@@ -10,10 +10,8 @@
:class="{ selected: isSelected(item) }"
@click="goToChatRoom(item)"
>
<div
class="chat-avatar pos-rel"
:class="{ 'red-dot': item.unread_msg_count > 0 }"
>
<div class="red-dot" v-if="item.unread_msg_count > 0">
{{ item.unread_msg_count }}
</div>
<div class="chat-info">
<div
......@@ -115,7 +113,11 @@ export default class ChatList extends Vue {
private get chatRooms() {
const list = this.chatList?.list.filter(chat => chat.title.indexOf(this.searchKeyword) > -1) || [];
this.unReadMsgCount = list.filter(chat => chat.unread_msg_count > 0).length;
let unReadMsgCount = 0;
list.filter(chat => chat.unread_msg_count > 0).forEach(chat => {
unReadMsgCount += chat.unread_msg_count
})
this.unReadMsgCount = unReadMsgCount;
this.$emit("list-count-update", this.unReadMsgCount);
this.$eventHub.$emit(EVENTS.NewMsg, this.unReadMsgCount);
return list;
......@@ -223,6 +225,7 @@ export default class ChatList extends Vue {
}
.chat-list {
.chat-item {
position: relative;
cursor: pointer;
padding: 4px 15px 10px;
border-bottom: 1px solid #eee;
......@@ -233,24 +236,19 @@ export default class ChatList extends Vue {
&.selected {
background: #f0f0f0;
}
.chat-avatar {
display: inline-block;
vertical-align: middle;
width: 0;
height: 0;
margin-right: 5px;
&.red-dot::before {
content: "";
.red-dot {
position: absolute;
width: 8px;
height: 8px;
min-width: 14px;
height: 14px;
line-height: 14px;
padding: 0 2px;
background: #e87005;
border-radius: 50%;
border-radius: 7px;
z-index: 1;
right: 0px;
top: -4px;
}
right: 10px;
bottom: 10px;
font-size: 12px;
color: #fff;
}
.chat-info {
display: inline-block;
......
......@@ -568,10 +568,10 @@ export default {
commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID, info.uniplatId);
commit(ChatStore.MUTATION_INITING_CHAT);
removeRegisterChatEvents.forEach((k) => k());
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)
await Promise.all([
dispatch(ChatStore.ACTION_REGISTER_EVENT),
dispatch(ChatStore.ACTION_GET_CHAT_MESSAGES),
dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS),
dispatch(ChatStore.ACTION_GET_CHAT_MESSAGES)
]);
commit(ChatStore.MUTATION_SAVE_CHAT_TITLE, wantedChatRoom.title || chatId);
commit(ChatStore.MUTATION_INITING_CHAT_DONE);
......
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