1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2026-01-03 23:22:30 +03:00

Manually patch up files which were formatted wrong

`eslint --fix` expands `if` statements incorrectly (wrong indentation).
This commit is contained in:
Kegan Dougal
2017-01-13 11:50:00 +00:00
parent 478550ec93
commit 5abf6b9f20
33 changed files with 298 additions and 306 deletions

View File

@@ -43,8 +43,8 @@ MockStorageApi.prototype = {
let keys = [];
for (let k in this.data) {
if (!this.data.hasOwnProperty(k)) {
continue;
}
continue;
}
keys.push(k);
}
this.keys = keys;

View File

@@ -144,8 +144,8 @@ describe("MatrixClient events", function() {
expect(user).toBeDefined();
expect(event).toBeDefined();
if (!user || !event) {
return;
}
return;
}
expect(event.event).toEqual(SYNC_DATA.presence.events[0]);
expect(user.presence).toEqual(

View File

@@ -123,9 +123,8 @@ describe("getEventTimeline support", function() {
let room = client.getRoom(roomId);
let timelineSet = room.getTimelineSets()[0];
expect(function() {
client.getEventTimeline(timelineSet, "event");
})
.toThrow();
client.getEventTimeline(timelineSet, "event");
}).toThrow();
}).catch(utils.failTest).done(done);
});
@@ -142,9 +141,8 @@ describe("getEventTimeline support", function() {
let room = client.getRoom(roomId);
let timelineSet = room.getTimelineSets()[0];
expect(function() {
client.getEventTimeline(timelineSet, "event");
})
.not.toThrow();
client.getEventTimeline(timelineSet, "event");
}).not.toThrow();
}).catch(utils.failTest).done(done);
httpBackend.flush().catch(utils.failTest);

View File

