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