Commit d1311847 by Sixong.Zhu

Merge branch 'master' into pre

parents 66487887 8931da86
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Ref, Vue, Watch } from "vue-property-decorator"; import { Component, Ref, Vue, Watch } from "vue-property-decorator";
import ChatInput, { import ChatInput, {
FILE_INFO_CLASS, isFileElement,
isImageOrFile, isImageOrFile,
} from "../hybrid-input/index.vue"; } from "../hybrid-input/index.vue";
import { Message, MessageType } from "../model"; import { Message, MessageType } from "../model";
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
@Ref("chat-input") @Ref("chat-input")
private readonly chatInput!: ChatInput; private readonly chatInput!: ChatInput;
private sending = false;
@Watch("chatRoomVisible") @Watch("chatRoomVisible")
private whenChatRoomShow() { private whenChatRoomShow() {
if (!this.chatRoomVisible) return; if (!this.chatRoomVisible) return;
...@@ -58,27 +60,39 @@ ...@@ -58,27 +60,39 @@
} }
private async sendMessage(msg: ChildNode[]) { private async sendMessage(msg: ChildNode[]) {
if (this.chatIniting) { if (this.chatIniting || this.sending) {
return; return;
} }
const count = msg.length;
let finished = 0;
this.sending = true;
const onFinishedChanged = () => {
finished++;
if (finished === count) {
this.sending = false;
}
};
setTimeout(() => (this.sending = false), 3000);
for (const item of msg) { for (const item of msg) {
if (isImageOrFile(item)) { if (isImageOrFile(item)) {
if ((item as Element).classList.contains(FILE_INFO_CLASS)) { if (isFileElement(item)) {
await this.sendFile(item, MessageType.File).catch((e) => await this.sendFile(item, MessageType.File)
this.onError(e) .catch((e) => this.onError(e))
); .finally(onFinishedChanged);
} else { } else {
await this.sendFile(item, MessageType.Image).catch((e) => await this.sendFile(item, MessageType.Image)
this.onError(e) .catch((e) => this.onError(e))
); .finally(onFinishedChanged);
} }
continue; continue;
} }
if (item.textContent) { if (item.textContent) {
await this.sendText(item.textContent).catch((e) => await this.sendText(item.textContent)
this.onError(e) .catch((e) => this.onError(e))
); .finally(onFinishedChanged);
} else {
onFinishedChanged();
} }
} }
this.$emit("sent"); this.$emit("sent");
...@@ -166,7 +180,8 @@ ...@@ -166,7 +180,8 @@
console.error(e); console.error(e);
this.setMsg2Failed(index); this.setMsg2Failed(index);
this.chatInput && this.chatInput.updateUploadProgress(0); this.chatInput &&
this.chatInput.updateUploadProgress(0);
}); });
} }
} }
......
...@@ -125,6 +125,10 @@ ...@@ -125,6 +125,10 @@
); );
} }
export function isFileElement(node: ChildNode) {
return (node as Element).classList.contains(FILE_INFO_CLASS);
}
const limitedFileExtension = [ const limitedFileExtension = [
"ppt", "ppt",
"pptx", "pptx",
...@@ -149,9 +153,6 @@ ...@@ -149,9 +153,6 @@
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_CHAT_ID) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_CHAT_ID)
private readonly chatId!: ChatStore.STATE_CHAT_CURRENT_CHAT_ID; private readonly chatId!: ChatStore.STATE_CHAT_CURRENT_CHAT_ID;
@chatStore.Action(ChatStore.ACTION_GET_MY_CHAT_LIST)
protected readonly getMyChatList!: ChatStore.ACTION_GET_MY_CHAT_LIST;
@Ref("input") @Ref("input")
private readonly messageInputBox!: HTMLDivElement; private readonly messageInputBox!: HTMLDivElement;
...@@ -350,8 +351,6 @@ ...@@ -350,8 +351,6 @@
if (this.chatId) { if (this.chatId) {
chatCache[this.chatId] = []; chatCache[this.chatId] = [];
} }
this.getMyChatList();
}, 120); }, 120);
} }
......
...@@ -102,6 +102,7 @@ class WebMonitor { ...@@ -102,6 +102,7 @@ class WebMonitor {
options && options &&
options.userAgent && options.userAgent &&
msg.push(`UserAgent: ${window.navigator.userAgent}`); msg.push(`UserAgent: ${window.navigator.userAgent}`);
r.config && r.config.params && msg.push(`Params: ${r.config.params}`);
r.config && r.config.data && msg.push(`Payload: ${JSON.stringify(r.config.data)}`); r.config && r.config.data && msg.push(`Payload: ${JSON.stringify(r.config.data)}`);
msg.push( msg.push(
......
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