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

Add logs to try debug issue with thread view #8628

Merged
merged 2 commits into from
May 17, 2022
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
9 changes: 9 additions & 0 deletions src/components/structures/ThreadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { TimelineWindow } from 'matrix-js-sdk/src/timeline-window';
import { Direction } from 'matrix-js-sdk/src/models/event-timeline';
import { IRelationsRequestOpts } from 'matrix-js-sdk/src/@types/requests';
import classNames from "classnames";
import { logger } from 'matrix-js-sdk/src/logger';

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

let timeline: JSX.Element;
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 = <>
<FileDropTarget parent={this.card.current} onFileDrop={this.onFileDrop} />
<TimelinePanel
Expand Down
29 changes: 14 additions & 15 deletions src/components/structures/TimelinePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { logger } from "matrix-js-sdk/src/logger";
import { ClientEvent } from "matrix-js-sdk/src/client";
import { Thread } from 'matrix-js-sdk/src/models/thread';
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 { Layout } from "../../settings/enums/Layout";
Expand Down Expand Up @@ -1260,9 +1261,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
* @param {boolean?} scrollIntoView whether to scroll the event into view.
*/
private loadTimeline(eventId?: string, pixelOffset?: number, offsetBase?: number, scrollIntoView = true): void {
this.timelineWindow = new TimelineWindow(
MatrixClientPeg.get(), this.props.timelineSet,
{ windowLimit: this.props.timelineCap });
const cli = MatrixClientPeg.get();
this.timelineWindow = new TimelineWindow(cli, this.props.timelineSet, { windowLimit: this.props.timelineCap });

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

Expand All @@ -1302,15 +1301,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
});
};

const onError = (error) => {
const onError = (error: MatrixError) => {
if (this.unmounted) return;

this.setState({ timelineLoading: false });
logger.error(
`Error loading timeline panel at ${eventId}: ${error}`,
);
logger.error(`Error loading timeline panel at ${this.props.timelineSet.room?.roomId}/${eventId}: ${error}`);

let onFinished;
let onFinished: () => void;

// 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,
Expand All @@ -1326,22 +1323,24 @@ class TimelinePanel extends React.Component<IProps, IState> {
});
};
}
let message;

let description: string;
if (error.errcode == 'M_FORBIDDEN') {
message = _t(
description = _t(
"Tried to load a specific point in this room's timeline, but you " +
"do not have permission to view the message in question.",
);
} else {
message = _t(
description = _t(
"Tried to load a specific point in this room's timeline, but was " +
"unable to find it.",
);
}

Modal.createTrackedDialog('Failed to load timeline position', '', ErrorDialog, {
title: _t("Failed to load timeline position"),
description: message,
onFinished: onFinished,
description,
onFinished,
});
};

Expand Down