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

Convert room list log setting to a real setting #5005

Merged
merged 1 commit into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ declare global {
mx_RoomListStore2: RoomListStore2;
mx_RoomListLayoutStore: RoomListLayoutStore;
mxPlatformPeg: PlatformPeg;

// TODO: Remove flag before launch: https://github.com/vector-im/riot-web/issues/14231
mx_LoudRoomListLogging: boolean;
}

// workaround for https://github.com/microsoft/TypeScript/issues/30933
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/rooms/RoomList2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { NotificationColor } from "../../../stores/notifications/NotificationCol
import { Action } from "../../../dispatcher/actions";
import { ViewRoomDeltaPayload } from "../../../dispatcher/payloads/ViewRoomDeltaPayload";
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
import SettingsStore from "../../../settings/SettingsStore";

// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14367

Expand Down Expand Up @@ -210,7 +211,7 @@ export default class RoomList2 extends React.Component<IProps, IState> {

private updateLists = () => {
const newLists = RoomListStore.instance.orderedLists;
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log("new lists", newLists);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class LabsUserSettingsTab extends React.Component {
<SettingsFlag name={"showHiddenEventsInTimeline"} level={SettingLevel.DEVICE} />
<SettingsFlag name={"lowBandwidth"} level={SettingLevel.DEVICE} />
<SettingsFlag name={"sendReadReceipts"} level={SettingLevel.ACCOUNT} />
<SettingsFlag name={"advancedRoomListLogging"} level={SettingLevel.DEVICE} />
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
"Try out new ways to ignore people (experimental)": "Try out new ways to ignore people (experimental)",
"Use the improved room list (will refresh to apply changes)": "Use the improved room list (will refresh to apply changes)",
"Support adding custom themes": "Support adding custom themes",
"Enable advanced debugging for the room list": "Enable advanced debugging for the room list",
"Show info about bridges in room settings": "Show info about bridges in room settings",
"Font size": "Font size",
"Use custom size": "Use custom size",
Expand Down
6 changes: 6 additions & 0 deletions src/settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ export const SETTINGS = {
supportedLevels: LEVELS_FEATURE,
default: false,
},
"advancedRoomListLogging": {
// TODO: Remove flag before launch: https://github.com/vector-im/riot-web/issues/14231
displayName: _td("Enable advanced debugging for the room list"),
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false,
},
"mjolnirRooms": {
supportedLevels: ['account'],
default: [],
Expand Down
48 changes: 30 additions & 18 deletions src/stores/room-list/RoomListStore2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {

private readonly watchedSettings = [
'feature_custom_tags',
'advancedRoomListLogging', // TODO: Remove watch: https://github.com/vector-im/riot-web/issues/14367
];

constructor() {
Expand Down Expand Up @@ -126,6 +127,9 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
if (this.enabled) {
console.log("⚡ new room list store engaged");
}
if (SettingsStore.getValue("advancedRoomListLogging")) {
console.warn("Advanced room list logging is enabled");
}
}

private async readAndCacheSettingsFromStore() {
Expand Down Expand Up @@ -154,7 +158,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
console.warn(`${activeRoomId} is current in RVS but missing from client - clearing sticky room`);
await this.algorithm.setStickyRoom(null);
} else if (activeRoom !== this.algorithm.stickyRoom) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`Changing sticky room to ${activeRoomId}`);
}
Expand Down Expand Up @@ -196,6 +200,14 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {

if (payload.action === 'setting_updated') {
if (this.watchedSettings.includes(payload.settingName)) {
// TODO: Remove with https://github.com/vector-im/riot-web/issues/14367
if (payload.settingName === "advancedRoomListLogging") {
// Log when the setting changes so we know when it was turned on in the rageshake
const enabled = SettingsStore.getValue("advancedRoomListLogging");
console.warn("Advanced room list logging is enabled? " + enabled);
return;
}

console.log("Regenerating room lists: Settings changed");
await this.readAndCacheSettingsFromStore();

Expand All @@ -218,7 +230,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
console.warn(`Own read receipt was in unknown room ${room.roomId}`);
return;
}
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Got own read receipt in ${room.roomId}`);
}
Expand All @@ -228,7 +240,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
}
} else if (payload.action === 'MatrixActions.Room.tags') {
const roomPayload = (<any>payload); // TODO: Type out the dispatcher types
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Got tag change in ${roomPayload.room.roomId}`);
}
Expand All @@ -243,13 +255,13 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
const roomId = eventPayload.event.getRoomId();
const room = this.matrixClient.getRoom(roomId);
const tryUpdate = async (updatedRoom: Room) => {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Live timeline event ${eventPayload.event.getId()}` +
` in ${updatedRoom.roomId}`);
}
if (eventPayload.event.getType() === 'm.room.tombstone' && eventPayload.event.getStateKey() === '') {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Got tombstone event - trying to remove now-dead room`);
}
Expand Down Expand Up @@ -282,15 +294,15 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
console.warn(`Event ${eventPayload.event.getId()} was decrypted in an unknown room ${roomId}`);
return;
}
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Decrypted timeline event ${eventPayload.event.getId()} in ${roomId}`);
}
await this.handleRoomUpdate(room, RoomUpdateCause.Timeline);
this.updateFn.trigger();
} else if (payload.action === 'MatrixActions.accountData' && payload.event_type === 'm.direct') {
const eventPayload = (<any>payload); // TODO: Type out the dispatcher types
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Received updated DM map`);
}
Expand All @@ -317,7 +329,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
const oldMembership = getEffectiveMembership(membershipPayload.oldMembership);
const newMembership = getEffectiveMembership(membershipPayload.membership);
if (oldMembership !== EffectiveMembership.Join && newMembership === EffectiveMembership.Join) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Handling new room ${membershipPayload.room.roomId}`);
}
Expand All @@ -326,15 +338,15 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
// the dead room in the list.
const createEvent = membershipPayload.room.currentState.getStateEvents("m.room.create", "");
if (createEvent && createEvent.getContent()['predecessor']) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Room has a predecessor`);
}
const prevRoom = this.matrixClient.getRoom(createEvent.getContent()['predecessor']['room_id']);
if (prevRoom) {
const isSticky = this.algorithm.stickyRoom === prevRoom;
if (isSticky) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Clearing sticky room due to room upgrade`);
}
Expand All @@ -343,15 +355,15 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {

// Note: we hit the algorithm instead of our handleRoomUpdate() function to
// avoid redundant updates.
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Removing previous room from room list`);
}
await this.algorithm.handleRoomUpdate(prevRoom, RoomUpdateCause.RoomRemoved);
}
}

