Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3254218
D6757.id22675.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D6757.id22675.diff
View Options
diff --git a/native/chat/compose-thread-button.react.js b/native/chat/compose-thread-button.react.js
--- a/native/chat/compose-thread-button.react.js
+++ b/native/chat/compose-thread-button.react.js
@@ -11,45 +11,43 @@
import SWMansionIcon from '../components/swmansion-icon.react.js';
import { MessageListRouteName } from '../navigation/route-names.js';
import { useSelector } from '../redux/redux-utils.js';
-import { type Colors, useColors } from '../themes/colors.js';
+import { useColors } from '../themes/colors.js';
-type BaseProps = {
- +navigate: $PropertyType<ChatNavigationProp<'ChatThreadList'>, 'navigate'>,
-};
type Props = {
- ...BaseProps,
- +colors: Colors,
- +viewerID: ?string,
+ +navigate: $PropertyType<ChatNavigationProp<'ChatThreadList'>, 'navigate'>,
};
-class ComposeThreadButton extends React.PureComponent<Props> {
- render() {
- const { listForegroundSecondaryLabel } = this.props.colors;
- return (
- <Button onPress={this.onPress} androidBorderlessRipple={true}>
- <SWMansionIcon
- name="edit-4"
- size={26}
- style={styles.composeButton}
- color={listForegroundSecondaryLabel}
- />
- </Button>
- );
- }
-
- onPress = () => {
- if (this.props.viewerID) {
- this.props.navigate<'MessageList'>({
- name: MessageListRouteName,
- params: {
- threadInfo: createPendingThread({
- viewerID: this.props.viewerID,
- threadType: threadTypes.PRIVATE,
- }),
- searching: true,
- },
- });
+function ComposeThreadButton(props: Props) {
+ const { navigate } = props;
+ const viewerID = useSelector(
+ state => state.currentUserInfo && state.currentUserInfo.id,
+ );
+ const onPress = React.useCallback(() => {
+ if (!viewerID) {
+ return;
}
- };
+ navigate<'MessageList'>({
+ name: MessageListRouteName,
+ params: {
+ threadInfo: createPendingThread({
+ viewerID,
+ threadType: threadTypes.PRIVATE,
+ }),
+ searching: true,
+ },
+ });
+ }, [navigate, viewerID]);
+
+ const { listForegroundSecondaryLabel } = useColors();
+ return (
+ <Button onPress={onPress} androidBorderlessRipple={true}>
+ <SWMansionIcon
+ name="edit-4"
+ size={26}
+ style={styles.composeButton}
+ color={listForegroundSecondaryLabel}
+ />
+ </Button>
+ );
}
const styles = StyleSheet.create({
@@ -58,17 +56,8 @@
},
});
-const ConnectedComposeThreadButton: React.ComponentType<BaseProps> = React.memo<BaseProps>(
- function ConnectedComposeThreadButton(props) {
- const colors = useColors();
- const viewerID = useSelector(
- state => state.currentUserInfo && state.currentUserInfo.id,
- );
-
- return (
- <ComposeThreadButton {...props} colors={colors} viewerID={viewerID} />
- );
- },
+const MemoizedComposeThreadButton: React.ComponentType<Props> = React.memo<Props>(
+ ComposeThreadButton,
);
-export default ConnectedComposeThreadButton;
+export default MemoizedComposeThreadButton;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 7:36 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2501662
Default Alt Text
D6757.id22675.diff (3 KB)
Attached To
Mode
D6757: [native] Convert ComposeThreadButton to a hook
Attached
Detach File
Event Timeline
Log In to Comment