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

Commit 83b3dfa

Browse files
authored
Add logs to try debug issue with thread view (#8628)
* Tidy up * Add logs to try debug issue with thread view
1 parent e099ebd commit 83b3dfa

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/components/structures/ThreadView.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { TimelineWindow } from 'matrix-js-sdk/src/timeline-window';
2222
import { Direction } from 'matrix-js-sdk/src/models/event-timeline';
2323
import { IRelationsRequestOpts } from 'matrix-js-sdk/src/@types/requests';
2424
import classNames from "classnames";
25+
import { logger } from 'matrix-js-sdk/src/logger';
2526

2627
import BaseCard from "../views/right_panel/BaseCard";
2728
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases";
@@ -305,6 +306,14 @@ export default class ThreadView extends React.Component<IProps, IState> {
305306

306307
let timeline: JSX.Element;
307308
if (this.state.thread) {
309+
if (this.props.initialEvent && this.props.initialEvent.getRoomId() !== this.state.thread.roomId) {
310+
logger.warn("ThreadView attempting to render TimelinePanel with mismatched initialEvent",
311+
this.state.thread.roomId,
312+
this.props.initialEvent.getRoomId(),
313+
this.props.initialEvent.getId(),
314+
);
315+
}
316+
308317
timeline = <>
309318
<FileDropTarget parent={this.card.current} onFileDrop={this.onFileDrop} />
310319
<TimelinePanel

src/components/structures/TimelinePanel.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { logger } from "matrix-js-sdk/src/logger";
2929
import { ClientEvent } from "matrix-js-sdk/src/client";
3030
import { Thread } from 'matrix-js-sdk/src/models/thread';
3131
import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
32+
import { MatrixError } from 'matrix-js-sdk/src/http-api';
3233

3334
import SettingsStore from "../../settings/SettingsStore";
3435
import { Layout } from "../../settings/enums/Layout";
@@ -1263,9 +1264,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
12631264
* @param {boolean?} scrollIntoView whether to scroll the event into view.
12641265
*/
12651266
private loadTimeline(eventId?: string, pixelOffset?: number, offsetBase?: number, scrollIntoView = true): void {
1266-
this.timelineWindow = new TimelineWindow(
1267-
MatrixClientPeg.get(), this.props.timelineSet,
1268-
{ windowLimit: this.props.timelineCap });
1267+
const cli = MatrixClientPeg.get();
1268+
this.timelineWindow = new TimelineWindow(cli, this.props.timelineSet, { windowLimit: this.props.timelineCap });
12691269

12701270
const onLoaded = () => {
12711271
if (this.unmounted) return;
@@ -1290,8 +1290,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
12901290
// we're in a setState callback, and we know
12911291
// timelineLoading is now false, so render() should have
12921292
// mounted the message panel.
1293-
logger.log("can't initialise scroll state because " +
1294-
"messagePanel didn't load");
1293+
logger.log("can't initialise scroll state because messagePanel didn't load");
12951294
return;
12961295
}
12971296

@@ -1305,15 +1304,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
13051304
});
13061305
};
13071306

1308-
const onError = (error) => {
1307+
const onError = (error: MatrixError) => {
13091308
if (this.unmounted) return;
13101309

13111310
this.setState({ timelineLoading: false });
1312-
logger.error(
1313-
`Error loading timeline panel at ${eventId}: ${error}`,
1314-
);
1311+
logger.error(`Error loading timeline panel at ${this.props.timelineSet.room?.roomId}/${eventId}: ${error}`);
13151312

1316-
let onFinished;
1313+
let onFinished: () => void;
13171314

13181315
// if we were given an event ID, then when the user closes the
13191316
// dialog, let's jump to the end of the timeline. If we weren't,
@@ -1329,22 +1326,24 @@ class TimelinePanel extends React.Component<IProps, IState> {
13291326
});
13301327
};
13311328
}
1332-
let message;
1329+
1330+
let description: string;
13331331
if (error.errcode == 'M_FORBIDDEN') {
1334-
message = _t(
1332+
description = _t(
13351333
"Tried to load a specific point in this room's timeline, but you " +
13361334
"do not have permission to view the message in question.",
13371335
);
13381336
} else {
1339-
message = _t(
1337+
description = _t(
13401338
"Tried to load a specific point in this room's timeline, but was " +
13411339
"unable to find it.",
13421340
);
13431341
}
1342+
13441343
Modal.createTrackedDialog('Failed to load timeline position', '', ErrorDialog, {
13451344
title: _t("Failed to load timeline position"),
1346-
description: message,
1347-
onFinished: onFinished,
1345+
description,
1346+
onFinished,
13481347
});
13491348
};
13501349

0 commit comments

Comments
 (0)