DEBUG: 消息筛选

This commit is contained in:
2023-10-21 18:08:51 +08:00
parent 2dd39dc530
commit 17e16a4246
2 changed files with 9 additions and 0 deletions

View File

@ -143,6 +143,7 @@ export default class Chat {
})
}
async 筛选指定范围的消息({ start, end }) {
console.log('筛选指定范围的消息', start, end)
const data = await values(this.store)
return data.map(item => ({ timestamp: new Date(item.time).getTime(), ...item })).filter(item => {
const timestamp = new Date(item.time).getTime()

View File

@ -183,6 +183,14 @@ clientList.setChannel('chat', {
}
if (data.type === 'list') {
console.log(client.name, '发来消息列表:', data)
const last = localStorage.getItem('store-chat-default')
const lastTimestamp = new Date(last).getTime()
data.list.map(item => ({ timestamp: new Date(item.time).getTime(), ...item })).filter(item => {
const timestamp = new Date(item.time).getTime()
return timestamp >= lastTimestamp
}).forEach(item => {
console.log('消息不符合要求的时间区间', item)
})
chat.合并消息列表(data.list)
return
}