Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 840a412

Browse files
authored
Merge pull request #4944 from matrix-org/travis/room-list/perf/log-disable
Add an option to disable room list logging, and improve logging
2 parents 42e1013 + cf154ec commit 840a412

File tree

9 files changed

+149
-93
lines changed

9 files changed

+149
-93
lines changed

src/@types/global.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ declare global {
3737
mx_RoomListStore2: RoomListStore2;
3838
mx_RoomListLayoutStore: RoomListLayoutStore;
3939
mxPlatformPeg: PlatformPeg;
40+
41+
// TODO: Remove flag before launch: https://github.com/vector-im/riot-web/issues/14231
42+
mx_QuietRoomListLogging: boolean;
4043
}
4144

4245
// workaround for https://github.com/microsoft/TypeScript/issues/30933

src/components/views/rooms/RoomList2.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ export default class RoomList2 extends React.Component<IProps, IState> {
219219

220220
private updateLists = () => {
221221
const newLists = RoomListStore.instance.orderedLists;
222-
console.log("new lists", newLists);
222+
if (!window.mx_QuietRoomListLogging) {
223+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
224+
console.log("new lists", newLists);
225+
}
223226

224227
this.setState({sublists: newLists}, () => {
225228
this.props.onResize();

src/components/views/rooms/RoomTile2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
256256
0
257257
));
258258
} else {
259-
console.log(`Unexpected tag ${tagId} applied to ${this.props.room.room_id}`);
259+
console.warn(`Unexpected tag ${tagId} applied to ${this.props.room.room_id}`);
260260
}
261261

262262
if ((ev as React.KeyboardEvent).key === Key.ENTER) {

src/stores/room-list/RoomListStore2.ts

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
104104
console.warn(`${activeRoomId} is current in RVS but missing from client - clearing sticky room`);
105105
this.algorithm.stickyRoom = null;
106106
} else if (activeRoom !== this.algorithm.stickyRoom) {
107-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
108-
console.log(`Changing sticky room to ${activeRoomId}`);
107+
if (!window.mx_QuietRoomListLogging) {
108+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
109+
console.log(`Changing sticky room to ${activeRoomId}`);
110+
}
109111
this.algorithm.stickyRoom = activeRoom;
110112
}
111113
}
@@ -169,15 +171,19 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
169171
console.warn(`Own read receipt was in unknown room ${room.roomId}`);
170172
return;
171173
}
172-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
173-
console.log(`[RoomListDebug] Got own read receipt in ${room.roomId}`);
174+
if (!window.mx_QuietRoomListLogging) {
175+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
176+
console.log(`[RoomListDebug] Got own read receipt in ${room.roomId}`);
177+
}
174178
await this.handleRoomUpdate(room, RoomUpdateCause.ReadReceipt);
175179
return;
176180
}
177181
} else if (payload.action === 'MatrixActions.Room.tags') {
178182
const roomPayload = (<any>payload); // TODO: Type out the dispatcher types
179-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
180-
console.log(`[RoomListDebug] Got tag change in ${roomPayload.room.roomId}`);
183+
if (!window.mx_QuietRoomListLogging) {
184+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
185+
console.log(`[RoomListDebug] Got tag change in ${roomPayload.room.roomId}`);
186+
}
181187
await this.handleRoomUpdate(roomPayload.room, RoomUpdateCause.PossibleTagChange);
182188
} else if (payload.action === 'MatrixActions.Room.timeline') {
183189
const eventPayload = (<any>payload); // TODO: Type out the dispatcher types
@@ -188,12 +194,16 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
188194
const roomId = eventPayload.event.getRoomId();
189195
const room = this.matrixClient.getRoom(roomId);
190196
const tryUpdate = async (updatedRoom: Room) => {
191-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
192-
console.log(`[RoomListDebug] Live timeline event ${eventPayload.event.getId()}` +
193-
` in ${updatedRoom.roomId}`);
194-
if (eventPayload.event.getType() === 'm.room.tombstone' && eventPayload.event.getStateKey() === '') {
197+
if (!window.mx_QuietRoomListLogging) {
195198
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
196-
console.log(`[RoomListDebug] Got tombstone event - trying to remove now-dead room`);
199+
console.log(`[RoomListDebug] Live timeline event ${eventPayload.event.getId()}` +
200+
` in ${updatedRoom.roomId}`);
201+
}
202+
if (eventPayload.event.getType() === 'm.room.tombstone' && eventPayload.event.getStateKey() === '') {
203+
if (!window.mx_QuietRoomListLogging) {
204+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
205+
console.log(`[RoomListDebug] Got tombstone event - trying to remove now-dead room`);
206+
}
197207
const newRoom = this.matrixClient.getRoom(eventPayload.event.getContent()['replacement_room']);
198208
if (newRoom) {
199209
// If we have the new room, then the new room check will have seen the predecessor
@@ -222,13 +232,17 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
222232
console.warn(`Event ${eventPayload.event.getId()} was decrypted in an unknown room ${roomId}`);
223233
return;
224234
}
225-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
226-
console.log(`[RoomListDebug] Decrypted timeline event ${eventPayload.event.getId()} in ${roomId}`);
235+
if (!window.mx_QuietRoomListLogging) {
236+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
237+
console.log(`[RoomListDebug] Decrypted timeline event ${eventPayload.event.getId()} in ${roomId}`);
238+
}
227239
await this.handleRoomUpdate(room, RoomUpdateCause.Timeline);
228240
} else if (payload.action === 'MatrixActions.accountData' && payload.event_type === 'm.direct') {
229241
const eventPayload = (<any>payload); // TODO: Type out the dispatcher types
230-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
231-
console.log(`[RoomListDebug] Received updated DM map`);
242+
if (!window.mx_QuietRoomListLogging) {
243+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
244+
console.log(`[RoomListDebug] Received updated DM map`);
245+
}
232246
const dmMap = eventPayload.event.getContent();
233247
for (const userId of Object.keys(dmMap)) {
234248
const roomIds = dmMap[userId];
@@ -251,45 +265,63 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
251265
const oldMembership = getEffectiveMembership(membershipPayload.oldMembership);
252266
const newMembership = getEffectiveMembership(membershipPayload.membership);
253267
if (oldMembership !== EffectiveMembership.Join && newMembership === EffectiveMembership.Join) {
254-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
255-
console.log(`[RoomListDebug] Handling new room ${membershipPayload.room.roomId}`);
268+
if (!window.mx_QuietRoomListLogging) {
269+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
270+
console.log(`[RoomListDebug] Handling new room ${membershipPayload.room.roomId}`);
271+
}
256272

257273
// If we're joining an upgraded room, we'll want to make sure we don't proliferate
258274
// the dead room in the list.
259275
const createEvent = membershipPayload.room.currentState.getStateEvents("m.room.create", "");
260276
if (createEvent && createEvent.getContent()['predecessor']) {
261-
console.log(`[RoomListDebug] Room has a predecessor`);
277+
if (!window.mx_QuietRoomListLogging) {
278+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
279+
console.log(`[RoomListDebug] Room has a predecessor`);
280+
}
262281
const prevRoom = this.matrixClient.getRoom(createEvent.getContent()['predecessor']['room_id']);
263282
if (prevRoom) {
264283
const isSticky = this.algorithm.stickyRoom === prevRoom;
265284
if (isSticky) {
266-
console.log(`[RoomListDebug] Clearing sticky room due to room upgrade`);
285+
if (!window.mx_QuietRoomListLogging) {
286+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
287+
console.log(`[RoomListDebug] Clearing sticky room due to room upgrade`);
288+
}
267289
await this.algorithm.setStickyRoomAsync(null);
268290
}
269291

270292
// Note: we hit the algorithm instead of our handleRoomUpdate() function to
271293
// avoid redundant updates.
272-
console.log(`[RoomListDebug] Removing previous room from room list`);
294+
if (!window.mx_QuietRoomListLogging) {
295+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
296+
console.log(`[RoomListDebug] Removing previous room from room list`);
297+
}
273298
await this.algorithm.handleRoomUpdate(prevRoom, RoomUpdateCause.RoomRemoved);
274299
}
275300
}
276301

277-
console.log(`[RoomListDebug] Adding new room to room list`);
302+
if (!window.mx_QuietRoomListLogging) {
303+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
304+
console.log(`[RoomListDebug] Adding new room to room list`);
305+
}
278306
await this.handleRoomUpdate(membershipPayload.room, RoomUpdateCause.NewRoom);
279307
return;
280308
}
281309

282310
if (oldMembership !== EffectiveMembership.Invite && newMembership === EffectiveMembership.Invite) {
283-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
284-
console.log(`[RoomListDebug] Handling invite to ${membershipPayload.room.roomId}`);
311+
if (!window.mx_QuietRoomListLogging) {
312+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
313+
console.log(`[RoomListDebug] Handling invite to ${membershipPayload.room.roomId}`);
314+
}
285315
await this.handleRoomUpdate(membershipPayload.room, RoomUpdateCause.NewRoom);
286316
return;
287317
}
288318

289319
// If it's not a join, it's transitioning into a different list (possibly historical)
290320
if (oldMembership !== newMembership) {
291-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
292-
console.log(`[RoomListDebug] Handling membership change in ${membershipPayload.room.roomId}`);
321+
if (!window.mx_QuietRoomListLogging) {
322+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
323+
console.log(`[RoomListDebug] Handling membership change in ${membershipPayload.room.roomId}`);
324+
}
293325
await this.handleRoomUpdate(membershipPayload.room, RoomUpdateCause.PossibleTagChange);
294326
return;
295327
}
@@ -299,8 +331,10 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
299331
private async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<any> {
300332
const shouldUpdate = await this.algorithm.handleRoomUpdate(room, cause);
301333
if (shouldUpdate) {
302-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
303-
console.log(`[DEBUG] Room "${room.name}" (${room.roomId}) triggered by ${cause} requires list update`);
334+
if (!window.mx_QuietRoomListLogging) {
335+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
336+
console.log(`[DEBUG] Room "${room.name}" (${room.roomId}) triggered by ${cause} requires list update`);
337+
}
304338
this.emit(LISTS_UPDATE_EVENT, this);
305339
}
306340
}
@@ -405,8 +439,10 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
405439
}
406440

407441
private onAlgorithmListUpdated = () => {
408-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
409-
console.log("Underlying algorithm has triggered a list update - refiring");
442+
if (!window.mx_QuietRoomListLogging) {
443+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
444+
console.log("Underlying algorithm has triggered a list update - refiring");
445+
}
410446
this.emit(LISTS_UPDATE_EVENT, this);
411447
};
412448

@@ -439,17 +475,21 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
439475
}
440476

441477
public addFilter(filter: IFilterCondition): void {
442-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
443-
console.log("Adding filter condition:", filter);
478+
if (!window.mx_QuietRoomListLogging) {
479+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
480+
console.log("Adding filter condition:", filter);
481+
}
444482
this.filterConditions.push(filter);
445483
if (this.algorithm) {
446484
this.algorithm.addFilterCondition(filter);
447485
}
448486
}
449487

450488
public removeFilter(filter: IFilterCondition): void {
451-
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
452-
console.log("Removing filter condition:", filter);
489+
if (!window.mx_QuietRoomListLogging) {
490+
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
491+
console.log("Removing filter condition:", filter);
492+
}
453493
const idx = this.filterConditions.indexOf(filter);
454494
if (idx >= 0) {
455495
this.filterConditions.splice(idx, 1);

0 commit comments

Comments
 (0)