@@ -79,9 +79,8 @@ describe("MatrixClient retrying", function() {
// shouldn't be able to cancel the first message yet
expect(function() {
client.cancelPendingEvent(ev1);
})
.toThrow();
client.cancelPendingEvent(ev1);
}).toThrow();
}).respond(400); // fail the first message
httpBackend.flush().then(function() {

View File

@@ -132,8 +132,8 @@ describe("MatrixClient room timelines", function() {
"with EventStatus.SENDING and the right event.sender", function(done) {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
expect(room.timeline.length).toEqual(1);
@@ -170,8 +170,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
client.sendTextMessage(roomId, "I am a fish", "txn1").done(
function() {
@@ -202,8 +202,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
let promise = client.sendTextMessage(roomId, "I am a fish", "txn1");
httpBackend.flush("/sync", 1).done(function() {
@@ -239,8 +239,8 @@ describe("MatrixClient room timelines", function() {
" of the timeline.", function(done) {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
expect(room.timeline.length).toEqual(1);
@@ -299,8 +299,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
// sync response
expect(room.timeline.length).toEqual(1);
@@ -335,8 +335,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
expect(room.timeline.length).toEqual(1);
@@ -363,8 +363,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
expect(room.oldState.paginationToken).toBeDefined();
@@ -391,8 +391,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
let index = 0;
@@ -431,8 +431,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
httpBackend.flush("/sync", 1).then(function() {
let preNameEvent = room.timeline[room.timeline.length - 3];
@@ -455,8 +455,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
let nameEmitCount = 0;
client.on("Room.name", function(rm) {
@@ -502,8 +502,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
httpBackend.flush("/sync", 1).then(function() {
expect(room.currentState.getMembers().length).toEqual(4);
@@ -531,8 +531,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
httpBackend.flush("/messages", 1);
@@ -563,8 +563,8 @@ describe("MatrixClient room timelines", function() {
client.on("sync", function(state) {
if (state !== "PREPARED") {
return;
}
return;
}
let room = client.getRoom(roomId);
let emitCount = 0;

View File

@@ -91,8 +91,8 @@ HttpBackend.prototype = {
for (j = 0; j < this.expectedRequests.length; j++) {
expectedReq = this.expectedRequests[j];
if (path && path !== expectedReq.path) {
continue;
}
continue;
}
if (expectedReq.method === req.method &&
req.path.indexOf(expectedReq.path) !== -1) {
if (!expectedReq.data || (JSON.stringify(expectedReq.data) ===
@@ -242,32 +242,32 @@ function Request(opts, callback) {
Object.defineProperty(this, 'method', {
get: function() {
return opts.method;
},
return opts.method;
},
});
Object.defineProperty(this, 'path', {
get: function() {
return opts.uri;
},
return opts.uri;
},
});
Object.defineProperty(this, 'data', {
get: function() {
return opts.body;
},
return opts.body;
},
});
Object.defineProperty(this, 'queryParams', {
get: function() {
return opts.qs;
},
return opts.qs;
},
});
Object.defineProperty(this, 'headers', {
get: function() {
return opts.headers || {};
},
return opts.headers || {};
},
});
}

View File

@@ -122,11 +122,11 @@ module.exports.mkMembership = function(opts) {
membership: opts.mship,
};
if (opts.name) {
opts.content.displayname = opts.name;
}
opts.content.displayname = opts.name;
}
if (opts.url) {
opts.content.avatar_url = opts.url;
}
opts.content.avatar_url = opts.url;
}
return module.exports.mkEvent(opts);
};

View File

@@ -20,8 +20,8 @@ describe("EventTimeline", function() {
// XXX: this is a horrid hack; should use sinon or something instead to mock
let timelineSet = { room: { roomId: roomId }};
timelineSet.room.getUnfilteredTimelineSet = function() {
return timelineSet;
};
return timelineSet;
};
timeline = new EventTimeline(timelineSet);
});
@@ -74,12 +74,12 @@ describe("EventTimeline", function() {
];
expect(function() {
timeline.initialiseState(state);
}).not.toThrow();
timeline.initialiseState(state);
}).not.toThrow();
timeline.addEvent(event, false);
expect(function() {
timeline.initialiseState(state);
}).toThrow();
timeline.initialiseState(state);
}).toThrow();
});
});

View File

@@ -18,8 +18,8 @@ describe("realtime-callbacks", function() {
clock.useMock();
fakeDate = Date.now();
callbacks.setNow(function() {
return fakeDate;
});
return fakeDate;
});
});
afterEach(function() {

View File

@@ -221,8 +221,8 @@ describe("RoomMember", function() {
let roomState = {
getStateEvents: function(type) {
if (type !== "m.room.member") {
return [];
}
return [];
}
return [
utils.mkMembership({
event: true, mship: "join", room: roomId,

View File

@@ -106,8 +106,8 @@ describe("Room", function() {
it("should throw if duplicateStrategy isn't 'replace' or 'ignore'", function() {
expect(function() {
room.addLiveEvents(events, "foo");
}).toThrow();
room.addLiveEvents(events, "foo");
}).toThrow();
});
it("should replace a timeline event if dupe strategy is 'replace'", function() {
@@ -616,8 +616,8 @@ describe("Room", function() {
};
let setAliases = function(aliases, stateKey) {
if (!stateKey) {
stateKey = "flibble";
}
stateKey = "flibble";
}
stateLookup["m.room.aliases$" + stateKey] = utils.mkEvent({
type: "m.room.aliases", room: roomId, skey: stateKey, content: {
aliases: aliases,
@@ -633,8 +633,8 @@ describe("Room", function() {
};
let addMember = function(userId, state, opts) {
if (!state) {
state = "join";
}
state = "join";
}
opts = opts || {};
opts.room = roomId;
opts.mship = state;
@@ -652,8 +652,8 @@ describe("Room", function() {
let list = [];
for (let stateBlob in stateLookup) {
if (!stateLookup.hasOwnProperty(stateBlob)) {
continue;
}
continue;
}
if (stateBlob.indexOf(prefix) === 0) {
list.push(stateLookup[stateBlob]);
}
@@ -915,11 +915,11 @@ describe("Room", function() {
let content = {};
records.forEach(function(r) {
if (!content[r.eventId]) {
content[r.eventId] = {};
}
content[r.eventId] = {};
}
if (!content[r.eventId][r.type]) {
content[r.eventId][r.type] = {};
}
content[r.eventId][r.type] = {};
}
content[r.eventId][r.type][r.userId] = {
ts: r.ts,
};

View File

@@ -76,8 +76,8 @@ describe("MatrixScheduler", function() {
return waitTimeMs;
};
queueFn = function() {
return "yep";
};
return "yep";
};
let procCount = 0;
scheduler.setProcessFunction(function(ev) {

View File

@@ -16,17 +16,17 @@ let USER_ID = "userId";
*/
function createTimeline(numEvents, baseIndex) {
if (numEvents === undefined) {
numEvents = 3;
}
numEvents = 3;
}
if (baseIndex === undefined) {
baseIndex = 1;
}
baseIndex = 1;
}
// XXX: this is a horrid hack
let timelineSet = { room: { roomId: ROOM_ID }};
timelineSet.room.getUnfilteredTimelineSet = function() {
return timelineSet;
};
return timelineSet;
};
let timeline = new EventTimeline(timelineSet);
@@ -167,8 +167,8 @@ describe("TimelineWindow", function() {
let liveTimeline = createTimeline();
let room = {};
room.getLiveTimeline = function() {
return liveTimeline;
};
return liveTimeline;
};
let timelineWindow = new TimelineWindow(undefined, room);
timelineWindow.load(undefined, 2).then(function() {

View File

@@ -45,22 +45,22 @@ describe("utils", function() {
describe("findElement", function() {
it("should find only 1 element if there is a match", function() {
let matchFn = function() {
return true;
};
return true;
};
let arr = [55, 66, 77];
expect(utils.findElement(arr, matchFn)).toEqual(55);
});
it("should be able to find in reverse order", function() {
let matchFn = function() {
return true;
};
return true;
};
let arr = [55, 66, 77];
expect(utils.findElement(arr, matchFn, true)).toEqual(77);
});
it("should find nothing if the function never returns true", function() {
let matchFn = function() {
return false;
};
return false;
};
let arr = [55, 66, 77];
expect(utils.findElement(arr, matchFn)).toBeFalsy();
});
@@ -69,24 +69,24 @@ describe("utils", function() {
describe("removeElement", function() {
it("should remove only 1 element if there is a match", function() {
let matchFn = function() {
return true;
};
return true;
};
let arr = [55, 66, 77];
utils.removeElement(arr, matchFn);
expect(arr).toEqual([66, 77]);
});
it("should be able to remove in reverse order", function() {
let matchFn = function() {
return true;
};
return true;
};
let arr = [55, 66, 77];
utils.removeElement(arr, matchFn, true);
expect(arr).toEqual([55, 66]);
});
it("should remove nothing if the function never returns true", function() {
let matchFn = function() {
return false;
};
return false;
};
let arr = [55, 66, 77];
utils.removeElement(arr, matchFn);
expect(arr).toEqual(arr);
@@ -126,41 +126,41 @@ describe("utils", function() {
describe("checkObjectHasKeys", function() {
it("should throw for missing keys", function() {
expect(function() {
utils.checkObjectHasKeys({}, ["foo"]);
}).toThrow();
utils.checkObjectHasKeys({}, ["foo"]);
}).toThrow();
expect(function() {
utils.checkObjectHasKeys({
foo: "bar",
}, ["foo"]);
}).not.toThrow();
utils.checkObjectHasKeys({
foo: "bar",
}, ["foo"]);
}).not.toThrow();
});
});
describe("checkObjectHasNoAdditionalKeys", function() {
it("should throw for extra keys", function() {
expect(function() {
utils.checkObjectHasNoAdditionalKeys({
foo: "bar",
baz: 4,
}, ["foo"]);
}).toThrow();
utils.checkObjectHasNoAdditionalKeys({
foo: "bar",
baz: 4,
}, ["foo"]);
}).toThrow();
expect(function() {
utils.checkObjectHasNoAdditionalKeys({
foo: "bar",
}, ["foo"]);
}).not.toThrow();
utils.checkObjectHasNoAdditionalKeys({
foo: "bar",
}, ["foo"]);
}).not.toThrow();
});
});
describe("deepCompare", function() {
let assert = {
isTrue: function(x) {
expect(x).toBe(true);
},
expect(x).toBe(true);
},
isFalse: function(x) {
expect(x).toBe(false);
},
expect(x).toBe(false);
},
};
it("should handle primitives", function() {
@@ -217,11 +217,11 @@ describe("utils", function() {
// context variables so even if they have same toString(), they
// won't have same functionality
let func = function(x) {
return true;
};
return true;
};
let func2 = function(x) {
return true;
};
return true;
};
assert.isTrue(utils.deepCompare(func, func));
assert.isFalse(utils.deepCompare(func, func2));
assert.isTrue(utils.deepCompare({ a: { b: func } }, { a: { b: func } }));

View File

@@ -136,24 +136,24 @@ MatrixBaseApis.prototype.register = function(
callback
) {
if (auth === undefined) {
auth = {};
}
auth = {};
}
if (sessionId) {
auth.session = sessionId;
}
auth.session = sessionId;
}
let params = {
auth: auth,
};
if (username !== undefined && username !== null) {
params.username = username;
}
params.username = username;
}
if (password !== undefined && password !== null) {
params.password = password;
}
params.password = password;
}
if (bindEmail !== undefined && bindEmail !== null) {
params.bind_email = bindEmail;
}
params.bind_email = bindEmail;
}
if (guestAccessToken !== undefined && guestAccessToken !== null) {
params.guest_access_token = guestAccessToken;
}
@@ -185,8 +185,8 @@ MatrixBaseApis.prototype.registerGuest = function(opts, callback) {
MatrixBaseApis.prototype.registerRequest = function(data, kind, callback) {
let params = {};
if (kind) {
params.kind = kind;
}
params.kind = kind;
}
return this._http.request(
callback, "POST", "/register", params, data
@@ -435,8 +435,8 @@ MatrixBaseApis.prototype.redactEvent = function(roomId, eventId, callback) {
*/
MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) {
if (utils.isFunction(limit)) {
callback = limit; limit = undefined;
}
callback = limit; limit = undefined;
}
let path = utils.encodeUri("/rooms/$roomId/initialSync",
{$roomId: roomId}
);
@@ -689,8 +689,8 @@ MatrixBaseApis.prototype.getCurrentUploads = function() {
*/
MatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) {
if (utils.isFunction(info)) {
callback = info; info = undefined;
}
callback = info; info = undefined;
}
let path = info ?
utils.encodeUri("/profile/$userId/$info",

View File

@@ -212,8 +212,8 @@ MatrixClient.prototype.supportsVoip = function() {
*/
MatrixClient.prototype.getSyncState = function() {
if (!this._syncApi) {
return null;
}
return null;
}
return this._syncApi.getSyncState();
};
@@ -589,8 +589,8 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
}
opts = opts || {};
if (opts.syncRoom === undefined) {
opts.syncRoom = true;
}
opts.syncRoom = true;
}
let room = this.getRoom(roomIdOrAlias);
if (room && room.hasMembershipState(this.credentials.userId, "join")) {
@@ -807,8 +807,8 @@ MatrixClient.prototype.setPowerLevel = function(roomId, userId, powerLevel,
MatrixClient.prototype.sendEvent = function(roomId, eventType, content, txnId,
callback) {
if (utils.isFunction(txnId)) {
callback = txnId; txnId = undefined;
}
callback = txnId; txnId = undefined;
}
if (!txnId) {
txnId = this.makeTxnId();
@@ -950,8 +950,8 @@ function _sendEventHttpRequest(client, event) {
*/
MatrixClient.prototype.sendMessage = function(roomId, content, txnId, callback) {
if (utils.isFunction(txnId)) {
callback = txnId; txnId = undefined;
}
callback = txnId; txnId = undefined;
}
return this.sendEvent(
roomId, "m.room.message", content, txnId, callback
);
@@ -1016,11 +1016,11 @@ MatrixClient.prototype.sendEmoteMessage = function(roomId, body, txnId, callback
*/
MatrixClient.prototype.sendImageMessage = function(roomId, url, info, text, callback) {
if (utils.isFunction(text)) {
callback = text; text = undefined;
}
callback = text; text = undefined;
}
if (!text) {
text = "Image";
}
text = "Image";
}
let content = {
msgtype: "m.image",
url: url,
@@ -1340,8 +1340,8 @@ MatrixClient.prototype.kick = function(roomId, userId, reason, callback) {
function _setMembershipState(client, roomId, userId, membershipValue, reason,
callback) {
if (utils.isFunction(reason)) {
callback = reason; reason = undefined;
}
callback = reason; reason = undefined;
}
let path = utils.encodeUri(
"/rooms/$roomId/state/m.room.member/$userId",
@@ -1367,8 +1367,8 @@ function _setMembershipState(client, roomId, userId, membershipValue, reason,
*/
function _membershipChange(client, roomId, userId, membership, reason, callback) {
if (utils.isFunction(reason)) {
callback = reason; reason = undefined;
}
callback = reason; reason = undefined;
}
let path = utils.encodeUri("/rooms/$room_id/$membership", {
$room_id: roomId,
@@ -1547,8 +1547,8 @@ MatrixClient.prototype.dropFromPresenceList = function(callback, userIds) {
*/
MatrixClient.prototype.scrollback = function(room, limit, callback) {
if (utils.isFunction(limit)) {
callback = limit; limit = undefined;
}
callback = limit; limit = undefined;
}
limit = limit || 30;
let timeToWaitMs = 0;
@@ -2326,11 +2326,11 @@ MatrixClient.prototype._processRoomEventsSearch = function(searchResults, respon
// to avoid O(N^2) fail
let highlights = {};
room_events.highlights.forEach(function(hl) {
highlights[hl] = 1;
});
highlights[hl] = 1;
});
searchResults.highlights.forEach(function(hl) {
highlights[hl] = 1;
});
highlights[hl] = 1;
});
// turn it back into a list.
searchResults.highlights = Object.keys(highlights);
@@ -2842,12 +2842,9 @@ function checkTurnServers(client) {
};
client._turnServers = [servers];
// re-fetch when we're about to reach the TTL
client._checkTurnServersTimeoutID =
setTimeout(function() {
checkTurnServers(client);
},
(res.ttl || (60 * 60)) * 1000 * 0.9
);
client._checkTurnServersTimeoutID = setTimeout(() => {
checkTurnServers(client);
}, (res.ttl || (60 * 60)) * 1000 * 0.9);
}
}, function(err) {
console.error("Failed to get TURN URIs");

View File

@@ -89,11 +89,11 @@ module.exports = {
return null;
}
if (!width) {
width = 96;
}
width = 96;
}
if (!height) {
height = 96;
}
height = 96;
}
let params = {
width: width,
height: height,

View File

@@ -90,8 +90,8 @@ OutboundSessionInfo.prototype.sharedWithTooManyDevices = function(
) {
for (let userId in this.sharedWithDevices) {
if (!this.sharedWithDevices.hasOwnProperty(userId)) {
continue;
}
continue;
}
if (!devicesInRoom.hasOwnProperty(userId)) {
console.log("Starting new session because we shared with " + userId);
@@ -226,8 +226,8 @@ MegolmEncryption.prototype._ensureOutboundSession = function(devicesInRoom) {
// helper which returns the session prepared by prepareSession
function returnSession() {
return session;
}
return session;
}
// first wait for the previous share to complete
let prom = this._setupPromise.then(prepareSession);

View File

@@ -363,8 +363,8 @@ Crypto.prototype._doKeyDownloadForUsers = function(downloadUsers) {
let promise = deferred.promise.finally(function() {
let inProgress = self._keyDownloadsInProgressByUser[u];
utils.removeElement(inProgress, function(e) {
return e === promise;
});
return e === promise;
});
if (inProgress.length === 0) {
// no more downloads for this user; remove the element
delete self._keyDownloadsInProgressByUser[u];
@@ -614,11 +614,11 @@ Crypto.prototype.listDeviceKeys = function(userId) {
// sort by deviceid
result.sort(function(a, b) {
if (a.deviceId < b.deviceId) {
return -1;
}
return -1;
}
if (a.deviceId > b.deviceId) {
return 1;
}
return 1;
}
return 0;
});

View File

@@ -128,8 +128,8 @@ module.exports.ensureOlmSessionsForDevices = function(
for (let userId in devicesByUser) {
if (!devicesByUser.hasOwnProperty(userId)) {
continue;
}
continue;
}
result[userId] = {};
let devices = devicesByUser[userId];
for (let j = 0; j < devices.length; j++) {
@@ -164,8 +164,8 @@ module.exports.ensureOlmSessionsForDevices = function(
let otk_res = res.one_time_keys || {};
for (let userId in devicesByUser) {
if (!devicesByUser.hasOwnProperty(userId)) {
continue;
}
continue;
}
let userRes = otk_res[userId] || {};
let devices = devicesByUser[userId];
for (let j = 0; j < devices.length; j++) {

View File

@@ -86,14 +86,14 @@ FilterComponent.prototype._checkFields =
function(room_id, sender, event_type, contains_url) {
let literal_keys = {
"rooms": function(v) {
return room_id === v;
},
return room_id === v;
},
"senders": function(v) {
return sender === v;
},
return sender === v;
},
"types": function(v) {
return _matches_wildcard(event_type, v);
},
return _matches_wildcard(event_type, v);
},
};
let self = this;

View File

@@ -617,8 +617,8 @@ module.exports.MatrixHttpApi.prototype = {
if (this.opts.extraParams) {
for (let key in this.opts.extraParams) {
if (!this.opts.extraParams.hasOwnProperty(key)) {
continue;
}
continue;
}
queryParams[key] = this.opts.extraParams[key];
}
}

View File

@@ -170,12 +170,12 @@ EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flu
let events = [];
for (let evtype in evMap) {
if (!evMap.hasOwnProperty(evtype)) {
continue;
}
continue;
}
for (let stateKey in evMap[evtype]) {
if (!evMap[evtype].hasOwnProperty(stateKey)) {
continue;
}
continue;
}
events.push(evMap[evtype][stateKey]);
}
}
@@ -213,10 +213,9 @@ EventTimelineSet.prototype.findEventById = function(eventId) {
if (!tl) {
return undefined;
}
return utils.findElement(tl.getEvents(),
function(ev) {
return ev.getId() == eventId;
});
return utils.findElement(tl.getEvents(), function(ev) {
return ev.getId() == eventId;
});
};
/**

View File

@@ -78,11 +78,12 @@ EventTimeline.prototype.initialiseState = function(stateEvents) {
let oldStateEvents = utils.map(
utils.deepCopy(
stateEvents.map(function(mxEvent) {
return mxEvent.event;
})
), function(ev) {
return new MatrixEvent(ev);
});
return mxEvent.event;
})
),
function(ev) {
return new MatrixEvent(ev);
});
this._startState.setStateEvents(oldStateEvents);
this._endState.setStateEvents(stateEvents);

View File

@@ -343,8 +343,8 @@ utils.extend(module.exports.MatrixEvent.prototype, {
let key;
for (key in this.event) {
if (!this.event.hasOwnProperty(key)) {
continue;
}
continue;
}
if (!_REDACT_KEEP_KEY_MAP[key]) {
delete this.event[key];
}
@@ -354,8 +354,8 @@ utils.extend(module.exports.MatrixEvent.prototype, {
let content = this.getContent();
for (key in content) {
if (!content.hasOwnProperty(key)) {
continue;
}
continue;
}
if (!keeps[key]) {
delete content[key];
}
@@ -428,7 +428,7 @@ let _REDACT_KEEP_KEY_MAP = [
'event_id', 'type', 'room_id', 'user_id', 'state_key', 'prev_state',
'content', 'unsigned',
].reduce(function(ret, val) {
ret[val] = 1; return ret;
ret[val] = 1; return ret;
}, {});
// a map from event type to the .content keys we keep when an event is redacted

View File

@@ -190,8 +190,8 @@ RoomMember.prototype.getLastModifiedTime = function() {
RoomMember.prototype.getAvatarUrl =
function(baseUrl, width, height, resizeMethod, allowDefault, allowDirectLinks) {
if (allowDefault === undefined) {
allowDefault = true;
}
allowDefault = true;
}
if (!this.events.member && !allowDefault) {
return null;
}

View File

@@ -121,11 +121,11 @@ RoomState.prototype.setStateEvents = function(stateEvents) {
// update the core event dict
utils.forEach(stateEvents, function(event) {
if (event.getRoomId() !== self.roomId) {
return;
}
return;
}
if (!event.isState()) {
return;
}
return;
}
if (self.events[event.getType()] === undefined) {
self.events[event.getType()] = {};
@@ -146,11 +146,11 @@ RoomState.prototype.setStateEvents = function(stateEvents) {
// clashing names rather than progressively which only catches 1 of them).
utils.forEach(stateEvents, function(event) {
if (event.getRoomId() !== self.roomId) {
return;
}
return;
}
if (!event.isState()) {
return;
}
return;
}
if (event.getType() === "m.room.member") {
let userId = event.getStateKey();
@@ -314,8 +314,8 @@ RoomState.prototype.maySendStateEvent = function(stateEventType, userId) {
RoomState.prototype._maySendEventOfType = function(eventType, userId, state) {
let member = this.getMember(userId);
if (!member || member.membership == 'leave') {
return false;
}
return false;
}
let power_levels_event = this.getStateEvents('m.room.power_levels', '');

View File

@@ -310,8 +310,8 @@ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod,
allowDefault) {
let roomAvatarEvent = this.currentState.getStateEvents("m.room.avatar", "");
if (allowDefault === undefined) {
allowDefault = true;
}
allowDefault = true;
}
if (!roomAvatarEvent && !allowDefault) {
return null;
}
@@ -668,9 +668,8 @@ Room.prototype._handleRemoteEcho = function(remoteEvent, localEvent) {
utils.removeElement(
this._pendingEventList,
function(ev) {
return ev.getId() == oldEventId;
},
false
return ev.getId() == oldEventId;
}, false
);
}
@@ -778,9 +777,8 @@ Room.prototype.updatePendingEvent = function(event, newStatus, newEventId) {
utils.removeElement(
this._pendingEventList,
function(ev) {
return ev.getId() == oldEventId;
},
false
return ev.getId() == oldEventId;
}, false
);
}
this.removeEvent(oldEventId);
@@ -985,8 +983,8 @@ Room.prototype.addReceipt = function(event, fake) {
// }
// }
if (fake === undefined) {
fake = false;
}
fake = false;
}
if (!fake) {
this._addReceiptsToStructure(event, this._realReceipts);
// we don't bother caching real receipts by event ID

View File

@@ -38,13 +38,13 @@ function PushProcessor(client) {
for (let ruleIndex = 0; ruleIndex < ruleset.length; ++ruleIndex) {
let rule = ruleset[ruleIndex];
if (!rule.enabled) {
continue;
}
continue;
}
let rawrule = templateRuleToRaw(kind, rule, device);
if (!rawrule) {
continue;
}
continue;
}
if (ruleMatchesEvent(rawrule, ev)) {
rule.kind = kind;
@@ -68,8 +68,8 @@ function PushProcessor(client) {
break;
case 'room':
if (!tprule.rule_id) {
return null;
}
return null;
}
rawrule.conditions.push({
'kind': 'event_match',
'key': 'room_id',
@@ -78,8 +78,8 @@ function PushProcessor(client) {
break;
case 'sender':
if (!tprule.rule_id) {
return null;
}
return null;
}
rawrule.conditions.push({
'kind': 'event_match',
'key': 'user_id',
@@ -88,8 +88,8 @@ function PushProcessor(client) {
break;
case 'content':
if (!tprule.pattern) {
return null;
}
return null;
}
rawrule.conditions.push({
'kind': 'event_match',
'key': 'content.body',
@@ -131,13 +131,13 @@ function PushProcessor(client) {
let eventFulfillsRoomMemberCountCondition = function(cond, ev) {
if (!cond.is) {
return false;
}
return false;
}
let room = client.getRoom(ev.getRoomId());
if (!room || !room.currentState || !room.currentState.members) {
return false;
}
return false;
}
let memberCount = Object.keys(room.currentState.members).filter(function(m) {
return room.currentState.members[m].membership == 'join';
@@ -145,13 +145,13 @@ function PushProcessor(client) {
let m = cond.is.match(/^([=<>]*)([0-9]*)$/);
if (!m) {
return false;
}
return false;
}
let ineq = m[1];
let rhs = parseInt(m[2]);
if (isNaN(rhs)) {
return false;
}
return false;
}
switch (ineq) {
case '':
case '==':
@@ -178,8 +178,8 @@ function PushProcessor(client) {
let room = client.getRoom(ev.getRoomId());
if (!room || !room.currentState || !room.currentState.members ||
!room.currentState.getMember(client.credentials.userId)) {
return false;
}
return false;
}
let displayName = room.currentState.getMember(client.credentials.userId).name;
@@ -196,8 +196,8 @@ function PushProcessor(client) {
let eventFulfillsEventMatchCondition = function(cond, ev) {
let val = valueForDottedKey(cond.key, ev);
if (!val || typeof val != 'string') {
return false;
}
return false;
}
let pat;
if (cond.key == 'content.body') {
@@ -245,8 +245,8 @@ function PushProcessor(client) {
while (parts.length > 0) {
let thispart = parts.shift();
if (!val[thispart]) {
return null;
}
return null;
}
val = val[thispart];
}
return val;
@@ -254,11 +254,11 @@ function PushProcessor(client) {
let matchingRuleForEventWithRulesets = function(ev, rulesets) {
if (!rulesets || !rulesets.device) {
return null;
}
return null;
}
if (ev.getSender() == client.credentials.userId) {
return null;
}
return null;
}
let allDevNames = Object.keys(rulesets.device);
for (let i = 0; i < allDevNames.length; ++i) {
@@ -267,8 +267,8 @@ function PushProcessor(client) {
let matchingRule = matchingRuleFromKindSet(devrules, devname);
if (matchingRule) {
return matchingRule;
}
return matchingRule;
}
}
return matchingRuleFromKindSet(ev, rulesets.global);
};
@@ -276,8 +276,8 @@ function PushProcessor(client) {
let pushActionsForEventAndRulesets = function(ev, rulesets) {
let rule = matchingRuleForEventWithRulesets(ev, rulesets);
if (!rule) {
return {};
}
return {};
}
let actionObj = PushProcessor.actionListToActionsObject(rule.actions);
@@ -319,8 +319,8 @@ PushProcessor.actionListToActionsObject = function(actionlist) {
actionobj.notify = true;
} else if (typeof action === 'object') {
if (action.value === undefined) {
action.value = true;
}
action.value = true;
}
actionobj.tweaks[action.set_tweak] = action.value;
}
}

View File

@@ -203,8 +203,8 @@ module.exports.MatrixInMemoryStore.prototype = {
*/
storeFilter: function(filter) {
if (!filter) {
return;
}
return;
}
if (!this.filters[filter.userId]) {
this.filters[filter.userId] = {};
}

View File

@@ -46,8 +46,8 @@ function getFilterName(userId, suffix) {
function debuglog() {
if (!DEBUG) {
return;
}
return;
}
console.log(...arguments);
}
@@ -437,8 +437,8 @@ SyncApi.prototype.stop = function() {
}
this._running = false;
if (this._currentSyncRequest) {
this._currentSyncRequest.abort();
}
this._currentSyncRequest.abort();
}
if (this._keepAliveTimer) {
clearTimeout(this._keepAliveTimer);
this._keepAliveTimer = null;
@@ -452,8 +452,8 @@ SyncApi.prototype.stop = function() {
*/
SyncApi.prototype.retryImmediately = function() {
if (!this._connectionReturnedDefer) {
return false;
}
return false;
}
this._startKeepAlives(0);
return true;
};
@@ -703,8 +703,8 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
client.emit("Room", room);
}
stateEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
});
// Handle joins
@@ -803,17 +803,17 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
client.emit("Room", room);
}
stateEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
timelineEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
ephemeralEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
accountDataEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
});
// Handle leaves (e.g. kicked rooms)
@@ -836,14 +836,14 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
}
stateEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
timelineEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
accountDataEvents.forEach(function(e) {
client.emit("event", e);
});
client.emit("event", e);
});
});
// update the notification timeline, if appropriate.
@@ -1044,8 +1044,8 @@ SyncApi.prototype._processRoomEvents = function(room, stateEventList,
let oldStateEvents = utils.map(
utils.deepCopy(
stateEventList.map(function(mxEvent) {
return mxEvent.event;
})
return mxEvent.event;
})
), client.getEventMapper()
);
let stateEvents = stateEventList;

View File

@@ -162,12 +162,12 @@ TimelineWindow.prototype.canPaginate = function(direction) {
if (direction == EventTimeline.BACKWARDS) {
if (tl.index > tl.minIndex()) {
return true;
}
return true;
}
} else {
if (tl.index < tl.maxIndex()) {
return true;
}
return true;
}
}
return Boolean(tl.timeline.getNeighbouringTimeline(direction) ||

View File

@@ -29,8 +29,8 @@ module.exports.encodeParams = function(params) {
let qs = "";
for (let key in params) {
if (!params.hasOwnProperty(key)) {
continue;
}
continue;
}
qs += "&" + encodeURIComponent(key) + "=" +
encodeURIComponent(params[key]);
}
@@ -48,8 +48,8 @@ module.exports.encodeParams = function(params) {
module.exports.encodeUri = function(pathTemplate, variables) {
for (let key in variables) {
if (!variables.hasOwnProperty(key)) {
continue;
}
continue;
}
pathTemplate = pathTemplate.replace(
key, encodeURIComponent(variables[key])
);
@@ -99,8 +99,8 @@ module.exports.keys = function(obj) {
let keys = [];
for (let key in obj) {
if (!obj.hasOwnProperty(key)) {
continue;
}
continue;
}
keys.push(key);
}
return keys;
@@ -115,8 +115,8 @@ module.exports.values = function(obj) {
let values = [];
for (let key in obj) {
if (!obj.hasOwnProperty(key)) {
continue;
}
continue;
}
values.push(obj[key]);
}
return values;
@@ -237,8 +237,8 @@ module.exports.checkObjectHasKeys = function(obj, keys) {
module.exports.checkObjectHasNoAdditionalKeys = function(obj, allowedKeys) {
for (let key in obj) {
if (!obj.hasOwnProperty(key)) {
continue;
}
continue;
}
if (allowedKeys.indexOf(key) === -1) {
throw new Error("Unknown key: " + key);
}