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

Commit 8d61226

Browse files
committed
Raw refreshLiveTimeline usage that seems to work
1 parent ed910bb commit 8d61226

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

Diff for: src/components/structures/MessagePanel.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,8 @@ export default class MessagePanel extends React.Component<IProps, IState> {
10211021
"mx_MessagePanel_narrow": this.context.narrow,
10221022
});
10231023

1024+
//console.log('MessagePanel: render', this.props.events.length)
1025+
10241026
return (
10251027
<ErrorBoundary>
10261028
<ScrollPanel

Diff for: src/components/structures/RoomStatusBar.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
9494
syncStateData: this.context.getSyncStateData(),
9595
unsentMessages: getUnsentMessages(this.props.room),
9696
isResending: false,
97-
timelineNeedsRefresh: this.props.room.getTimelineNeedsRefresh(),
97+
timelineNeedsRefresh: true // TODO: Put this back to this.props.room.getTimelineNeedsRefresh(),
9898
};
9999
}
100100

@@ -153,10 +153,13 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
153153
// clear the timeline. I also tried to split out
154154
// `scrollbackFromPaginationToken` from the `scrollback` method in to
155155
// paginate from the beginning of the room but it's just not right.
156+
this.props.room.refreshLiveTimeline();
157+
//timelinePanel.refreshTimeline();
156158

157-
this.setState({
158-
timelineNeedsRefresh: false,
159-
});
159+
// TODO: Uncomment
160+
// this.setState({
161+
// timelineNeedsRefresh: false,
162+
// });
160163
};
161164

162165
private onRoomLocalEchoUpdated = (ev: MatrixEvent, room: Room) => {

Diff for: src/components/structures/RoomView.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -2065,11 +2065,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
20652065
highlightedEventId = this.state.initialEventId;
20662066
}
20672067

2068+
const timelineSet = this.state.room.getUnfilteredTimelineSet();
2069+
console.log('RoomView: timelineSet', timelineSet);
2070+
20682071
// console.info("ShowUrlPreview for %s is %s", this.state.room.roomId, this.state.showUrlPreview);
20692072
const messagePanel = (
20702073
<TimelinePanel
20712074
ref={this.gatherTimelinePanelRef}
2072-
timelineSet={this.state.room.getUnfilteredTimelineSet()}
2075+
timelineSet={timelineSet}
20732076
showReadReceipts={this.state.showReadReceipts}
20742077
manageReadReceipts={!this.state.isPeeking}
20752078
sendReadReceiptOnLoad={!this.state.wasContextSwitch}

Diff for: src/components/structures/TimelinePanel.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
280280
const cli = MatrixClientPeg.get();
281281
cli.on(RoomEvent.Timeline, this.onRoomTimeline);
282282
cli.on(RoomEvent.TimelineReset, this.onRoomTimelineReset);
283+
this.props.timelineSet.room.on(RoomEvent.TimelineRefresh, this.onRoomTimelineRefresh);
283284
cli.on(RoomEvent.Redaction, this.onRoomRedaction);
284285
if (SettingsStore.getValue("feature_msc3531_hide_messages_pending_moderation")) {
285286
// Make sure that events are re-rendered when their visibility-pending-moderation changes.
@@ -370,6 +371,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
370371
client.removeListener(MatrixEventEvent.VisibilityChange, this.onEventVisibilityChange);
371372
client.removeListener(ClientEvent.Sync, this.onSync);
372373
}
374+
375+
this.props.timelineSet.room.removeListener(RoomEvent.TimelineRefresh, this.onRoomTimelineRefresh);
373376
}
374377

375378
private onMessageListUnfillRequest = (backwards: boolean, scrollToken: string): void => {
@@ -627,10 +630,18 @@ class TimelinePanel extends React.Component<IProps, IState> {
627630
});
628631
};
629632

633+
private onRoomTimelineRefresh = (room: Room, timelineSet: EventTimelineSet): void => {
634+
console.log(`onRoomTimelineRefresh skipping=${timelineSet !== this.props.timelineSet}`);
635+
if (timelineSet !== this.props.timelineSet) return;
636+
637+
this.refreshTimeline();
638+
};
639+
630640
private onRoomTimelineReset = (room: Room, timelineSet: EventTimelineSet): void => {
641+
console.log(`onRoomTimelineReset skipping=${timelineSet !== this.props.timelineSet} skippingBecauseAtBottom=${this.canResetTimeline()}`);
631642
if (timelineSet !== this.props.timelineSet) return;
632643

633-
if (this.messagePanel.current && this.messagePanel.current.isAtBottom()) {
644+
if (this.canResetTimeline()) {
634645
this.loadTimeline();
635646
}
636647
};
@@ -1181,6 +1192,9 @@ class TimelinePanel extends React.Component<IProps, IState> {
11811192
* @param {boolean?} scrollIntoView whether to scroll the event into view.
11821193
*/
11831194
private loadTimeline(eventId?: string, pixelOffset?: number, offsetBase?: number, scrollIntoView = true): void {
1195+
console.log('TimelinePanel: loadTimeline', this.props.timelineSet.getTimelines(), this.props.timelineSet.getTimelines().map((timeline) => {
1196+
return timeline.getEvents().length;
1197+
}))
11841198
this.timelineWindow = new TimelineWindow(
11851199
MatrixClientPeg.get(), this.props.timelineSet,
11861200
{ windowLimit: this.props.timelineCap });
@@ -1319,6 +1333,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
13191333
// get the list of events from the timeline window and the pending event list
13201334
private getEvents(): Pick<IState, "events" | "liveEvents" | "firstVisibleEventIndex"> {
13211335
const events: MatrixEvent[] = this.timelineWindow.getEvents();
1336+
console.log('TimelinePanel: getEvents', events.length);
13221337

13231338
// `arrayFastClone` performs a shallow copy of the array
13241339
// we want the last event to be decrypted first but displayed last

0 commit comments

Comments
 (0)