= ({ hasThreads, filterOption, showAllThreadsCallback }) => {
let body: JSX.Element;
if (hasThreads) {
body = (
<>
{_t(
"Reply to an ongoing thread or use ā%(replyInThread)sā " +
"when hovering over a message to start a new one.",
{
replyInThread: _t("Reply in thread"),
},
)}
{/* Always display that paragraph to prevent layout shift when hiding the button */}
{filterOption === ThreadFilterType.My ? (
{_t("Show all threads")}
) : (
<> >
)}
>
);
} else {
body = (
<>
{_t("Threads help keep your conversations on-topic and easy to track.")}
{_t(
"Tip: Use ā%(replyInThread)sā when hovering over a message.",
{
replyInThread: _t("Reply in thread"),
},
{
b: (sub) => {sub} ,
},
)}
>
);
}
return (
{_t("Keep discussions organised with threads")}
{body}
);
};
const ThreadPanel: React.FC = ({ roomId, onClose, permalinkCreator }) => {
const mxClient = useContext(MatrixClientContext);
const roomContext = useContext(RoomContext);
const timelinePanel = useRef(null);
const card = useRef(null);
const [filterOption, setFilterOption] = useState(ThreadFilterType.All);
const [room, setRoom] = useState(null);
const [narrow, setNarrow] = useState(false);
const timelineSet: Optional =
filterOption === ThreadFilterType.My ? room?.threadsTimelineSets[1] : room?.threadsTimelineSets[0];
const hasThreads = Boolean(room?.threadsTimelineSets?.[0]?.getLiveTimeline()?.getEvents()?.length);
useEffect(() => {
const room = mxClient.getRoom(roomId);
room?.createThreadsTimelineSets()
.then(() => room.fetchRoomThreads())
.then(() => {
setFilterOption(ThreadFilterType.All);
setRoom(room);
});
}, [mxClient, roomId]);
useEffect(() => {
if (timelineSet && !Thread.hasServerSideSupport) {
timelinePanel.current?.refreshTimeline();
}
}, [timelineSet, timelinePanel]);
return (
}
className="mx_ThreadPanel"
onClose={onClose}
withoutScrollContainer={true}
ref={card}
>
{card.current && }
{timelineSet ? (
setFilterOption(ThreadFilterType.All)}
/>
}
alwaysShowTimestamps={true}
layout={Layout.Group}
hideThreadedMessages={false}
hidden={false}
showReactions={false}
className="mx_RoomView_messagePanel"
membersLoaded={true}
permalinkCreator={permalinkCreator}
disableGrouping={true}
/>
) : (
)}
);
};
export default ThreadPanel;