避免重复ID

This commit is contained in:
2023-10-21 19:16:16 +08:00
parent 2808da61a0
commit d668b7236d
2 changed files with 6 additions and 3 deletions

View File

@ -208,8 +208,11 @@ export default class Chat {
]
}))
}
存储消息(data) {
set(data.id, data, this.store)
async 存储消息(data) {
// 检查id是否已经存在
const item = await get(data.id, this.store)
if (item) return;
await set(data.id, data, this.store)
}
发送消息(text) {
const name = '我'

View File

@ -175,7 +175,7 @@ clientList.setChannel('chat', {
}
if (data.type === 'list') {
console.log(client.name, `同步来 ${data.list.length} 条消息`)
chat.合并消息列表(data.list)
await chat.合并消息列表(data.list)
return
}
console.log('未知类型:', data.type)