if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Adding new room to room list`);
}
Expand All @@ -361,7 +373,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
}

if (oldMembership !== EffectiveMembership.Invite && newMembership === EffectiveMembership.Invite) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Handling invite to ${membershipPayload.room.roomId}`);
}
Expand All @@ -372,7 +384,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {

// If it's not a join, it's transitioning into a different list (possibly historical)
if (oldMembership !== newMembership) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Handling membership change in ${membershipPayload.room.roomId}`);
}
Expand All @@ -386,7 +398,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
private async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<any> {
const shouldUpdate = await this.algorithm.handleRoomUpdate(room, cause);
if (shouldUpdate) {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[DEBUG] Room "${room.name}" (${room.roomId}) triggered by ${cause} requires list update`);
}
Expand Down Expand Up @@ -509,7 +521,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
}

private onAlgorithmListUpdated = () => {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log("Underlying algorithm has triggered a list update - marking");
}
Expand Down Expand Up @@ -559,7 +571,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
}

public addFilter(filter: IFilterCondition): void {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log("Adding filter condition:", filter);
}
Expand All @@ -571,7 +583,7 @@ export class RoomListStore2 extends AsyncStoreWithClient<ActionPayload> {
}

public removeFilter(filter: IFilterCondition): void {
if (window.mx_LoudRoomListLogging) {
if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log("Removing filter condition:", filter);
}
Expand Down
Loading