diff --git a/web/rdfdbclient.ts b/web/rdfdbclient.ts --- a/web/rdfdbclient.ts +++ b/web/rdfdbclient.ts @@ -5,7 +5,7 @@ const log = debug("rdfdbclient"); export class RdfDbClient { private channel: RdfDbChannel; - _patchesToSend: Patch[]; + private patchesToSend: Patch[]; // Send and receive patches from rdfdb. Primarily used in SyncedGraph. // // What this should do, and does not yet, is keep the graph @@ -19,10 +19,10 @@ export class RdfDbClient { private applyPatch: (p: Patch) => void, setStatus: (status: string) => void ) { - this._patchesToSend = []; + this.patchesToSend = []; this.channel = new RdfDbChannel(patchSenderUrl); this.channel.statusDisplay.subscribe((st: string) => { - setStatus(st + `; ${this._patchesToSend.length} pending `); + setStatus(st + `; ${this.patchesToSend.length} pending `); }); this.channel.newConnection.subscribe(() => { this.clearGraphOnNewConnection(); @@ -40,7 +40,7 @@ export class RdfDbClient { sendPatch(patch: Patch) { log("queue patch to server ", patch.summary()); - this._patchesToSend.push(patch); + this.patchesToSend.push(patch); this._continueSending(); } @@ -51,11 +51,13 @@ export class RdfDbClient { async _continueSending() { // we could call this less often and coalesce patches together to optimize // the dragging cases. See rdfdb 'compactPatches' and 'processInbox'. - while (this._patchesToSend.length) { - const patch = this._patchesToSend.splice(0, 1)[0]; + while (this.patchesToSend.length) { + const patch = this.patchesToSend.splice(0, 1)[0]; const json = await patch.toJsonPatch(); const ret = this.channel.sendMessage(json); if (!ret) { + log('sendMessage failed- retrying') + this.patchesToSend.unshift(patch); setTimeout(this._continueSending.bind(this), 500); // this.disconnect()