Fix issue with thread panel not updating when it loads on first render (#8382)

This commit is contained in:
Michael Telatynski 2022-04-22 08:37:23 +01:00 committed by GitHub
parent 495a69532d
commit 763edb7ab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View file

@ -198,9 +198,10 @@ const ThreadPanel: React.FC<IProps> = ({
useEffect(() => { useEffect(() => {
const room = mxClient.getRoom(roomId); const room = mxClient.getRoom(roomId);
room.createThreadsTimelineSets().then(() => { room.createThreadsTimelineSets().then(() => {
setRoom(room); return room.fetchRoomThreads();
}).then(() => {
setFilterOption(ThreadFilterType.All); setFilterOption(ThreadFilterType.All);
room.fetchRoomThreads(); setRoom(room);
}); });
}, [mxClient, roomId]); }, [mxClient, roomId]);
@ -286,8 +287,8 @@ const ThreadPanel: React.FC<IProps> = ({
sensor={card.current} sensor={card.current}
onMeasurement={setNarrow} onMeasurement={setNarrow}
/> />
{ timelineSet && ( { timelineSet
<TimelinePanel ? <TimelinePanel
key={timelineSet.getFilter()?.filterId ?? (roomId + ":" + filterOption)} key={timelineSet.getFilter()?.filterId ?? (roomId + ":" + filterOption)}
ref={timelinePanel} ref={timelinePanel}
showReadReceipts={false} // No RR support in thread's MVP showReadReceipts={false} // No RR support in thread's MVP
@ -311,7 +312,8 @@ const ThreadPanel: React.FC<IProps> = ({
permalinkCreator={permalinkCreator} permalinkCreator={permalinkCreator}
disableGrouping={true} disableGrouping={true}
/> />
) } : <div className="mx_AutoHideScrollbar" />
}
</BaseCard> </BaseCard>
</RoomContext.Provider> </RoomContext.Provider>
); );

View file

@ -1188,11 +1188,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
const onLoaded = () => { const onLoaded = () => {
if (this.unmounted) return; if (this.unmounted) return;
// clear the timeline min-height when // clear the timeline min-height when (re)loading the timeline
// (re)loading the timeline this.messagePanel.current?.onTimelineReset();
if (this.messagePanel.current) {
this.messagePanel.current.onTimelineReset();
}
this.reloadEvents(); this.reloadEvents();
// If we switched away from the room while there were pending // If we switched away from the room while there were pending