1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-19 16:42:09 +03:00

Fix linting errors

This commit is contained in:
Kegan Dougal
2015-07-21 17:20:35 +01:00
parent 90e778cb84
commit 358cdaf167
2 changed files with 11 additions and 4 deletions

View File

@@ -94,6 +94,13 @@ utils.inherits(Room, EventEmitter);
*/ */
Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline) { Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline) {
var stateContext = toStartOfTimeline ? this.oldState : this.currentState; var stateContext = toStartOfTimeline ? this.oldState : this.currentState;
function checkForRedaction(redactEvent) {
return function(e) {
return e.getId() === redactEvent.event.redacts;
};
}
for (var i = 0; i < events.length; i++) { for (var i = 0; i < events.length; i++) {
if (toStartOfTimeline && this._redactions.indexOf(events[i].getId()) >= 0) { if (toStartOfTimeline && this._redactions.indexOf(events[i].getId()) >= 0) {
continue; // do not add the redacted event. continue; // do not add the redacted event.
@@ -112,9 +119,9 @@ Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline) {
} }
if (events[i].getType() === "m.room.redaction") { if (events[i].getType() === "m.room.redaction") {
// try to remove the element // try to remove the element
var removed = utils.removeElement(this.timeline, function(e) { var removed = utils.removeElement(
return e.getId() === events[i].event.redacts this.timeline, checkForRedaction(events[i])
}, true); );
if (!removed && toStartOfTimeline) { if (!removed && toStartOfTimeline) {
// redactions will trickle in BEFORE the event redacted so make // redactions will trickle in BEFORE the event redacted so make
// a note of the redacted event; we'll check it later. // a note of the redacted event; we'll check it later.

View File

@@ -148,7 +148,7 @@ module.exports.findElement = function(array, fn, reverse) {
* function signature <code>fn(element, index, array)</code>. Return true to * function signature <code>fn(element, index, array)</code>. Return true to
* remove this element and break. * remove this element and break.
* @param {boolean} reverse True to search in reverse order. * @param {boolean} reverse True to search in reverse order.
* @return True if an element was removed. * @return {boolean} True if an element was removed.
*/ */
module.exports.removeElement = function(array, fn, reverse) { module.exports.removeElement = function(array, fn, reverse) {
var i; var i;