Skip to content

Commit e7ee1c9

Browse files
committed
connect: Add all required SelectorProps annotations.
This is the one kind of annotation that Flow v0.92 requires at some call sites of `connect`, with our spiffy new type for it. We added a few in 165e848; now add the rest.
1 parent 8934976 commit e7ee1c9

File tree

7 files changed

+51
-20
lines changed

7 files changed

+51
-20
lines changed

src/account-info/AccountDetails.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@ const componentStyles = StyleSheet.create({
2727

2828
const AVATAR_SIZE = 200;
2929

30-
type Props = {|
31-
dispatch: Dispatch,
30+
type SelectorProps = {|
3231
realm: string,
33-
user: User,
3432
userStatusText: string | void,
3533
|};
3634

35+
type Props = {|
36+
user: User,
37+
38+
dispatch: Dispatch,
39+
...SelectorProps,
40+
|};
41+
3742
class AccountDetails extends PureComponent<Props, void> {
3843
render() {
3944
const { realm, user, userStatusText } = this.props;
@@ -74,7 +79,7 @@ class AccountDetails extends PureComponent<Props, void> {
7479
}
7580
}
7681

77-
export default connect((state: GlobalState, props) => ({
82+
export default connect((state: GlobalState, props): SelectorProps => ({
7883
realm: getCurrentRealm(state),
7984
userStatusText: getUserStatusTextForUser(state, props.user.user_id),
8085
}))(AccountDetails);

src/chat/Chat.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ import styles from '../styles';
1313
import { canSendToNarrow } from '../utils/narrow';
1414
import { getShowMessagePlaceholders } from '../selectors';
1515

16+
type SelectorProps = {|
17+
canSend: boolean,
18+
|};
19+
1620
type Props = {|
17-
dispatch: Dispatch,
1821
/* $FlowFixMe: probably this shouldn't be optional */
1922
narrow?: Narrow,
20-
canSend: boolean,
23+
24+
dispatch: Dispatch,
25+
...SelectorProps,
2126
|};
2227

2328
const componentStyles = StyleSheet.create({
@@ -49,6 +54,6 @@ class Chat extends PureComponent<Props> {
4954
}
5055
}
5156

52-
export default connect((state: GlobalState, props) => ({
57+
export default connect((state: GlobalState, props): SelectorProps => ({
5358
canSend: canSendToNarrow(props.narrow) && !getShowMessagePlaceholders(props.narrow)(state),
5459
}))(Chat);

src/compose/ComposeBox.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type SelectorProps = {|
6060

6161
type Props = {|
6262
narrow: Narrow,
63+
6364
dispatch: Dispatch,
6465
...SelectorProps,
6566
|};

src/emoji/EmojiRow.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ const styles = StyleSheet.create({
2020
},
2121
});
2222

23+
type SelectorProps = {|
24+
imageEmoji: ImageEmojiType | void,
25+
|};
26+
2327
type Props = {|
24-
dispatch: Dispatch,
2528
name: string,
26-
imageEmoji: ImageEmojiType | void,
2729
onPress: (name: string) => void,
30+
31+
dispatch: Dispatch,
32+
...SelectorProps,
2833
|};
2934

3035
class EmojiRow extends PureComponent<Props> {
@@ -49,6 +54,6 @@ class EmojiRow extends PureComponent<Props> {
4954
}
5055
}
5156

52-
export default connect((state: GlobalState, props) => ({
57+
export default connect((state: GlobalState, props): SelectorProps => ({
5358
imageEmoji: getActiveImageEmojiByName(state)[props.name],
5459
}))(EmojiRow);

src/message/NoMessages.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ const messages: EmptyMessage[] = [
4747
{ isFunc: isSearchNarrow, text: 'No messages' },
4848
];
4949

50-
type Props = {|
51-
dispatch: Dispatch,
52-
narrow: Narrow,
50+
type SelectorProps = {|
5351
showMessagePlaceholders: boolean,
5452
noMessages: boolean,
5553
|};
5654

55+
type Props = {|
56+
narrow: Narrow,
57+
58+
dispatch: Dispatch,
59+
...SelectorProps,
60+
|};
61+
5762
class NoMessages extends PureComponent<Props> {
5863
render() {
5964
const { noMessages, showMessagePlaceholders, narrow } = this.props;
@@ -73,7 +78,7 @@ class NoMessages extends PureComponent<Props> {
7378
}
7479
}
7580

76-
export default connect((state, props) => ({
81+
export default connect((state, props): SelectorProps => ({
7782
showMessagePlaceholders: getShowMessagePlaceholders(props.narrow)(state),
7883
noMessages: getIfNoMessages(props.narrow)(state),
7984
}))(NoMessages);

src/title-buttons/InfoNavButtonGroup.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ import { getRecipientsInGroupNarrow } from '../selectors';
88
import NavButton from '../nav/NavButton';
99
import { navigateToGroupDetails } from '../actions';
1010

11+
type SelectorProps = {|
12+
recipients: UserOrBot[],
13+
|};
14+
1115
type Props = {|
12-
dispatch: Dispatch,
1316
color: string,
1417
narrow: Narrow,
15-
recipients: UserOrBot[],
18+
19+
dispatch: Dispatch,
20+
...SelectorProps,
1621
|};
1722

1823
class InfoNavButtonGroup extends PureComponent<Props> {
@@ -28,6 +33,6 @@ class InfoNavButtonGroup extends PureComponent<Props> {
2833
}
2934
}
3035

31-
export default connect((state, props) => ({
36+
export default connect((state, props): SelectorProps => ({
3237
recipients: getRecipientsInGroupNarrow(state, props.narrow),
3338
}))(InfoNavButtonGroup);

src/title/TitleStream.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ import { isTopicNarrow } from '../utils/narrow';
1010
import { getStreamInNarrow } from '../selectors';
1111
import styles from '../styles';
1212

13+
type SelectorProps = {|
14+
stream: Subscription | {| ...Stream, in_home_view: boolean |},
15+
|};
16+
1317
type Props = {|
14-
dispatch: Dispatch,
1518
narrow: Narrow,
16-
stream: Subscription | {| ...Stream, in_home_view: boolean |},
1719
color: string,
20+
21+
dispatch: Dispatch,
22+
...SelectorProps,
1823
|};
1924

2025
class TitleStream extends PureComponent<Props> {
@@ -57,6 +62,6 @@ class TitleStream extends PureComponent<Props> {
5762
}
5863
}
5964

60-
export default connect((state, props) => ({
65+
export default connect((state, props): SelectorProps => ({
6166
stream: getStreamInNarrow(props.narrow)(state),
6267
}))(TitleStream);

0 commit comments

Comments
 (0)