Don't stop fetching backlog on error

Some servers allow fetching history from some targets but not
others. Don't completely stop fetching chat history on error.

The root cause was a variable shadowing in Client.fetchBatch.
This commit is contained in:
Simon Ser 2021-11-10 09:53:17 +01:00
parent 1206cfae37
commit 195e4ca371
2 changed files with 5 additions and 3 deletions

View file

@ -1012,8 +1012,9 @@ export default class App extends Component {
fetchBacklog(client, target, after, before) {
client.fetchHistoryBetween(target, after, before, CHATHISTORY_MAX_SIZE).catch((err) => {
this.setState({ error: "Failed to fetch history for '" + target + "': " + err });
this.receipts.delete(channel);
console.error("Failed to fetch backlog for '" + target + "': ", err);
this.setState({ error: "Failed to fetch backlog for '" + target + "'" });
this.receipts.delete(target);
this.saveReceipts();
});
}

View file

@ -704,6 +704,7 @@ export default class Client extends EventTarget {
fetchBatch(msg, batchType) {
let batchName = null;
let messages = [];
let cmd = msg.command;
return this.roundtrip(msg, (msg) => {
if (batchName) {
let batch = msg.batch;
@ -729,7 +730,7 @@ export default class Client extends EventTarget {
}
break;
case "FAIL":
if (msg.params[0] === msg.command) {
if (msg.params[0] === cmd) {
throw msg;
}
break;