Commit 1ee879ff by Sixong.Zhu

update

parent 8b24464a
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
class="chat-input flex-none h-100" class="chat-input flex-none h-100"
v-if="hasInput" v-if="hasInput"
> >
<message-input @error="onError" /> <message-input @error="onError" @sent="onMessageSent" />
</div> </div>
</div> </div>
</div> </div>
...@@ -70,6 +70,11 @@ ...@@ -70,6 +70,11 @@
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR)
private readonly chatError!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR; private readonly chatError!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR;
@chatStore.Getter(ChatStore.GETTER_CURRENT_CURRENT_CHAT)
private readonly currentChat!: ChatStore.GETTER_CURRENT_CURRENT_CHAT;
private setting = 0;
private get hasInput() { private get hasInput() {
return this.isChatMember && this.chatError !== this.chatId; return this.isChatMember && this.chatError !== this.chatId;
} }
...@@ -131,6 +136,21 @@ ...@@ -131,6 +136,21 @@
private openPayMessage(id: number) { private openPayMessage(id: number) {
this.$emit("open-pay-message", id); this.$emit("open-pay-message", id);
} }
private onMessageSent() {
if (this.setting) {
clearTimeout(this.setting);
}
this.setting = setTimeout(
() =>
this.currentChat &&
Chat.setRead(
this.currentChat.model_name,
this.currentChat.obj_id
),
300
);
}
} }
</script> </script>
......
...@@ -146,14 +146,16 @@ class Chat { ...@@ -146,14 +146,16 @@ class Chat {
return Promise.resolve(uri); return Promise.resolve(uri);
} }
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
xim.open(uri, this.token).catch(reject).finally(() => { xim.open(uri, this.token)
this.registerXimEvent(); .catch(reject)
if (xim.isConnected()) { .finally(() => {
resolve(); this.registerXimEvent();
} else { if (xim.isConnected()) {
reject(new Error(`xim is not connected`)); resolve();
} } else {
}); reject(new Error(`xim is not connected`));
}
});
}); });
} }
...@@ -203,6 +205,15 @@ class Chat { ...@@ -203,6 +205,15 @@ class Chat {
public getAvatar() { public getAvatar() {
return this.defaultAvatar; return this.defaultAvatar;
} }
public setRead(model: string, obj: string) {
if (this.isBackend()) {
const sdk = this.getSdk();
if (sdk) {
sdk.getAxios().post(`/general/xim/model/${model}/${obj}/read`);
}
}
}
} }
export default new Chat(); export default new Chat();
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