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

Commit 46ba142

Browse files
Add a way to toggle ScrollPanel and TimelinePanel debug logs (#8513)
Part of element-hq/element-web#21532 To better debug timeline issues when they crop up. Turn on: ```js mxSettingsStore.setValue('debug_scroll_panel', null, 'device', true); mxSettingsStore.setValue('debug_timeline_panel', null, 'device', true); ``` Turn off: ```js mxSettingsStore.setValue('debug_scroll_panel', null, 'device', false); mxSettingsStore.setValue('debug_timeline_panel', null, 'device', false); ```
1 parent e97536e commit 46ba142

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/components/structures/ScrollPanel.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ limitations under the License.
1717
import React, { createRef, CSSProperties, ReactNode, KeyboardEvent } from "react";
1818
import { logger } from "matrix-js-sdk/src/logger";
1919

20+
import SettingsStore from '../../settings/SettingsStore';
2021
import Timer from '../../utils/Timer';
2122
import AutoHideScrollbar from "./AutoHideScrollbar";
2223
import { getKeyBindingsManager } from "../../KeyBindingsManager";
2324
import ResizeNotifier from "../../utils/ResizeNotifier";
2425
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
2526

26-
const DEBUG_SCROLL = false;
27-
2827
// The amount of extra scroll distance to allow prior to unfilling.
2928
// See getExcessHeight.
3029
const UNPAGINATION_PADDING = 6000;
@@ -36,13 +35,11 @@ const UNFILL_REQUEST_DEBOUNCE_MS = 200;
3635
// much while the content loads.
3736
const PAGE_SIZE = 400;
3837

39-
let debuglog;
40-
if (DEBUG_SCROLL) {
41-
// using bind means that we get to keep useful line numbers in the console
42-
debuglog = logger.log.bind(console, "ScrollPanel debuglog:");
43-
} else {
44-
debuglog = function() {};
45-
}
38+
const debuglog = (...args: any[]) => {
39+
if (SettingsStore.getValue("debug_scroll_panel")) {
40+
logger.log.call(console, "ScrollPanel debuglog:", ...args);
41+
}
42+
};
4643

4744
interface IProps {
4845
/* stickyBottom: if set to true, then once the user hits the bottom of

src/components/structures/TimelinePanel.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ const READ_RECEIPT_INTERVAL_MS = 500;
6161

6262
const READ_MARKER_DEBOUNCE_MS = 100;
6363

64-
const DEBUG = false;
65-
66-
let debuglog = function(...s: any[]) {};
67-
if (DEBUG) {
68-
// using bind means that we get to keep useful line numbers in the console
69-
debuglog = logger.log.bind(console, "TimelinePanel debuglog:");
70-
}
64+
const debuglog = (...args: any[]) => {
65+
if (SettingsStore.getValue("debug_timeline_panel")) {
66+
logger.log.call(console, "TimelinePanel debuglog:", ...args);
67+
}
68+
};
7169

7270
interface IProps {
7371
// The js-sdk EventTimelineSet object for the timeline sequence we are

src/settings/Settings.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,14 @@ export const SETTINGS: {[setting: string]: ISetting} = {
949949
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
950950
default: false,
951951
},
952+
"debug_scroll_panel": {
953+
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
954+
default: false,
955+
},
956+
"debug_timeline_panel": {
957+
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
958+
default: false,
959+
},
952960
[UIFeature.RoomHistorySettings]: {
953961
supportedLevels: LEVELS_UI_FEATURE,
954962
default: true,

0 commit comments

Comments
 (0)