From d74a71cc2d6be0a8ad70efda0f50414eea1b7649 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 17 Jun 2015 17:47:57 +0100 Subject: [PATCH] linting and update README. --- README.md | 5 ++++- lib/client.js | 2 +- lib/utils.js | 12 +++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 544678c7b..e929ea2cf 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,15 @@ events for incoming data and state changes. Aside from wrapping the HTTP API, it - Exposes high-level objects like `Rooms`, `RoomState`, `RoomMembers` and `Users` which can be listened to for things like name changes, new messages, membership changes, presence changes, and more. + - Handle "local echo" of messages sent using the SDK. This means that messages + that have just been sent will appear in the timeline as 'sending', until it + completes. This is beneficial because it prevents there being a gap between + hitting the send button and having the "remote echo" arrive. Later versions of the SDK will: - Automatically retry requests to send messages due to network errors. - Automatically retry requests to send messages due to rate limiting errors. - Mark events' sent status (e.g. 'not sent'). - - Handle "local echo" of messages sent. - Handle queueing of messages. - Handle pagination. - Expose a `RoomSummary` which would be suitable for a recents page. diff --git a/lib/client.js b/lib/client.js index 1e2294c21..f5527ac37 100644 --- a/lib/client.js +++ b/lib/client.js @@ -253,7 +253,7 @@ MatrixClient.prototype.sendEvent = function(roomId, eventType, content, txnId, } return this._http.authedRequest( callback, "PUT", path, undefined, content - ).then(function (res) { + ).then(function(res) { if (room && localEvent) { var eventId = res.event_id; // try to find an event with this event_id. If we find it, this is diff --git a/lib/utils.js b/lib/utils.js index 9005f3df4..51d305cc2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -123,15 +123,16 @@ module.exports.forEach = function(array, fn) { * the given function. */ module.exports.findElement = function(array, fn, reverse) { + var i; if (reverse) { - for (var i = array.length-1; i >= 0; i--) { + for (i = array.length - 1; i >= 0; i--) { if (fn(array[i], i, array)) { return array[i]; } } } else { - for (var i = 0; i < array.length; i++) { + for (i = 0; i < array.length; i++) { if (fn(array[i], i, array)) { return array[i]; } @@ -149,15 +150,16 @@ module.exports.findElement = function(array, fn, reverse) { * @param {boolean} reverse True to search in reverse order. */ module.exports.removeElement = function(array, fn, reverse) { + var i; if (reverse) { - for (var i = array.length-1; i >= 0; i--) { + for (i = array.length - 1; i >= 0; i--) { if (fn(array[i], i, array)) { array.splice(i, 1); - return; } + return; } } } else { - for (var i = 0; i < array.length; i++) { + for (i = 0; i < array.length; i++) { if (fn(array[i], i, array)) { array.splice(i, 1); return;