Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3349306
D9989.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D9989.diff
View Options
diff --git a/native/chat/chat-list.react.js b/native/chat/chat-list.react.js
--- a/native/chat/chat-list.react.js
+++ b/native/chat/chat-list.react.js
@@ -1,5 +1,10 @@
// @flow
+import type {
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+} from '@react-navigation/core';
import invariant from 'invariant';
import _sum from 'lodash/fp/sum.js';
import * as React from 'react';
@@ -24,6 +29,7 @@
type KeyboardState,
KeyboardContext,
} from '../keyboard/keyboard-state.js';
+import type { ScreenParamList } from '../navigation/route-names.js';
import type { TabNavigationProp } from '../navigation/tab-navigator.react.js';
import { useSelector } from '../redux/redux-utils.js';
import type { ChatMessageItemWithHeight } from '../types/chat-types.js';
@@ -80,16 +86,28 @@
}
componentDidMount() {
- const tabNavigation: ?TabNavigationProp<'Chat'> =
- this.props.navigation.getParent();
+ const tabNavigation = this.props.navigation.getParent<
+ ScreenParamList,
+ 'Chat',
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+ TabNavigationProp<'Chat'>,
+ >();
invariant(tabNavigation, 'ChatNavigator should be within TabNavigator');
tabNavigation.addListener('tabPress', this.onTabPress);
this.props.inputState?.addScrollToMessageListener(this.scrollToMessage);
}
componentWillUnmount() {
- const tabNavigation: ?TabNavigationProp<'Chat'> =
- this.props.navigation.getParent();
+ const tabNavigation = this.props.navigation.getParent<
+ ScreenParamList,
+ 'Chat',
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+ TabNavigationProp<'Chat'>,
+ >();
invariant(tabNavigation, 'ChatNavigator should be within TabNavigator');
tabNavigation.removeListener('tabPress', this.onTabPress);
this.props.inputState?.removeScrollToMessageListener(this.scrollToMessage);
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
@@ -1,6 +1,14 @@
// @flow
import IonIcon from '@expo/vector-icons/Ionicons.js';
+import type {
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+ StackNavigationState,
+ StackOptions,
+ StackNavigationEventMap,
+} from '@react-navigation/core';
import invariant from 'invariant';
import * as React from 'react';
import {
@@ -40,6 +48,7 @@
HomeChatThreadListRouteName,
BackgroundChatThreadListRouteName,
type NavigationRoute,
+ type ScreenParamList,
} from '../navigation/route-names.js';
import type { TabNavigationProp } from '../navigation/tab-navigator.react.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -415,11 +424,24 @@
}, [navigation]);
React.useEffect(() => {
- const chatNavigation: ?ChatNavigationProp<'ChatThreadList'> =
- navigation.getParent();
+ const chatNavigation = navigation.getParent<
+ ScreenParamList,
+ 'ChatThreadList',
+ StackNavigationState,
+ StackOptions,
+ StackNavigationEventMap,
+ ChatNavigationProp<'ChatThreadList'>,
+ >();
invariant(chatNavigation, 'ChatNavigator should be within TabNavigator');
- const tabNavigation: ?TabNavigationProp<'Chat'> =
- chatNavigation.getParent();
+
+ const tabNavigation = chatNavigation.getParent<
+ ScreenParamList,
+ 'Chat',
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+ TabNavigationProp<'Chat'>,
+ >();
invariant(tabNavigation, 'ChatNavigator should be within TabNavigator');
tabNavigation.addListener('tabPress', onTabPress);
diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js
--- a/native/chat/settings/thread-settings.react.js
+++ b/native/chat/settings/thread-settings.react.js
@@ -1,5 +1,10 @@
// @flow
+import type {
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+} from '@react-navigation/core';
import invariant from 'invariant';
import * as React from 'react';
import { View, Platform } from 'react-native';
@@ -88,8 +93,9 @@
AddUsersModalRouteName,
ComposeSubchannelModalRouteName,
FullScreenThreadMediaGalleryRouteName,
+ type ScreenParamList,
+ type NavigationRoute,
} from '../../navigation/route-names.js';
-import type { NavigationRoute } from '../../navigation/route-names.js';
import type { TabNavigationProp } from '../../navigation/tab-navigator.react.js';
import { useSelector } from '../../redux/redux-utils.js';
import type { AppState } from '../../redux/state-types.js';
@@ -1239,7 +1245,14 @@
const { navigation } = props;
React.useEffect(() => {
- const tabNavigation: ?TabNavigationProp<'Chat'> = navigation.getParent();
+ const tabNavigation = navigation.getParent<
+ ScreenParamList,
+ 'Chat',
+ TabNavigationState,
+ BottomTabOptions,
+ BottomTabNavigationEventMap,
+ TabNavigationProp<'Chat'>,
+ >();
invariant(tabNavigation, 'ChatNavigator should be within TabNavigator');
const onTabPress = () => {
diff --git a/native/flow-typed/npm/@react-navigation/core_v6.x.x.js b/native/flow-typed/npm/@react-navigation/core_v6.x.x.js
--- a/native/flow-typed/npm/@react-navigation/core_v6.x.x.js
+++ b/native/flow-typed/npm/@react-navigation/core_v6.x.x.js
@@ -868,7 +868,20 @@
+isFocused: () => boolean,
+canGoBack: () => boolean,
+getId: () => string | void,
- +getParent: <Parent: NavigationProp<ParamListBase>>(id?: string) => ?Parent,
+ +getParent: <
+ ParamList: ParamListBase,
+ RouteName: $Keys<ParamList>,
+ State: PossiblyStaleNavigationState,
+ ScreenOptions: {...},
+ EventMap: EventMapBase,
+ Parent: NavigationProp<
+ ParamList,
+ RouteName,
+ State,
+ ScreenOptions,
+ EventMap,
+ >,
+ >(id?: string) => ?Parent,
+getState: () => NavigationState,
+addListener: <EventName: $Keys<
{| ...EventMap, ...EventMapCore<State> |},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 5:37 PM (20 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571798
Default Alt Text
D9989.diff (6 KB)
Attached To
Mode
D9989: [Flow202][native][skip-ci] [5/x] Fix parameterization of ReactNav getParent
Attached
Detach File
Event Timeline
Log In to Comment