Page MenuHomePhabricator

D9261.diff
No OneTemporary

D9261.diff

diff --git a/native/user-profile/user-profile-utils.js b/native/user-profile/user-profile-utils.js
new file mode 100644
--- /dev/null
+++ b/native/user-profile/user-profile-utils.js
@@ -0,0 +1,40 @@
+// @flow
+
+import { useNavigation } from '@react-navigation/native';
+import _throttle from 'lodash/throttle.js';
+import * as React from 'react';
+
+import {
+ UserProfileBottomSheetRouteName,
+ UserProfileBottomSheetNavigatorRouteName,
+} from '../navigation/route-names.js';
+
+function useNavigateToUserProfileBottomSheet(): (userID: string) => mixed {
+ const { navigate } = useNavigation();
+
+ return React.useMemo(
+ () =>
+ _throttle(
+ (userID: string) => {
+ navigate<'UserProfileBottomSheetNavigator'>(
+ UserProfileBottomSheetNavigatorRouteName,
+ {
+ screen: UserProfileBottomSheetRouteName,
+ params: {
+ userID,
+ },
+ key: `${UserProfileBottomSheetNavigatorRouteName}|${UserProfileBottomSheetRouteName}|${userID}`,
+ },
+ );
+ },
+ 500, // 500ms throttle delay
+ {
+ leading: true,
+ trailing: false,
+ },
+ ),
+ [navigate],
+ );
+}
+
+export { useNavigateToUserProfileBottomSheet };

File Metadata

Mime Type
text/plain
Expires
Sat, Sep 21, 7:44 AM (22 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2160165
Default Alt Text
D9261.diff (1 KB)

Event Timeline