Add logs to try debug issue with thread view (#8628)

* Tidy up

* Add logs to try debug issue with thread view
This commit is contained in:
Michael Telatynski 2022-05-17 15:38:24 +01:00 committed by GitHub
parent e099ebd9ec
commit 83b3dfa341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 15 deletions

View file

@ -22,6 +22,7 @@ import { TimelineWindow } from 'matrix-js-sdk/src/timeline-window';
import { Direction } from 'matrix-js-sdk/src/models/event-timeline'; import { Direction } from 'matrix-js-sdk/src/models/event-timeline';
import { IRelationsRequestOpts } from 'matrix-js-sdk/src/@types/requests'; import { IRelationsRequestOpts } from 'matrix-js-sdk/src/@types/requests';
import classNames from "classnames"; import classNames from "classnames";
import { logger } from 'matrix-js-sdk/src/logger';
import BaseCard from "../views/right_panel/BaseCard"; import BaseCard from "../views/right_panel/BaseCard";
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases"; import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases";
@ -305,6 +306,14 @@ export default class ThreadView extends React.Component<IProps, IState> {
let timeline: JSX.Element; let timeline: JSX.Element;
if (this.state.thread) { if (this.state.thread) {
if (this.props.initialEvent && this.props.initialEvent.getRoomId() !== this.state.thread.roomId) {
logger.warn("ThreadView attempting to render TimelinePanel with mismatched initialEvent",
this.state.thread.roomId,
this.props.initialEvent.getRoomId(),
this.props.initialEvent.getId(),
);
}
timeline = <> timeline = <>
<FileDropTarget parent={this.card.current} onFileDrop={this.onFileDrop} /> <FileDropTarget parent={this.card.current} onFileDrop={this.onFileDrop} />
<TimelinePanel <TimelinePanel

View file

@ -29,6 +29,7 @@ import { logger } from "matrix-js-sdk/src/logger";
import { ClientEvent } from "matrix-js-sdk/src/client"; import { ClientEvent } from "matrix-js-sdk/src/client";
import { Thread } from 'matrix-js-sdk/src/models/thread'; import { Thread } from 'matrix-js-sdk/src/models/thread';
import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts"; import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
import { MatrixError } from 'matrix-js-sdk/src/http-api';
import SettingsStore from "../../settings/SettingsStore"; import SettingsStore from "../../settings/SettingsStore";
import { Layout } from "../../settings/enums/Layout"; import { Layout } from "../../settings/enums/Layout";
@ -1263,9 +1264,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
* @param {boolean?} scrollIntoView whether to scroll the event into view. * @param {boolean?} scrollIntoView whether to scroll the event into view.
*/ */
private loadTimeline(eventId?: string, pixelOffset?: number, offsetBase?: number, scrollIntoView = true): void { private loadTimeline(eventId?: string, pixelOffset?: number, offsetBase?: number, scrollIntoView = true): void {
this.timelineWindow = new TimelineWindow( const cli = MatrixClientPeg.get();
MatrixClientPeg.get(), this.props.timelineSet, this.timelineWindow = new TimelineWindow(cli, this.props.timelineSet, { windowLimit: this.props.timelineCap });
{ windowLimit: this.props.timelineCap });
const onLoaded = () => { const onLoaded = () => {
if (this.unmounted) return; if (this.unmounted) return;
@ -1290,8 +1290,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
// we're in a setState callback, and we know // we're in a setState callback, and we know
// timelineLoading is now false, so render() should have // timelineLoading is now false, so render() should have
// mounted the message panel. // mounted the message panel.
logger.log("can't initialise scroll state because " + logger.log("can't initialise scroll state because messagePanel didn't load");
"messagePanel didn't load");
return; return;
} }
@ -1305,15 +1304,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
}); });
}; };
const onError = (error) => { const onError = (error: MatrixError) => {
if (this.unmounted) return; if (this.unmounted) return;
this.setState({ timelineLoading: false }); this.setState({ timelineLoading: false });
logger.error( logger.error(`Error loading timeline panel at ${this.props.timelineSet.room?.roomId}/${eventId}: ${error}`);
`Error loading timeline panel at ${eventId}: ${error}`,
);
let onFinished; let onFinished: () => void;
// if we were given an event ID, then when the user closes the // if we were given an event ID, then when the user closes the
// dialog, let's jump to the end of the timeline. If we weren't, // 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> {
}); });
}; };
} }
let message;
let description: string;
if (error.errcode == 'M_FORBIDDEN') { if (error.errcode == 'M_FORBIDDEN') {
message = _t( description = _t(
"Tried to load a specific point in this room's timeline, but you " + "Tried to load a specific point in this room's timeline, but you " +
"do not have permission to view the message in question.", "do not have permission to view the message in question.",
); );
} else { } else {
message = _t( description = _t(
"Tried to load a specific point in this room's timeline, but was " + "Tried to load a specific point in this room's timeline, but was " +
"unable to find it.", "unable to find it.",
); );
} }
Modal.createTrackedDialog('Failed to load timeline position', '', ErrorDialog, { Modal.createTrackedDialog('Failed to load timeline position', '', ErrorDialog, {
title: _t("Failed to load timeline position"), title: _t("Failed to load timeline position"),
description: message, description,
onFinished: onFinished, onFinished,
}); });
}; };