only increment sent counter after successful send

otherwise the message doesn't get sent after coming back online
This commit is contained in:
Bruno Windels 2020-05-07 18:46:16 +02:00
parent b65da9b8a9
commit 24cb9e3f5c

View file

@ -31,7 +31,6 @@ export class SendQueue {
while (this._amountSent < this._pendingEvents.length) { while (this._amountSent < this._pendingEvents.length) {
const pendingEvent = this._pendingEvents.get(this._amountSent); const pendingEvent = this._pendingEvents.get(this._amountSent);
console.log("trying to send", pendingEvent.content.body); console.log("trying to send", pendingEvent.content.body);
this._amountSent += 1;
if (pendingEvent.remoteId) { if (pendingEvent.remoteId) {
continue; continue;
} }
@ -50,6 +49,7 @@ export class SendQueue {
console.log("writing remoteId now"); console.log("writing remoteId now");
await this._tryUpdateEvent(pendingEvent); await this._tryUpdateEvent(pendingEvent);
console.log("keep sending?", this._amountSent, "<", this._pendingEvents.length); console.log("keep sending?", this._amountSent, "<", this._pendingEvents.length);
this._amountSent += 1;
} }
} catch(err) { } catch(err) {
if (err instanceof ConnectionError) { if (err instanceof ConnectionError) {