Hide thread UI behind experimentalThreadSupport flag

pull/21833/head
Germain Souquet 2021-08-19 14:56:51 +01:00
parent ac0412d238
commit d5356361a9
4 changed files with 26 additions and 12 deletions

View File

@ -267,7 +267,9 @@ export default class MessagePanel extends React.Component<IProps, IState> {
componentDidMount() { componentDidMount() {
this.calculateRoomMembersCount(); this.calculateRoomMembersCount();
this.props.room?.on("RoomState.members", this.calculateRoomMembersCount); this.props.room?.on("RoomState.members", this.calculateRoomMembersCount);
this.props.room?.getThreads().forEach(thread => thread.fetchReplyChain()); if (SettingsStore.getValue("experimentalThreadSupport")) {
this.props.room?.getThreads().forEach(thread => thread.fetchReplyChain());
}
this.isMounted = true; this.isMounted = true;
} }

View File

@ -36,6 +36,7 @@ import Resend from "../../../Resend";
import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { MediaEventHelper } from "../../../utils/MediaEventHelper"; import { MediaEventHelper } from "../../../utils/MediaEventHelper";
import DownloadActionButton from "./DownloadActionButton"; import DownloadActionButton from "./DownloadActionButton";
import SettingsStore from '../../../settings/SettingsStore';
const OptionsButton = ({ mxEvent, getTile, getReplyThread, permalinkCreator, onFocusChange }) => { const OptionsButton = ({ mxEvent, getTile, getReplyThread, permalinkCreator, onFocusChange }) => {
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu(); const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
@ -274,12 +275,14 @@ export default class MessageActionBar extends React.PureComponent {
onClick={this.onReplyClick} onClick={this.onReplyClick}
key="reply" key="reply"
/> />
<RovingAccessibleTooltipButton { SettingsStore.getValue("experimentalThreadSupport") && (
className="mx_MessageActionBar_maskButton mx_MessageActionBar_threadButton" <RovingAccessibleTooltipButton
title={_t("Thread")} className="mx_MessageActionBar_maskButton mx_MessageActionBar_threadButton"
onClick={this.onThreadClick} title={_t("Thread")}
key="thread" onClick={this.onThreadClick}
/> key="thread"
/>
)}
</>); </>);
} }
if (this.context.canReact) { if (this.context.canReact) {

View File

@ -280,9 +280,11 @@ const RoomSummaryCard: React.FC<IProps> = ({ room, onClose }) => {
<Button className="mx_RoomSummaryCard_icon_files" onClick={onRoomFilesClick}> <Button className="mx_RoomSummaryCard_icon_files" onClick={onRoomFilesClick}>
{ _t("Show files") } { _t("Show files") }
</Button> </Button>
<Button className="mx_RoomSummaryCard_icon_threads" onClick={onRoomThreadsClick}> { SettingsStore.getValue("experimentalThreadSupport") && (
{ _t("Show threads") } <Button className="mx_RoomSummaryCard_icon_threads" onClick={onRoomThreadsClick}>
</Button> { _t("Show threads") }
</Button>
) }
<Button className="mx_RoomSummaryCard_icon_share" onClick={onShareRoomClick}> <Button className="mx_RoomSummaryCard_icon_share" onClick={onShareRoomClick}>
{ _t("Share room") } { _t("Share room") }
</Button> </Button>

View File

@ -57,6 +57,7 @@ import ReactionsRow from '../messages/ReactionsRow';
import { getEventDisplayInfo } from '../../../utils/EventUtils'; import { getEventDisplayInfo } from '../../../utils/EventUtils';
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases"; import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
import { Thread } from '../../../../../matrix-js-sdk/src/models/thread'; import { Thread } from '../../../../../matrix-js-sdk/src/models/thread';
import SettingsStore from "../../../settings/SettingsStore";
const eventTileTypes = { const eventTileTypes = {
[EventType.RoomMessage]: 'messages.MessageEvent', [EventType.RoomMessage]: 'messages.MessageEvent',
@ -461,8 +462,10 @@ export default class EventTile extends React.Component<IProps, IState> {
this.isListeningForReceipts = true; this.isListeningForReceipts = true;
} }
this.props.mxEvent.once("Thread.ready", this.updateThread); if (SettingsStore.getValue("experimentalThreadSupport")) {
this.props.mxEvent.on("Thread.update", this.updateThread); this.props.mxEvent.once("Thread.ready", this.updateThread);
this.props.mxEvent.on("Thread.update", this.updateThread);
}
} }
private updateThread = (thread) => { private updateThread = (thread) => {
@ -511,6 +514,10 @@ export default class EventTile extends React.Component<IProps, IState> {
} }
private renderThreadInfo(): React.ReactNode { private renderThreadInfo(): React.ReactNode {
if (!SettingsStore.getValue("experimentalThreadSupport")) {
return null;
}
const thread = this.state.thread; const thread = this.state.thread;
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
if (!thread || this.props.showThreadInfo === false) { if (!thread || this.props.showThreadInfo === false) {