Skip to content

Commit

Permalink
messageActionSheet: Fix action sheet title for private messages.
Browse files Browse the repository at this point in the history
Currently, when viewing the options for a header in the message
list in a multi-stream narrow, the title for the action sheet
breaks.
Fix that to show the list of people involved in the private
message.

Fixes #3874.
  • Loading branch information
agrawal-d authored and rk-for-zulip committed Feb 22, 2020
1 parent c1c1c53 commit 01a5b6b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/message/messageActionSheet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/* @flow strict-local */
import { Clipboard, Share, Alert } from 'react-native';
import type { Auth, Dispatch, GetText, Message, Narrow, Outbox, Subscription } from '../types';
import type {
Auth,
Dispatch,
GetText,
Message,
Narrow,
Outbox,
Subscription,
User,
} from '../types';
import type { BackgroundData } from '../webview/MessageList';
import {
getNarrowFromMessage,
Expand All @@ -13,6 +22,7 @@ import * as api from '../api';
import { showToast } from '../utils/info';
import { doNarrow, startEditMessage, deleteOutboxMessage, navigateToEmojiPicker } from '../actions';
import { navigateToMessageReactionScreen } from '../nav/navActions';
import filteredRecipientsForPM from '../pm-conversations/filteredRecipientsForPM';

// TODO really this belongs in a libdef.
export type ShowActionSheetWithOptions = (
Expand Down Expand Up @@ -245,6 +255,19 @@ export const constructMessageActionButtons = ({
return buttons;
};

/** Returns the title for the action sheet. */
const getActionSheetTitle = (message: Message | Outbox, ownUser: User): string => {
if (message.type === 'private') {
const recipients = filteredRecipientsForPM(message, ownUser);
return recipients
.map(r => r.full_name)
.sort()
.join(', ');
} else {
return `#${message.display_recipient} > ${message.subject}`;
}
};

/** Invoke the given callback to show an appropriate action sheet. */
export const showActionSheet = (
isHeader: boolean,
Expand Down Expand Up @@ -277,7 +300,7 @@ export const showActionSheet = (
{
...(isHeader
? {
title: `#${params.message.display_recipient} > ${params.message.subject}`,
title: getActionSheetTitle(params.message, params.backgroundData.ownUser),
}
: {}),
options: optionCodes.map(code => _(allButtons[code].title)),
Expand Down

0 comments on commit 01a5b6b

Please sign in to comment.