Make threads use 'm.thread' relation

This commit is contained in:
Germain Souquet 2021-10-14 16:57:02 +01:00
parent 562a880c7d
commit d315641056
7 changed files with 52 additions and 58 deletions

View file

@ -271,9 +271,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
componentDidMount() {
this.calculateRoomMembersCount();
this.props.room?.on("RoomState.members", this.calculateRoomMembersCount);
if (SettingsStore.getValue("feature_thread")) {
this.props.room?.getThreads().forEach(thread => thread.fetchReplyChain());
}
this.isMounted = true;
}
@ -463,8 +460,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
// Checking if the message has a "parentEventId" as we do not
// want to hide the root event of the thread
if (mxEv.replyInThread && mxEv.parentEventId
&& this.props.hideThreadedMessages
if (mxEv.isThreadRoot && this.props.hideThreadedMessages
&& SettingsStore.getValue("feature_thread")) {
return false;
}

View file

@ -71,7 +71,7 @@ const useFilteredThreadsTimelinePanel = ({
userId,
updateTimeline,
}: {
threads: Set<Thread>;
threads: Map<string, Thread>;
room: Room;
userId: string;
filterOption: ThreadFilterType;
@ -85,13 +85,13 @@ const useFilteredThreadsTimelinePanel = ({
useEffect(() => {
let filteredThreads = Array.from(threads);
if (filterOption === ThreadFilterType.My) {
filteredThreads = filteredThreads.filter(thread => {
filteredThreads = filteredThreads.filter(([id, thread]) => {
return thread.rootEvent.getSender() === userId;
});
}
// NOTE: Temporarily reverse the list until https://github.com/vector-im/element-web/issues/19393 gets properly resolved
// The proper list order should be top-to-bottom, like in social-media newsfeeds.
filteredThreads.reverse().forEach(thread => {
filteredThreads.reverse().forEach(([id, thread]) => {
const event = thread.rootEvent;
if (timelineSet.findEventById(event.getId()) || event.status !== null) return;
timelineSet.addEventToTimeline(

View file

@ -17,6 +17,7 @@ limitations under the License.
import React from 'react';
import { MatrixEvent, Room } from 'matrix-js-sdk/src';
import { Thread, ThreadEvent } from 'matrix-js-sdk/src/models/thread';
import { RelationType } from 'matrix-js-sdk/src/@types/event';
import BaseCard from "../views/right_panel/BaseCard";
import { RightPanelPhases } from "../../stores/RightPanelStorePhases";
@ -185,8 +186,10 @@ export default class ThreadView extends React.Component<IProps, IState> {
{ this.state?.thread?.timelineSet && (<MessageComposer
room={this.props.room}
resizeNotifier={this.props.resizeNotifier}
replyInThread={true}
replyToEvent={this.state?.thread?.replyToEvent}
relation={{
rel_type: RelationType.Thread,
event_id: this.state.thread.id,
}}
showReplyPreview={false}
permalinkCreator={this.props.permalinkCreator}
e2eStatus={this.props.e2eStatus}