Skip to content

Commit 909453b

Browse files
authored
Allow reactions in announcement only groups
1 parent 60d348e commit 909453b

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

ts/components/conversation/Message.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
9999
author: overrideProps.author || getDefaultConversation(),
100100
reducedMotion: boolean('reducedMotion', false),
101101
bodyRanges: overrideProps.bodyRanges,
102+
canReact: true,
102103
canReply: true,
103104
canDownload: true,
104105
canDeleteForEveryone: overrideProps.canDeleteForEveryone || false,

ts/components/conversation/Message.tsx

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ export type PropsData = {
195195

196196
deletedForEveryone?: boolean;
197197

198+
canReact: boolean;
198199
canReply: boolean;
199200
canDownload: boolean;
200201
canDeleteForEveryone: boolean;
@@ -1325,6 +1326,7 @@ export class Message extends React.PureComponent<Props, State> {
13251326
const {
13261327
attachments,
13271328
canDownload,
1329+
canReact,
13281330
canReply,
13291331
direction,
13301332
disableMenu,
@@ -1467,7 +1469,7 @@ export class Message extends React.PureComponent<Props, State> {
14671469
>
14681470
{this.isWindowWidthNotNarrow() && (
14691471
<>
1470-
{canReply ? reactButton : null}
1472+
{canReact ? reactButton : null}
14711473
{canDownload ? downloadButton : null}
14721474
{canReply ? replyButton : null}
14731475
</>
@@ -1512,6 +1514,7 @@ export class Message extends React.PureComponent<Props, State> {
15121514
const {
15131515
attachments,
15141516
canDownload,
1517+
canReact,
15151518
canReply,
15161519
deleteMessage,
15171520
deleteMessageForEveryone,
@@ -1560,36 +1563,40 @@ export class Message extends React.PureComponent<Props, State> {
15601563
{i18n('downloadAttachment')}
15611564
</MenuItem>
15621565
) : null}
1563-
{canReply && shouldShowAdditional ? (
1566+
{shouldShowAdditional ? (
15641567
<>
1565-
<MenuItem
1566-
attributes={{
1567-
className:
1568-
'module-message__context--icon module-message__context__reply',
1569-
}}
1570-
onClick={(event: React.MouseEvent) => {
1571-
event.stopPropagation();
1572-
event.preventDefault();
1573-
1574-
replyToMessage(id);
1575-
}}
1576-
>
1577-
{i18n('replyToMessage')}
1578-
</MenuItem>
1579-
<MenuItem
1580-
attributes={{
1581-
className:
1582-
'module-message__context--icon module-message__context__react',
1583-
}}
1584-
onClick={(event: React.MouseEvent) => {
1585-
event.stopPropagation();
1586-
event.preventDefault();
1587-
1588-
this.toggleReactionPicker();
1589-
}}
1590-
>
1591-
{i18n('reactToMessage')}
1592-
</MenuItem>
1568+
{canReply && (
1569+
<MenuItem
1570+
attributes={{
1571+
className:
1572+
'module-message__context--icon module-message__context__reply',
1573+
}}
1574+
onClick={(event: React.MouseEvent) => {
1575+
event.stopPropagation();
1576+
event.preventDefault();
1577+
1578+
replyToMessage(id);
1579+
}}
1580+
>
1581+
{i18n('replyToMessage')}
1582+
</MenuItem>
1583+
)}
1584+
{canReact && (
1585+
<MenuItem
1586+
attributes={{
1587+
className:
1588+
'module-message__context--icon module-message__context__react',
1589+
}}
1590+
onClick={(event: React.MouseEvent) => {
1591+
event.stopPropagation();
1592+
event.preventDefault();
1593+
1594+
this.toggleReactionPicker();
1595+
}}
1596+
>
1597+
{i18n('reactToMessage')}
1598+
</MenuItem>
1599+
)}
15931600
</>
15941601
) : null}
15951602
<MenuItem
@@ -2323,15 +2330,15 @@ export class Message extends React.PureComponent<Props, State> {
23232330

23242331
public handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {
23252332
// Do not allow reactions to error messages
2326-
const { canReply } = this.props;
2333+
const { canReact } = this.props;
23272334

23282335
const key = KeyboardLayout.lookup(event.nativeEvent);
23292336

23302337
if (
23312338
(key === 'E' || key === 'e') &&
23322339
(event.metaKey || event.ctrlKey) &&
23332340
event.shiftKey &&
2334-
canReply
2341+
canReact
23352342
) {
23362343
this.toggleReactionPicker();
23372344
}

ts/components/conversation/MessageDetail.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const defaultMessage: MessageDataPropsType = {
2727
id: 'some-id',
2828
title: 'Max',
2929
}),
30+
canReact: true,
3031
canReply: true,
3132
canDeleteForEveryone: true,
3233
canDownload: true,

ts/components/conversation/Quote.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const defaultMessageProps: MessagesProps = {
3737
id: 'some-id',
3838
title: 'Person X',
3939
}),
40+
canReact: true,
4041
canReply: true,
4142
canDeleteForEveryone: true,
4243
canDownload: true,

ts/components/conversation/Timeline.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const items: Record<string, TimelineItemType> = {
4848
}),
4949
canDeleteForEveryone: false,
5050
canDownload: true,
51+
canReact: true,
5152
canReply: true,
5253
conversationColor: 'forest',
5354
conversationId: 'conversation-id',
@@ -69,6 +70,7 @@ const items: Record<string, TimelineItemType> = {
6970
author: getDefaultConversation({}),
7071
canDeleteForEveryone: false,
7172
canDownload: true,
73+
canReact: true,
7274
canReply: true,
7375
conversationColor: 'forest',
7476
conversationId: 'conversation-id',
@@ -104,6 +106,7 @@ const items: Record<string, TimelineItemType> = {
104106
author: getDefaultConversation({}),
105107
canDeleteForEveryone: false,
106108
canDownload: true,
109+
canReact: true,
107110
canReply: true,
108111
conversationColor: 'crimson',
109112
conversationId: 'conversation-id',
@@ -200,6 +203,7 @@ const items: Record<string, TimelineItemType> = {
200203
author: getDefaultConversation({}),
201204
canDeleteForEveryone: false,
202205
canDownload: true,
206+
canReact: true,
203207
canReply: true,
204208
conversationColor: 'plum',
205209
conversationId: 'conversation-id',
@@ -222,6 +226,7 @@ const items: Record<string, TimelineItemType> = {
222226
author: getDefaultConversation({}),
223227
canDeleteForEveryone: false,
224228
canDownload: true,
229+
canReact: true,
225230
canReply: true,
226231
conversationColor: 'crimson',
227232
conversationId: 'conversation-id',
@@ -244,6 +249,7 @@ const items: Record<string, TimelineItemType> = {
244249
author: getDefaultConversation({}),
245250
canDeleteForEveryone: false,
246251
canDownload: true,
252+
canReact: true,
247253
canReply: true,
248254
conversationColor: 'crimson',
249255
conversationId: 'conversation-id',
@@ -266,6 +272,7 @@ const items: Record<string, TimelineItemType> = {
266272
author: getDefaultConversation({}),
267273
canDeleteForEveryone: false,
268274
canDownload: true,
275+
canReact: true,
269276
canReply: true,
270277
conversationColor: 'crimson',
271278
conversationId: 'conversation-id',
@@ -288,6 +295,7 @@ const items: Record<string, TimelineItemType> = {
288295
author: getDefaultConversation({}),
289296
canDeleteForEveryone: false,
290297
canDownload: true,
298+
canReact: true,
291299
canReply: true,
292300
conversationColor: 'crimson',
293301
conversationId: 'conversation-id',

ts/state/selectors/message.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ type ShallowPropsType = Pick<
508508
PropsForMessage,
509509
| 'canDeleteForEveryone'
510510
| 'canDownload'
511+
| 'canReact'
511512
| 'canReply'
512513
| 'contact'
513514
| 'contactNameColor'
@@ -589,6 +590,7 @@ const getShallowPropsForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
589590
return {
590591
canDeleteForEveryone: canDeleteForEveryone(message),
591592
canDownload: canDownload(message, conversationSelector),
593+
canReact: canReact(message, ourConversationId, conversationSelector),
592594
canReply: canReply(message, ourConversationId, conversationSelector),
593595
contact: getPropsForEmbeddedContact(message, regionCode, accountSelector),
594596
contactNameColor,

0 commit comments

Comments
 (0)