Skip to content

Commit 8383a3e

Browse files
committed
msglist [nfc]: Inline away "selector props"
This originally described the props supplied by our callback passed to `connect`. Now that everything's just one big function component, that's no longer such a meaningful distinction.
1 parent 177072a commit 8383a3e

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

src/webview/MessageList.js

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ type OuterProps = $ReadOnly<{|
5252
startEditMessage: (editMessage: EditMessage) => void,
5353
|}>;
5454

55-
type SelectorProps = {|
56-
// Data independent of the particular narrow or messages we're displaying.
57-
backgroundData: BackgroundData,
58-
59-
// The remaining props contain data specific to the particular narrow or
60-
// particular messages we're displaying. Data that's independent of those
61-
// should go in `BackgroundData`, above.
62-
fetching: Fetching,
63-
messageListElementsForShownMessages: $ReadOnlyArray<MessageListElement>,
64-
typingUsers: $ReadOnlyArray<UserOrBot>,
65-
doNotMarkMessagesAsRead: boolean,
66-
|};
67-
6855
/**
6956
* All the data for rendering the message list, and callbacks for its UI actions.
7057
*
@@ -82,12 +69,20 @@ type SelectorProps = {|
8269
export type Props = $ReadOnly<{|
8370
...OuterProps,
8471

72+
showActionSheetWithOptions: ShowActionSheetWithOptions,
73+
_: GetText,
8574
dispatch: Dispatch,
86-
...SelectorProps,
8775

88-
showActionSheetWithOptions: ShowActionSheetWithOptions,
76+
// Data independent of the particular narrow or messages we're displaying.
77+
backgroundData: BackgroundData,
8978

90-
_: GetText,
79+
// The remaining props contain data specific to the particular narrow or
80+
// particular messages we're displaying. Data that's independent of those
81+
// should go in `BackgroundData`, above.
82+
fetching: Fetching,
83+
messageListElementsForShownMessages: $ReadOnlyArray<MessageListElement>,
84+
typingUsers: $ReadOnlyArray<UserOrBot>,
85+
doNotMarkMessagesAsRead: boolean,
9186
|}>;
9287

9388
/**
@@ -121,12 +116,24 @@ const marksMessagesAsRead = (narrow: Narrow): boolean =>
121116
mentioned: () => false,
122117
});
123118

124-
function useSelectorProps(props: OuterProps) {
119+
function useMessageListProps(props: OuterProps): Props {
120+
const _ = useContext(TranslationContext);
121+
const showActionSheetWithOptions: ShowActionSheetWithOptions =
122+
useActionSheet().showActionSheetWithOptions;
123+
const dispatch = useDispatch();
124+
125125
const globalSettings = useGlobalSelector(getGlobalSettings);
126126
const debug = useGlobalSelector(getDebug);
127127

128128
return useSelector(state => ({
129+
...props,
130+
131+
showActionSheetWithOptions,
132+
_,
133+
dispatch,
134+
129135
backgroundData: getBackgroundData(state, globalSettings, debug),
136+
130137
fetching: getFetchingForNarrow(state, props.narrow),
131138
messageListElementsForShownMessages: getMessageListElementsMemoized(
132139
props.messages,
@@ -151,22 +158,6 @@ function useSelectorProps(props: OuterProps) {
151158
}));
152159
}
153160

154-
function useMessageListProps(outerProps: OuterProps): Props {
155-
const _ = useContext(TranslationContext);
156-
const showActionSheetWithOptions: ShowActionSheetWithOptions =
157-
useActionSheet().showActionSheetWithOptions;
158-
const dispatch = useDispatch();
159-
const selectorProps = useSelectorProps(outerProps);
160-
161-
return {
162-
...outerProps,
163-
showActionSheetWithOptions,
164-
_,
165-
dispatch,
166-
...selectorProps,
167-
};
168-
}
169-
170161
/**
171162
* The URL of the platform-specific assets folder.
172163
*

0 commit comments

Comments
 (0)