1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

fix lint errors

This commit is contained in:
Bruno Windels
2018-07-18 12:40:16 +02:00
parent 88f2f62945
commit 9a796f1383
6 changed files with 48 additions and 24 deletions

View File

@@ -769,7 +769,7 @@ MatrixClient.prototype.loadRoomMembersIfNeeded = function(roomId) {
} }
const membersPromise = this.joinedMembers(roomId); const membersPromise = this.joinedMembers(roomId);
room.setLazilyLoadedMembers(membersPromise); room.setLazilyLoadedMembers(membersPromise);
} };
/** /**
* Retrieve all known rooms. * Retrieve all known rooms.

View File

@@ -75,11 +75,11 @@ utils.inherits(EventTimelineSet, EventEmitter);
/** /**
* Sets the lazily loaded members. For now only joined members. * Sets the lazily loaded members. For now only joined members.
* @param {Profile[]} array with {avatar_url, display_name } tuples * @param {Profile[]} joinedMembers array with {avatar_url, display_name } tuples
*/ */
EventTimelineSet.prototype.setJoinedMembers = function(joinedMembers) { EventTimelineSet.prototype.setJoinedMembers = function(joinedMembers) {
this._timelines.forEach(tl => tl.setJoinedMembers(joinedMembers)); this._timelines.forEach((tl) => tl.setJoinedMembers(joinedMembers));
} };
/** /**
* Get the filter object this timeline set is filtered on, if any * Get the filter object this timeline set is filtered on, if any

View File

@@ -111,6 +111,12 @@ EventTimeline.prototype.initialiseState = function(stateEvents) {
* All attached listeners will keep receiving state updates from the new live timeline state. * All attached listeners will keep receiving state updates from the new live timeline state.
* The end state of this timeline gets replaced with an independent copy of the current RoomState, * The end state of this timeline gets replaced with an independent copy of the current RoomState,
* and will need a new pagination token if it ever needs to paginate forwards. * and will need a new pagination token if it ever needs to paginate forwards.
* @param {string} direction EventTimeline.BACKWARDS to get the state at the
* start of the timeline; EventTimeline.FORWARDS to get the state at the end
* of the timeline.
*
* @return {EventTimeline} the new timeline
*/ */
EventTimeline.prototype.forkLive = function(direction) { EventTimeline.prototype.forkLive = function(direction) {
const forkState = this.getState(direction); const forkState = this.getState(direction);
@@ -129,6 +135,12 @@ EventTimeline.prototype.forkLive = function(direction) {
/** /**
* Creates an independent timeline, inheriting the directional state from this timeline. * Creates an independent timeline, inheriting the directional state from this timeline.
*
* @param {string} direction EventTimeline.BACKWARDS to get the state at the
* start of the timeline; EventTimeline.FORWARDS to get the state at the end
* of the timeline.
*
* @return {EventTimeline} the new timeline
*/ */
EventTimeline.prototype.fork = function(direction) { EventTimeline.prototype.fork = function(direction) {
const forkState = this.getState(direction); const forkState = this.getState(direction);
@@ -148,12 +160,12 @@ EventTimeline.prototype.getRoomId = function() {
/** /**
* Sets the lazily loaded members. For now only joined members. * Sets the lazily loaded members. For now only joined members.
* @param {Profile[]} array with {avatar_url, display_name } tuples * @param {Profile[]} joinedMembers array with {avatar_url, display_name } tuples
*/ */
EventTimeline.prototype.setJoinedMembers = function(joinedMembers) { EventTimeline.prototype.setJoinedMembers = function(joinedMembers) {
this._startState.setJoinedMembers(joinedMembers); this._startState.setJoinedMembers(joinedMembers);
this._endState.setJoinedMembers(joinedMembers); this._endState.setJoinedMembers(joinedMembers);
} };
/** /**
* Get the filter for this timeline's timelineSet (if any) * Get the filter for this timeline's timelineSet (if any)

View File

@@ -66,7 +66,7 @@ utils.inherits(RoomMember, EventEmitter);
RoomMember.prototype.isLazyLoaded = function() { RoomMember.prototype.isLazyLoaded = function() {
return this._isLazilyLoaded; return this._isLazilyLoaded;
} };
/** /**
* Update this room member's membership event. May fire "RoomMember.name" if * Update this room member's membership event. May fire "RoomMember.name" if
@@ -102,8 +102,12 @@ RoomMember.prototype.setMembershipEvent = function(event, roomState) {
this.emit("RoomMember.name", event, this, oldName); this.emit("RoomMember.name", event, this, oldName);
} }
}; };
/** /**
* Update this room member from a lazily loaded member * Update this room member from a lazily loaded member
* @param {string} displayName
* @param {string} avatarUrl
* @param {RoomState} roomState the room state this member is part of, needed to disambiguate the display name
*/ */
RoomMember.prototype.setAsJoinedMember = function(displayName, avatarUrl, roomState) { RoomMember.prototype.setAsJoinedMember = function(displayName, avatarUrl, roomState) {
this.membership = "join"; this.membership = "join";
@@ -112,7 +116,7 @@ RoomMember.prototype.setAsJoinedMember = function(displayName, avatarUrl, roomSt
this._lazyLoadAvatarUrl = avatarUrl; this._lazyLoadAvatarUrl = avatarUrl;
this._isLazilyLoaded = true; this._isLazilyLoaded = true;
//TODO: race condition between existing membership events since started syncing //TODO: race condition between existing membership events since started syncing
} };
/** /**
* Update this room member's power level event. May fire * Update this room member's power level event. May fire
@@ -233,7 +237,7 @@ RoomMember.prototype.getDMInviter = function() {
return inviteSender; return inviteSender;
} }
} }
} };
/** /**
@@ -290,7 +294,7 @@ RoomMember.prototype.getMxcAvatarUrl = function() {
return this.user.avatarUrl; return this.user.avatarUrl;
} }
return null; return null;
} };
function calculateDisplayName(selfUserId, displayName, roomState) { function calculateDisplayName(selfUserId, displayName, roomState) {
if (!displayName) { if (!displayName) {

View File

@@ -151,17 +151,19 @@ RoomState.prototype.getStateEvents = function(eventType, stateKey) {
/** /**
* Creates a copy of this room state so that mutations to either won't affect the other. * Creates a copy of this room state so that mutations to either won't affect the other.
* @return {RoomState} the copy of the room state
*/ */
RoomState.prototype.clone = function() { RoomState.prototype.clone = function() {
const copy = new RoomState(this.roomId); const copy = new RoomState(this.roomId);
//freeze and pass all state events to copy //freeze and pass all state events to copy
Object.values(this.events).forEach(eventsByStateKey => { Object.values(this.events).forEach((eventsByStateKey) => {
const eventsForType = Object.values(eventsByStateKey); const eventsForType = Object.values(eventsByStateKey);
copy.setStateEvents(eventsForType); copy.setStateEvents(eventsForType);
}); });
// clone lazily loaded members // clone lazily loaded members
const lazyLoadedMembers = Object.values(this.members).filter(member => member.isLazyLoaded()); const lazyLoadedMembers = Object.values(this.members)
lazyLoadedMembers.forEach(m => { .filter((member) => member.isLazyLoaded());
lazyLoadedMembers.forEach((m) => {
copy._setJoinedMember(m.userId, m.rawDisplayName, m.getMxcAvatarUrl()); copy._setJoinedMember(m.userId, m.rawDisplayName, m.getMxcAvatarUrl());
}); });
return copy; return copy;
@@ -270,17 +272,17 @@ RoomState.prototype._updateMember = function(member) {
this.members[member.userId] = member; this.members[member.userId] = member;
this._joinedMemberCount = null; this._joinedMemberCount = null;
} };
/** /**
* Sets the lazily loaded members. For now only joined members. * Sets the lazily loaded members. For now only joined members.
* @param {Profile[]} array with {avatar_url, display_name } tuples * @param {Profile[]} joinedMembers array with {avatar_url, display_name } tuples
*/ */
RoomState.prototype.setJoinedMembers = function(joinedMembers) { RoomState.prototype.setJoinedMembers = function(joinedMembers) {
Object.entries(joinedMembers).forEach(([userId, details]) => { Object.entries(joinedMembers).forEach(([userId, details]) => {
this._setJoinedMember(userId, details.display_name, details.avatar_url); this._setJoinedMember(userId, details.display_name, details.avatar_url);
}); });
} };
RoomState.prototype._setJoinedMember = function(userId, displayName, avatarUrl) { RoomState.prototype._setJoinedMember = function(userId, displayName, avatarUrl) {
const member = new RoomMember(this.roomId, userId); const member = new RoomMember(this.roomId, userId);
@@ -304,7 +306,7 @@ RoomState.prototype._setJoinedMember = function(userId, displayName, avatarUrl)
else { else {
this.emit('RoomState.members', {}, self, member); this.emit('RoomState.members', {}, self, member);
} }
} };
/** /**
* Set the current typing event for this room. * Set the current typing event for this room.

View File

@@ -215,22 +215,28 @@ Room.prototype.getPendingEvents = function() {
Room.prototype.getLiveTimeline = function() { Room.prototype.getLiveTimeline = function() {
return this.getUnfilteredTimelineSet().getLiveTimeline(); return this.getUnfilteredTimelineSet().getLiveTimeline();
}; };
/** /**
* Get the lazy loading state, whether loading is needed or not. * Get the lazy loading state, whether loading is needed or not.
* @return {bool} whether or not the members of this room need to be loaded
*/ */
Room.prototype.membersNeedLoading = function() { Room.prototype.membersNeedLoading = function() {
return this._membersNeedLoading; return this._membersNeedLoading;
} };
/** /**
* Sets the lazily loaded members from the result of calling /joined_members * Sets the lazily loaded members from the result of calling /joined_members
* @param {Promise} promise with result of /joined_members endpoint * @param {Promise} joinedMembersPromise promise with result of /joined_members endpoint
*/ */
Room.prototype.setLazilyLoadedMembers = async function(joinedMembersPromise) { Room.prototype.setLazilyLoadedMembers = async function(joinedMembersPromise) {
this._membersNeedLoading = false; this._membersNeedLoading = false;
const members = await joinedMembersPromise; const members = await joinedMembersPromise;
this._timelineSets.forEach(tlSet => tlSet.setJoinedMembers(members.joined)); //wait 10 seconds
} await new Promise((resolve) => setTimeout(resolve, 5000));
console.log('set lazily loaded members!');
this._timelineSets.forEach((tlSet) => tlSet.setJoinedMembers(members.joined));
this.emit('Room', this);
};
/** /**
* Reset the live timeline of all timelineSets, and start new ones. * Reset the live timeline of all timelineSets, and start new ones.