mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-28 18:26:19 -05:00
Prevent hole in history when reconnecting
This commit is contained in:
parent
f2c9fd1d7f
commit
962c05c066
1 changed files with 10 additions and 1 deletions
|
@ -870,15 +870,24 @@ export default class App extends Component {
|
|||
let now = irc.formatDate(new Date());
|
||||
client.fetchHistoryTargets(now, lastReceipt.time).then((targets) => {
|
||||
targets.forEach((target) => {
|
||||
let from = lastReceipt;
|
||||
|
||||
// Maybe we've just received a READ update from the
|
||||
// server, avoid over-fetching history
|
||||
let from = lastReceipt;
|
||||
let stored = this.bufferStore.get({ name: target.name, server: client.params });
|
||||
let readReceipt = getReceipt(stored, ReceiptType.READ);
|
||||
if (isReceiptBefore(from, readReceipt)) {
|
||||
from = readReceipt;
|
||||
}
|
||||
|
||||
// If we already have messages stored for the target,
|
||||
// fetch all messages we've missed
|
||||
let buf = State.getBuffer(this.state, { server: serverID, name: target.name });
|
||||
if (buf && buf.messages.length > 0) {
|
||||
let lastMsg = buf.messages[buf.messages.length - 1];
|
||||
from = receiptFromMessage(lastMsg);
|
||||
}
|
||||
|
||||
let to = { time: msg.tags.time || now };
|
||||
this.fetchBacklog(client, target.name, from, to);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue