Add a way to toggle `ScrollPanel` and `TimelinePanel` debug logs (#8513)

Part of https://github.com/vector-im/element-web/issues/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);
```
pull/28217/head
Eric Eastwood 2022-05-06 11:13:23 -05:00 committed by GitHub
parent e97536ef96
commit 46ba14219c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 16 deletions

View File

@ -17,14 +17,13 @@ limitations under the License.
import React, { createRef, CSSProperties, ReactNode, KeyboardEvent } from "react"; import React, { createRef, CSSProperties, ReactNode, KeyboardEvent } from "react";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import SettingsStore from '../../settings/SettingsStore';
import Timer from '../../utils/Timer'; import Timer from '../../utils/Timer';
import AutoHideScrollbar from "./AutoHideScrollbar"; import AutoHideScrollbar from "./AutoHideScrollbar";
import { getKeyBindingsManager } from "../../KeyBindingsManager"; import { getKeyBindingsManager } from "../../KeyBindingsManager";
import ResizeNotifier from "../../utils/ResizeNotifier"; import ResizeNotifier from "../../utils/ResizeNotifier";
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts"; import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
const DEBUG_SCROLL = false;
// The amount of extra scroll distance to allow prior to unfilling. // The amount of extra scroll distance to allow prior to unfilling.
// See getExcessHeight. // See getExcessHeight.
const UNPAGINATION_PADDING = 6000; const UNPAGINATION_PADDING = 6000;
@ -36,13 +35,11 @@ const UNFILL_REQUEST_DEBOUNCE_MS = 200;
// much while the content loads. // much while the content loads.
const PAGE_SIZE = 400; const PAGE_SIZE = 400;
let debuglog; const debuglog = (...args: any[]) => {
if (DEBUG_SCROLL) { if (SettingsStore.getValue("debug_scroll_panel")) {
// using bind means that we get to keep useful line numbers in the console logger.log.call(console, "ScrollPanel debuglog:", ...args);
debuglog = logger.log.bind(console, "ScrollPanel debuglog:"); }
} else { };
debuglog = function() {};
}
interface IProps { interface IProps {
/* stickyBottom: if set to true, then once the user hits the bottom of /* stickyBottom: if set to true, then once the user hits the bottom of

View File

@ -61,13 +61,11 @@ const READ_RECEIPT_INTERVAL_MS = 500;
const READ_MARKER_DEBOUNCE_MS = 100; const READ_MARKER_DEBOUNCE_MS = 100;
const DEBUG = false; const debuglog = (...args: any[]) => {
if (SettingsStore.getValue("debug_timeline_panel")) {
let debuglog = function(...s: any[]) {}; logger.log.call(console, "TimelinePanel debuglog:", ...args);
if (DEBUG) { }
// using bind means that we get to keep useful line numbers in the console };
debuglog = logger.log.bind(console, "TimelinePanel debuglog:");
}
interface IProps { interface IProps {
// The js-sdk EventTimelineSet object for the timeline sequence we are // The js-sdk EventTimelineSet object for the timeline sequence we are

View File

@ -949,6 +949,14 @@ export const SETTINGS: {[setting: string]: ISetting} = {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
default: false, default: false,
}, },
"debug_scroll_panel": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false,
},
"debug_timeline_panel": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false,
},
[UIFeature.RoomHistorySettings]: { [UIFeature.RoomHistorySettings]: {
supportedLevels: LEVELS_UI_FEATURE, supportedLevels: LEVELS_UI_FEATURE,
default: true, default: true,