Page MenuHomePhabricator

D6757.id22766.diff
No OneTemporary

D6757.id22766.diff

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,16 +56,7 @@
},
});
-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

Mime Type
text/plain
Expires
Sat, Nov 16, 7:58 PM (21 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2501948
Default Alt Text
D6757.id22766.diff (3 KB)

Event Timeline