diff --git a/src/chat.js b/src/chat.js index 0c9eb3a..8fc8144 100644 --- a/src/chat.js +++ b/src/chat.js @@ -170,14 +170,10 @@ export default class Chat { 存储消息(data) { set(data.id, data, this.store) } - 载入消息() { - values(this.store).then(items => { - items.map(item => { - item.timestamp = new Date(item.time).getTime() - return item - }).sort((a, b) => a.timestamp - b.timestamp).forEach(item => { - this.添加元素(item) - }) + async 载入消息() { + const data = await values(this.store) + data.map(item => ({ timestamp: new Date(item.time).getTime(), ...item })).sort((a, b) => a.timestamp - b.timestamp).forEach(item => { + this.添加元素(item) }) } 发送消息(text) {