Skip to content

Commit 4e88484

Browse files
committed
ActionSheet [nfc]: Pass StreamsById to actionsheet.
While not directly used within the action sheet, this modification will help us to create TopicActionSheet with `streamId` for any `streamName` at the callsite of `showTopicActionSheet`.
1 parent 5f1cc4a commit 4e88484

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

src/message/__tests__/messageActionSheet-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { streamNameOfStreamMessage } from '../../utils/recipient';
55

66
import * as eg from '../../__tests__/lib/exampleData';
77
import { constructMessageActionButtons, constructTopicActionButtons } from '../messageActionSheet';
8+
import { getStreamsById } from '../../selectors';
89

910
const baseBackgroundData = deepFreeze({
1011
alertWords: [],
@@ -14,6 +15,7 @@ const baseBackgroundData = deepFreeze({
1415
flags: eg.baseReduxState.flags,
1516
mute: [],
1617
ownUser: eg.selfUser,
18+
streams: getStreamsById(eg.baseReduxState),
1719
subscriptions: [],
1820
theme: 'default',
1921
twentyFourHourTime: false,

src/message/messageActionSheet.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
Subscription,
1515
User,
1616
EditMessage,
17+
Stream,
1718
} from '../types';
1819
import {
1920
getNarrowForReply,
@@ -227,12 +228,13 @@ cancel.title = 'Cancel';
227228
cancel.errorMessage = 'Failed to hide menu';
228229

229230
export const constructTopicActionButtons = ({
230-
backgroundData: { mute, subscriptions, ownUser },
231+
backgroundData: { mute, ownUser, streams, subscriptions },
231232
streamName,
232233
topic,
233234
}: {|
234235
backgroundData: $ReadOnly<{
235236
mute: MuteState,
237+
streams: Map<number, Stream>,
236238
subscriptions: Subscription[],
237239
ownUser: User,
238240
...
@@ -404,6 +406,7 @@ export const showTopicActionSheet = ({
404406
backgroundData: $ReadOnly<{
405407
auth: Auth,
406408
mute: MuteState,
409+
streams: Map<number, Stream>,
407410
subscriptions: Subscription[],
408411
ownUser: User,
409412
flags: FlagsState,

src/streams/TopicItem.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ import { showTopicActionSheet } from '../message/messageActionSheet';
99
import type { ShowActionSheetWithOptions } from '../message/messageActionSheet';
1010
import { TranslationContext } from '../boot/TranslationProvider';
1111
import { useDispatch, useSelector } from '../react-redux';
12-
import { getAuth, getMute, getFlags, getSubscriptions, getOwnUser } from '../selectors';
12+
import {
13+
getAuth,
14+
getMute,
15+
getFlags,
16+
getSubscriptions,
17+
getStreamsById,
18+
getOwnUser,
19+
} from '../selectors';
1320

1421
const componentStyles = createStyleSheet({
1522
selectedRow: {
@@ -45,6 +52,7 @@ export default function TopicItem(props: Props) {
4552
const backgroundData = useSelector(state => ({
4653
auth: getAuth(state),
4754
mute: getMute(state),
55+
streams: getStreamsById(state),
4856
subscriptions: getSubscriptions(state),
4957
ownUser: getOwnUser(state),
5058
flags: getFlags(state),

src/title/TitleStream.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
getMute,
2525
getFlags,
2626
getSubscriptions,
27+
getStreamsById,
2728
getOwnUser,
2829
getStreamInNarrow,
2930
} from '../selectors';
@@ -35,6 +36,7 @@ type SelectorProps = {|
3536
backgroundData: {|
3637
auth: Auth,
3738
mute: MuteState,
39+
streams: Map<number, Stream>,
3840
subscriptions: Subscription[],
3941
ownUser: User,
4042
flags: FlagsState,
@@ -114,6 +116,7 @@ export default connect<SelectorProps, _, _>((state, props) => ({
114116
backgroundData: {
115117
auth: getAuth(state),
116118
mute: getMute(state),
119+
streams: getStreamsById(state),
117120
subscriptions: getSubscriptions(state),
118121
ownUser: getOwnUser(state),
119122
flags: getFlags(state),

src/webview/MessageList.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
ImageEmojiType,
2222
HtmlPieceDescriptor,
2323
Subscription,
24+
Stream,
2425
ThemeName,
2526
User,
2627
UserOrBot,
@@ -43,6 +44,7 @@ import {
4344
getOwnUser,
4445
getSettings,
4546
getSubscriptions,
47+
getStreamsById,
4648
getShownMessagesForNarrow,
4749
getRealm,
4850
} from '../selectors';
@@ -81,6 +83,7 @@ export type BackgroundData = $ReadOnly<{|
8183
mute: MuteState,
8284
mutedUsers: MutedUsersState,
8385
ownUser: User,
86+
streams: Map<number, Stream>,
8487
subscriptions: Subscription[],
8588
theme: ThemeName,
8689
twentyFourHourTime: boolean,
@@ -360,6 +363,7 @@ export default connect<SelectorProps, _, _>((state, props: OuterProps) => {
360363
mute: getMute(state),
361364
mutedUsers: getMutedUsers(state),
362365
ownUser: getOwnUser(state),
366+
streams: getStreamsById(state),
363367
subscriptions: getSubscriptions(state),
364368
theme: getSettings(state).theme,
365369
twentyFourHourTime: getRealm(state).twentyFourHourTime,

src/webview/__tests__/generateInboundEvents-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { flagsStateToStringList } from '../html/messageAsHtml';
77
import { HOME_NARROW } from '../../utils/narrow';
88
import * as eg from '../../__tests__/lib/exampleData';
99
import type { Props } from '../MessageList';
10+
import { getStreamsById } from '../../selectors';
1011

1112
describe('generateInboundEvents', () => {
1213
const baseBackgroundData = deepFreeze({
@@ -18,6 +19,7 @@ describe('generateInboundEvents', () => {
1819
mute: [],
1920
mutedUsers: Immutable.Map(),
2021
ownUser: eg.selfUser,
22+
streams: getStreamsById(eg.baseReduxState),
2123
subscriptions: [],
2224
theme: 'default',
2325
twentyFourHourTime: false,

0 commit comments

Comments
 (0)