Fix thread summary layout for narrow right panel timeline (#7838)
This commit is contained in:
parent
5e76d988ca
commit
d8ac7cf202
15 changed files with 248 additions and 68 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -37,6 +37,7 @@ import RoomContext, { TimelineRenderingType } from '../../contexts/RoomContext';
|
|||
import TimelinePanel from './TimelinePanel';
|
||||
import { Layout } from '../../settings/enums/Layout';
|
||||
import { RoomPermalinkCreator } from '../../utils/permalinks/Permalinks';
|
||||
import Measured from '../views/elements/Measured';
|
||||
|
||||
async function getThreadTimelineSet(
|
||||
client: MatrixClient,
|
||||
|
@ -213,12 +214,14 @@ const EmptyThread: React.FC<EmptyThreadIProps> = ({ filterOption, showAllThreads
|
|||
const ThreadPanel: React.FC<IProps> = ({ roomId, onClose, permalinkCreator }) => {
|
||||
const mxClient = useContext(MatrixClientContext);
|
||||
const roomContext = useContext(RoomContext);
|
||||
const [filterOption, setFilterOption] = useState<ThreadFilterType>(ThreadFilterType.All);
|
||||
const ref = useRef<TimelinePanel>();
|
||||
const timelinePanel = useRef<TimelinePanel>();
|
||||
const card = useRef<HTMLDivElement>();
|
||||
|
||||
const [filterOption, setFilterOption] = useState<ThreadFilterType>(ThreadFilterType.All);
|
||||
const [room, setRoom] = useState(mxClient.getRoom(roomId));
|
||||
const [threadCount, setThreadCount] = useState<number>(0);
|
||||
const [timelineSet, setTimelineSet] = useState<EventTimelineSet | null>(null);
|
||||
const [narrow, setNarrow] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
setRoom(mxClient.getRoom(roomId));
|
||||
|
@ -257,7 +260,7 @@ const ThreadPanel: React.FC<IProps> = ({ roomId, onClose, permalinkCreator }) =>
|
|||
}
|
||||
|
||||
function refreshTimeline() {
|
||||
if (timelineSet) ref.current.refreshTimeline();
|
||||
if (timelineSet) timelinePanel.current.refreshTimeline();
|
||||
}
|
||||
|
||||
setThreadCount(room.threads.size);
|
||||
|
@ -278,14 +281,15 @@ const ThreadPanel: React.FC<IProps> = ({ roomId, onClose, permalinkCreator }) =>
|
|||
}, [mxClient, room, filterOption]);
|
||||
|
||||
useEffect(() => {
|
||||
if (timelineSet) ref.current.refreshTimeline();
|
||||
}, [timelineSet, ref]);
|
||||
if (timelineSet) timelinePanel.current.refreshTimeline();
|
||||
}, [timelineSet, timelinePanel]);
|
||||
|
||||
return (
|
||||
<RoomContext.Provider value={{
|
||||
...roomContext,
|
||||
timelineRenderingType: TimelineRenderingType.ThreadsList,
|
||||
showHiddenEventsInTimeline: true,
|
||||
narrow,
|
||||
}}>
|
||||
<BaseCard
|
||||
header={<ThreadPanelHeader
|
||||
|
@ -296,10 +300,15 @@ const ThreadPanel: React.FC<IProps> = ({ roomId, onClose, permalinkCreator }) =>
|
|||
className="mx_ThreadPanel"
|
||||
onClose={onClose}
|
||||
withoutScrollContainer={true}
|
||||
ref={card}
|
||||
>
|
||||
<Measured
|
||||
sensor={card.current}
|
||||
onMeasurement={setNarrow}
|
||||
/>
|
||||
{ timelineSet && (
|
||||
<TimelinePanel
|
||||
ref={ref}
|
||||
ref={timelinePanel}
|
||||
showReadReceipts={false} // No RR support in thread's MVP
|
||||
manageReadReceipts={false} // No RR support in thread's MVP
|
||||
manageReadMarkers={false} // No RM support in thread's MVP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue