You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-09-01 21:21:58 +03:00
fix lint errors
This commit is contained in:
@@ -199,8 +199,8 @@ Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline) {
|
|||||||
// Done after adding the event because otherwise the app would get a read receipt
|
// Done after adding the event because otherwise the app would get a read receipt
|
||||||
// pointing to an event that wasn't yet in the timeline
|
// pointing to an event that wasn't yet in the timeline
|
||||||
|
|
||||||
// This is really ugly because JS has no way to express an object literal where the
|
// This is really ugly because JS has no way to express an object literal
|
||||||
// name of a key comes from an expression
|
// where the name of a key comes from an expression
|
||||||
if (events[i].sender) {
|
if (events[i].sender) {
|
||||||
var fakeReceipt = {content: {}};
|
var fakeReceipt = {content: {}};
|
||||||
fakeReceipt.content[events[i].getId()] = {
|
fakeReceipt.content[events[i].getId()] = {
|
||||||
@@ -284,14 +284,17 @@ Room.prototype.addEvents = function(events, duplicateStrategy) {
|
|||||||
* @param {String} event_ids A list of event_ids to remove.
|
* @param {String} event_ids A list of event_ids to remove.
|
||||||
*/
|
*/
|
||||||
Room.prototype.removeEvents = function(event_ids) {
|
Room.prototype.removeEvents = function(event_ids) {
|
||||||
|
// avoids defining a function in the loop, which is a lint error
|
||||||
|
function eq(a, b) {
|
||||||
|
return a === b;
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < event_ids.length; ++i) {
|
for (var i = 0; i < event_ids.length; ++i) {
|
||||||
// NB. we supply reverse to search from the end,
|
// NB. we supply reverse to search from the end,
|
||||||
// on the assumption that recents events are much
|
// on the assumption that recents events are much
|
||||||
// more likley to be removed than older ones.
|
// more likley to be removed than older ones.
|
||||||
var removed = utils.removeElement(
|
var removed = utils.removeElement(
|
||||||
this.timeline, function(e) {
|
this.timeline, eq.bind(event_ids[i]), true
|
||||||
return e.getId() == event_ids[i];
|
|
||||||
}, true
|
|
||||||
);
|
);
|
||||||
if (removed !== false) {
|
if (removed !== false) {
|
||||||
this.emit("Room.timeline", removed, this, undefined, true);
|
this.emit("Room.timeline", removed, this, undefined, true);
|
||||||
|
@@ -152,10 +152,11 @@ module.exports.findElement = function(array, fn, reverse) {
|
|||||||
*/
|
*/
|
||||||
module.exports.removeElement = function(array, fn, reverse) {
|
module.exports.removeElement = function(array, fn, reverse) {
|
||||||
var i;
|
var i;
|
||||||
|
var removed;
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
for (i = array.length - 1; i >= 0; i--) {
|
for (i = array.length - 1; i >= 0; i--) {
|
||||||
if (fn(array[i], i, array)) {
|
if (fn(array[i], i, array)) {
|
||||||
var removed = array[i];
|
removed = array[i];
|
||||||
array.splice(i, 1);
|
array.splice(i, 1);
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
@@ -164,7 +165,7 @@ module.exports.removeElement = function(array, fn, reverse) {
|
|||||||
else {
|
else {
|
||||||
for (i = 0; i < array.length; i++) {
|
for (i = 0; i < array.length; i++) {
|
||||||
if (fn(array[i], i, array)) {
|
if (fn(array[i], i, array)) {
|
||||||
var removed = array[i];
|
removed = array[i];
|
||||||
array.splice(i, 1);
|
array.splice(i, 1);
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user