You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
fix some lint
This commit is contained in:
@@ -20,7 +20,7 @@ limitations under the License.
|
||||
|
||||
function _matches_wildcard(actual_value, filter_value) {
|
||||
if (filter_value.endsWith("*")) {
|
||||
type_prefix = filter_value.slice(0, -1);
|
||||
var type_prefix = filter_value.slice(0, -1);
|
||||
return actual_value.substr(0, type_prefix.length) === type_prefix;
|
||||
}
|
||||
else {
|
||||
@@ -47,7 +47,7 @@ function FilterComponent(filter_json) {
|
||||
this.not_senders = filter_json.not_senders || [];
|
||||
|
||||
this.contains_url = filter_json.contains_url || null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks with the filter component matches the given event
|
||||
@@ -97,7 +97,7 @@ FilterComponent.prototype.checkFields =
|
||||
}
|
||||
});
|
||||
|
||||
contains_url_filter = this.filter_json.contains_url;
|
||||
var contains_url_filter = this.filter_json.contains_url;
|
||||
if (contains_url_filter !== undefined) {
|
||||
if (contains_url_filter !== contains_url) {
|
||||
return false;
|
||||
|
||||
@@ -75,13 +75,14 @@ Filter.prototype.setDefinition = function(definition) {
|
||||
// "not_rooms": ["!123456:example.com"],
|
||||
// "state": {
|
||||
// "types": ["m.room.*"],
|
||||
// "not_rooms": ["!726s6s6q:example.com"]
|
||||
// "not_rooms": ["!726s6s6q:example.com"],
|
||||
// },
|
||||
// "timeline": {
|
||||
// "limit": 10,
|
||||
// "types": ["m.room.message"],
|
||||
// "not_rooms": ["!726s6s6q:example.com"],
|
||||
// "not_senders": ["@spam:example.com"]
|
||||
// "contains_url": true
|
||||
// },
|
||||
// "ephemeral": {
|
||||
// "types": ["m.receipt", "m.typing"],
|
||||
|
||||
@@ -73,7 +73,7 @@ utils.inherits(EventTimelineSet, EventEmitter);
|
||||
*/
|
||||
EventTimeline.prototype.getFilter = function() {
|
||||
return this._filter;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the filter object this timeline list is filtered on
|
||||
@@ -81,7 +81,7 @@ EventTimeline.prototype.getFilter = function() {
|
||||
*/
|
||||
EventTimeline.prototype.setFilter = function(filter) {
|
||||
this._filter = filter;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the live timeline for this room.
|
||||
@@ -223,8 +223,10 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
|
||||
}
|
||||
|
||||
if (this._filter) {
|
||||
var events = this._filter.filterRoomTimeline(events);
|
||||
if (!events) return;
|
||||
events = this._filter.filterRoomTimeline(events);
|
||||
if (!events) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var direction = toStartOfTimeline ? EventTimeline.BACKWARDS :
|
||||
@@ -370,7 +372,9 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
|
||||
EventTimelineSet.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||
if (this._filter) {
|
||||
var events = this._filter.filterRoomTimeline([event]);
|
||||
if (!events) return;
|
||||
if (!events) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var timeline = this._eventIdToTimeline[event.getId()];
|
||||
@@ -428,7 +432,7 @@ EventTimelineSet.prototype.addEventToTimeline = function(event, timeline, toStar
|
||||
var data = {
|
||||
timeline: timeline,
|
||||
liveEvent: !toStartOfTimeline && timeline == this._liveTimeline,
|
||||
filter: this._filter,
|
||||
timelineSet: this,
|
||||
};
|
||||
this.emit("Room.timeline", event, this.room, Boolean(toStartOfTimeline), false, data);
|
||||
};
|
||||
@@ -462,7 +466,7 @@ EventTimelineSet.prototype.removeEvent = function(eventId) {
|
||||
delete this._eventIdToTimeline[eventId];
|
||||
var data = {
|
||||
timeline: timeline,
|
||||
filter: this._filter,
|
||||
timelineSet: this,
|
||||
};
|
||||
this.emit("Room.timeline", removed, this.room, undefined, true, data);
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ EventTimeline.setEventMetadata = function(event, stateContext, toStartOfTimeline
|
||||
event.forwardLooking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove an event from the timeline
|
||||
|
||||
@@ -28,17 +28,6 @@ var EventTimeline = require("./event-timeline");
|
||||
var EventTimelineSet = require("./event-timeline-set");
|
||||
|
||||
|
||||
// var DEBUG = false;
|
||||
var DEBUG = true;
|
||||
|
||||
if (DEBUG) {
|
||||
// using bind means that we get to keep useful line numbers in the console
|
||||
var debuglog = console.log.bind(console);
|
||||
} else {
|
||||
var debuglog = function() {};
|
||||
}
|
||||
|
||||
|
||||
function synthesizeReceipt(userId, event, receiptType) {
|
||||
// console.log("synthesizing receipt for "+event.getId());
|
||||
// This is really ugly because JS has no way to express an object literal
|
||||
@@ -219,8 +208,6 @@ Room.prototype.getLiveTimeline = function(filterId) {
|
||||
* @fires module:client~MatrixClient#event:"Room.timelineReset"
|
||||
*/
|
||||
Room.prototype.resetLiveTimeline = function(backPaginationToken) {
|
||||
var newTimeline;
|
||||
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
this._timelineSets[i].resetLiveTimeline(backPaginationToken);
|
||||
}
|
||||
@@ -470,8 +457,13 @@ Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
||||
|
||||
/**
|
||||
* Add a timelineSet for this room with the given filter
|
||||
* @param {Filter} filter The filter to be applied to this timelineSet
|
||||
* @return {EventTimelineSet} The timelineSet
|
||||
*/
|
||||
Room.prototype.addFilteredTimelineSet = function(filter) {
|
||||
Room.prototype.getOrCreateFilteredTimelineSet = function(filter) {
|
||||
if (this._filteredTimelineSets[filter.filterId]) {
|
||||
return this._filteredTimelineSets[filter.filterId];
|
||||
}
|
||||
var timelineSet = new EventTimelineSet(
|
||||
this.roomId, this, {
|
||||
filter: filter,
|
||||
@@ -480,6 +472,7 @@ Room.prototype.addFilteredTimelineSet = function(filter) {
|
||||
reEmit(this, timelineSet, [ "Room.timeline" ]);
|
||||
this._filteredTimelineSets[filter.filterId] = timelineSet;
|
||||
this._timelineSets.push(timelineSet);
|
||||
return timelineSet;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -504,10 +497,11 @@ Room.prototype.removeFilteredTimelineSet = function(filter) {
|
||||
* @private
|
||||
*/
|
||||
Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
||||
var i;
|
||||
if (event.getType() === "m.room.redaction") {
|
||||
var redactId = event.event.redacts;
|
||||
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
for (i = 0; i < this._timelineSets.length; i++) {
|
||||
var timelineSet = this._timelineSets[i];
|
||||
// if we know about this event, redact its contents now.
|
||||
var redactedEvent = timelineSet.findEventById(redactId);
|
||||
@@ -541,7 +535,7 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
||||
}
|
||||
|
||||
// add to our timeline lists
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
for (i = 0; i < this._timelineSets.length; i++) {
|
||||
this._timelineSets[i].addLiveEvent(event, duplicateStrategy);
|
||||
}
|
||||
|
||||
@@ -787,17 +781,18 @@ Room.prototype.updatePendingEvent = function(event, newStatus, newEventId) {
|
||||
* @throws If <code>duplicateStrategy</code> is not falsey, 'replace' or 'ignore'.
|
||||
*/
|
||||
Room.prototype.addLiveEvents = function(events, duplicateStrategy) {
|
||||
var i;
|
||||
if (duplicateStrategy && ["replace", "ignore"].indexOf(duplicateStrategy) === -1) {
|
||||
throw new Error("duplicateStrategy MUST be either 'replace' or 'ignore'");
|
||||
}
|
||||
|
||||
// sanity check that the live timeline is still live
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
for (i = 0; i < this._timelineSets.length; i++) {
|
||||
var liveTimeline = this._timelineSets[i].getLiveTimeline();
|
||||
if (liveTimeline.getPaginationToken(EventTimeline.FORWARDS)) {
|
||||
throw new Error(
|
||||
"live timeline "+i+" is no longer live - it has a pagination token (" +
|
||||
timelineSet.getPaginationToken(EventTimeline.FORWARDS) + ")"
|
||||
liveTimeline.getPaginationToken(EventTimeline.FORWARDS) + ")"
|
||||
);
|
||||
}
|
||||
if (liveTimeline.getNeighbouringTimeline(EventTimeline.FORWARDS)) {
|
||||
@@ -807,7 +802,7 @@ Room.prototype.addLiveEvents = function(events, duplicateStrategy) {
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
for (i = 0; i < events.length; i++) {
|
||||
if (events[i].getType() === "m.typing") {
|
||||
this.currentState.setTypingEvent(events[i]);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ limitations under the License.
|
||||
|
||||
var q = require("q");
|
||||
var EventTimeline = require("./models/event-timeline");
|
||||
var EventTimelineSet = require("./models/event-timeline-set");
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user