改进 消息记录更新
This commit is contained in:
parent
16c87b4ab1
commit
89da46022b
@ -72,15 +72,19 @@ const chats = computed<ApiV1ChatsGet200Response>(() => {
|
|||||||
});
|
});
|
||||||
chatStore.getChats();
|
chatStore.getChats();
|
||||||
|
|
||||||
let waitUpdate = false;
|
let lastUpdate = null;
|
||||||
chatStore.$subscribe(() => {
|
chatStore.$subscribe(() => {
|
||||||
if (waitUpdate) {
|
if (lastUpdate === null) {
|
||||||
|
lastUpdate = new Date().getTime();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
waitUpdate = true;
|
if (lastUpdate !== null && new Date().getTime() - lastUpdate < 2 * 1000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
chatStore.getChats();
|
chatStore.getChats();
|
||||||
waitUpdate = false;
|
lastUpdate = new Date().getTime();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user