避免重复ID
This commit is contained in:
parent
2808da61a0
commit
d668b7236d
@ -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 = '我'
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user