diff --git a/node/src/client.js b/node/src/client.js index 36858cf..09c8b42 100644 --- a/node/src/client.js +++ b/node/src/client.js @@ -588,13 +588,23 @@ export default class PeerClient { * @param {string} req.mxid * @param {ChannelProps} req.channel_props * @param {?Long} req.sync_from - * @param {?Number} req.limit + * @param {?number} req.limit */ getChats = async (req) => { const talkChannel = await this.#getUserChannel(req.mxid, req.channel_props) const res = await talkChannel.getChatListFrom(req.sync_from) - if (res.success && 0 < req.limit && req.limit < res.result.length) { + if (!res.success) return res + + while (true) { + const nextRes = await talkChannel.getChatListFrom( + res.result[res.result.length - 1].logId + ) + if (!nextRes.success) return nextRes + if (!nextRes.result.length) break + res.result.push(...nextRes.result) + } + if (0 < req.limit && req.limit < res.result.length) { res.result.splice(0, res.result.length - req.limit) } return res