Fix undefined CHATHISTORY_PAGE_SIZE

This commit is contained in:
Simon Ser 2021-01-23 12:16:57 +01:00
parent bfc0960200
commit 4d540d55ac
2 changed files with 12 additions and 4 deletions

View file

@ -13,6 +13,7 @@ const permanentCaps = [
];
const RECONNECT_DELAY_SEC = 10;
const CHATHISTORY_PAGE_SIZE = 100;
export default class Client extends EventTarget {
static Status = {
@ -396,6 +397,14 @@ export default class Client extends EventTarget {
return this.pendingHistory;
}
/* Fetch one page of history before the given date. */
fetchHistoryBefore(target, before) {
var params = ["BEFORE", target, "timestamp=" + before, CHATHISTORY_PAGE_SIZE];
return this.roundtripChatHistory(params).then((batch) => {
return { more: batch.messages.length < CHATHISTORY_PAGE_SIZE };
});
}
/* Fetch history in ascending order. */
fetchHistoryBetween(target, after, before, limit) {
var max = Math.min(limit, CHATHISTORY_PAGE_SIZE);
@ -410,6 +419,7 @@ export default class Client extends EventTarget {
after.time = batch.messages[batch.messages.length - 1].tags.time;
return this.fetchHistoryBetween(target, after, before, limit);
}
return null;
});
}
}