Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3368380
D9172.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9172.diff
View Options
diff --git a/native/chat/chat-thread-list.react.js b/native/chat/chat-thread-list.react.js
--- a/native/chat/chat-thread-list.react.js
+++ b/native/chat/chat-thread-list.react.js
@@ -138,6 +138,7 @@
pendingPersonalThreadUserInfo?: UserInfo,
) => void,
+onPressSeeMoreSidebars: (threadInfo: ThreadInfo) => void,
+ +hardwareBack: () => boolean,
};
class ChatThreadList extends React.PureComponent<Props> {
@@ -164,7 +165,7 @@
invariant(tabNavigation, 'ChatNavigator should be within TabNavigator');
tabNavigation.addListener('tabPress', this.onTabPress);
- BackHandler.addEventListener('hardwareBackPress', this.hardwareBack);
+ BackHandler.addEventListener('hardwareBackPress', this.props.hardwareBack);
}
componentWillUnmount() {
@@ -178,25 +179,12 @@
invariant(tabNavigation, 'ChatNavigator should be within TabNavigator');
tabNavigation.removeListener('tabPress', this.onTabPress);
- BackHandler.removeEventListener('hardwareBackPress', this.hardwareBack);
+ BackHandler.removeEventListener(
+ 'hardwareBackPress',
+ this.props.hardwareBack,
+ );
}
- hardwareBack = () => {
- if (!this.props.navigation.isFocused()) {
- return false;
- }
-
- const { searchStatus } = this.props;
- const isActiveOrActivating =
- searchStatus === 'active' || searchStatus === 'activating';
- if (!isActiveOrActivating) {
- return false;
- }
-
- this.props.onSearchCancel();
- return true;
- };
-
componentDidUpdate(prevProps: Props) {
const { searchStatus } = this.props;
const prevSearchStatus = prevProps.searchStatus;
@@ -634,6 +622,20 @@
[navigation, onChangeSearchText],
);
+ const hardwareBack = React.useCallback(() => {
+ if (!navigation.isFocused()) {
+ return false;
+ }
+ const isActiveOrActivating =
+ searchStatus === 'active' || searchStatus === 'activating';
+ if (!isActiveOrActivating) {
+ return false;
+ }
+
+ onSearchCancel();
+ return true;
+ }, [navigation, onSearchCancel, searchStatus]);
+
return (
<ChatThreadList
navigation={navigation}
@@ -673,6 +675,7 @@
renderSearch={renderSearch}
onPressItem={onPressItem}
onPressSeeMoreSidebars={onPressSeeMoreSidebars}
+ hardwareBack={hardwareBack}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 7:35 PM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585919
Default Alt Text
D9172.diff (2 KB)
Attached To
Mode
D9172: [native] Lift `hardwareBack` to `ConnectedChatThreadList`
Attached
Detach File
Event Timeline
Log In to Comment