Skip to content

Commit 7508fd9

Browse files
author
Germain
authored
Prevent thread creation on events with existing relation (matrix-org#8037)
1 parent 4b0df21 commit 7508fd9

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

res/css/views/messages/_MessageActionBar.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ limitations under the License.
6565
.mx_MessageActionBar_maskButton {
6666
width: 28px;
6767
height: 28px;
68+
69+
&:disabled,
70+
&[disabled] {
71+
cursor: not-allowed;
72+
opacity: .75;
73+
}
6874
}
6975

7076
.mx_MessageActionBar_maskButton::after {

src/components/views/messages/MessageActionBar.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ limitations under the License.
1919
import React, { ReactElement, useEffect } from 'react';
2020
import { EventStatus, MatrixEvent, MatrixEventEvent } from 'matrix-js-sdk/src/models/event';
2121
import classNames from 'classnames';
22-
import { MsgType } from 'matrix-js-sdk/src/@types/event';
22+
import { MsgType, RelationType } from 'matrix-js-sdk/src/@types/event';
2323

2424
import type { Relations } from 'matrix-js-sdk/src/models/relations';
2525
import { _t } from '../../../languageHandler';
@@ -166,7 +166,7 @@ interface IMessageActionBarProps {
166166
isQuoteExpanded?: boolean;
167167
getRelationsForEvent?: (
168168
eventId: string,
169-
relationType: string,
169+
relationType: RelationType | string,
170170
eventType: string
171171
) => Relations;
172172
}
@@ -303,11 +303,19 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
303303
key="cancel"
304304
/>;
305305

306+
const hasARelation = !!this.props.mxEvent?.getRelation()?.rel_type;
307+
306308
const threadTooltipButton = <CardContext.Consumer key="thread">
307309
{ context =>
308310
<RovingAccessibleTooltipButton
309311
className="mx_MessageActionBar_maskButton mx_MessageActionBar_threadButton"
310-
title={_t("Reply in thread")}
312+
313+
disabled={hasARelation}
314+
title={!hasARelation
315+
? _t("Reply in thread")
316+
: _t("Can't create a thread from an event with an existing relation")
317+
}
318+
311319
onClick={this.onThreadClick.bind(null, context.isCard)}
312320
/>
313321
}

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,7 @@
21032103
"React": "React",
21042104
"Edit": "Edit",
21052105
"Reply in thread": "Reply in thread",
2106+
"Can't create a thread from an event with an existing relation": "Can't create a thread from an event with an existing relation",
21062107
"Reply": "Reply",
21072108
"Collapse quotes": "Collapse quotes",
21082109
"Expand quotes": "Expand quotes",

0 commit comments

Comments
 (0)