forked from CringeStudios/gamja
Fix undefined CHATHISTORY_PAGE_SIZE
This commit is contained in:
parent
bfc0960200
commit
4d540d55ac
@ -13,7 +13,6 @@ import { SERVER_BUFFER, BufferType, ReceiptType, NetworkStatus, Unread } from "/
|
|||||||
import commands from "/commands.js";
|
import commands from "/commands.js";
|
||||||
import { setup as setupKeybindings } from "/keybindings.js";
|
import { setup as setupKeybindings } from "/keybindings.js";
|
||||||
|
|
||||||
const CHATHISTORY_PAGE_SIZE = 100;
|
|
||||||
const CHATHISTORY_MAX_SIZE = 4000;
|
const CHATHISTORY_MAX_SIZE = 4000;
|
||||||
|
|
||||||
const DEFAULT_NETWORK = "network"; // TODO: remove this global
|
const DEFAULT_NETWORK = "network"; // TODO: remove this global
|
||||||
@ -894,9 +893,8 @@ export default class App extends Component {
|
|||||||
// Avoids sending multiple CHATHISTORY commands in parallel
|
// Avoids sending multiple CHATHISTORY commands in parallel
|
||||||
this.endOfHistory.set(buf.id, true);
|
this.endOfHistory.set(buf.id, true);
|
||||||
|
|
||||||
var params = ["BEFORE", buf.name, "timestamp=" + before, CHATHISTORY_PAGE_SIZE];
|
client.fetchHistoryBefore(buf.name, before).then((result) => {
|
||||||
client.roundtripChatHistory(params).then((batch) => {
|
this.endOfHistory.set(buf.id, !result.more);
|
||||||
this.endOfHistory.set(buf.id, batch.messages.length < CHATHISTORY_PAGE_SIZE);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ const permanentCaps = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const RECONNECT_DELAY_SEC = 10;
|
const RECONNECT_DELAY_SEC = 10;
|
||||||
|
const CHATHISTORY_PAGE_SIZE = 100;
|
||||||
|
|
||||||
export default class Client extends EventTarget {
|
export default class Client extends EventTarget {
|
||||||
static Status = {
|
static Status = {
|
||||||
@ -396,6 +397,14 @@ export default class Client extends EventTarget {
|
|||||||
return this.pendingHistory;
|
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. */
|
/* Fetch history in ascending order. */
|
||||||
fetchHistoryBetween(target, after, before, limit) {
|
fetchHistoryBetween(target, after, before, limit) {
|
||||||
var max = Math.min(limit, CHATHISTORY_PAGE_SIZE);
|
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;
|
after.time = batch.messages[batch.messages.length - 1].tags.time;
|
||||||
return this.fetchHistoryBetween(target, after, before, limit);
|
return this.fetchHistoryBetween(target, after, before, limit);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user