diff --git a/src/app/Routes/HomeStack.tsx b/src/app/Routes/HomeStack.tsx index 4e67f0f..8c0c869 100644 --- a/src/app/Routes/HomeStack.tsx +++ b/src/app/Routes/HomeStack.tsx @@ -15,18 +15,15 @@ const Stack = createStackNavigator(); type Props = { route: RouteProp; navigation: BottomTabNavigationProp; + openMessages: () => void; }; -const HomePageStack: React.FC = ({ route }) => ( +const HomePageStack: React.FC = ({ openMessages }) => ( - + + {(props) => } + diff --git a/src/app/Routes/MessageStack.tsx b/src/app/Routes/MessageStack.tsx index 8175796..e9ad3cb 100644 --- a/src/app/Routes/MessageStack.tsx +++ b/src/app/Routes/MessageStack.tsx @@ -28,11 +28,9 @@ const MessageStack: React.FC = ({ navigation }) => { return ( - + + {(props) => } + diff --git a/src/app/Routes/Navigation.tsx b/src/app/Routes/Navigation.tsx index 0cc58c3..e06e8fa 100644 --- a/src/app/Routes/Navigation.tsx +++ b/src/app/Routes/Navigation.tsx @@ -59,10 +59,6 @@ export const TabNavigation: React.FC = ({ navigation }) => { > ( = ({ navigation }) => { /> ), }} - /> + > + {(props) => ( + + )} + ; navigation: StackNavigationProp; + openMessages: () => void; }; -const Home: React.FC = observer(({ route }) => { +const Home: React.FC = observer(({ openMessages }) => { const { colors, dark } = useTheme(); const { fetchFeed, loading, posts: feedPosts } = useFeed(); const { height } = useWindowDimensions(); - const openMessages = () => - route.params.openMessages && route.params.openMessages(); - const [openedModalData, setOpenedModalData] = useState<{ modalType: "MENU" | "SHARE"; username: string; diff --git a/src/app/Screens/Messages/ChatList.tsx b/src/app/Screens/Messages/ChatList.tsx index f575c6c..41f3022 100644 --- a/src/app/Screens/Messages/ChatList.tsx +++ b/src/app/Screens/Messages/ChatList.tsx @@ -21,6 +21,7 @@ import { getTimeDistance } from "../../utils/utils"; type Props = { route: RouteProp; navigation: StackNavigationProp; + goBack: () => void; }; type UserItemProps = { @@ -69,7 +70,7 @@ const UserListItem: React.FC = ({ item, openMessage }) => { ); }; -const MessagesList: React.FC = ({ navigation, route }) => { +const MessagesList: React.FC = ({ navigation, route, goBack }) => { const { colors, dark } = useTheme(); const { height } = useWindowDimensions(); const { messageList, loading, fetchMessageList } = useChatList(); @@ -77,8 +78,6 @@ const MessagesList: React.FC = ({ navigation, route }) => { const newMessage = () => navigation.navigate("NewChat"); - const goBack = () => route.params.goBack && route.params.goBack(); - const openMessage = (username: string) => { navigation.navigate("Messages", { username, diff --git a/src/app/types/navigation.ts b/src/app/types/navigation.ts index edb73c5..791ca79 100644 --- a/src/app/types/navigation.ts +++ b/src/app/types/navigation.ts @@ -5,17 +5,13 @@ import { User } from "../store/UsersStore"; import { definitions } from "./supabase"; export type MessageStackNavigationParams = { - ChatList: { - goBack: () => void; - }; + ChatList: undefined; NewChat: undefined; Messages: { username: string; }; Comments: CommentsPageParams; - Profile: ProfilePageProps & { - goBack: () => void; - }; + Profile: ProfilePageProps; Post: { post: Pick; user: Pick; @@ -40,22 +36,16 @@ export type SwipeTabNavigationParams = { Messages: undefined; }; export type HomeStackNavigationParams = { - Home: { - openMessages: () => void; - }; + Home: undefined; Comments: CommentsPageParams; - Profile: ProfilePageProps & { - goBack: () => void; - }; + Profile: ProfilePageProps; }; export type ProfileStackParams = { Messages: { username: string; }; - ProfilePage: ProfilePageProps & { - goBack?: () => void; - }; + ProfilePage: ProfilePageProps & { goBack: () => void }; Followers: ProfilePageProps & { followers: Follower[]; }; @@ -82,9 +72,7 @@ export type ExploreStackNavigationParams = { user: Pick; }; Comments: CommentsPageParams; - Profile: ProfilePageProps & { - goBack: () => void; - }; + Profile: ProfilePageProps; }; export type PostListParams = { goBack: () => void; @@ -103,9 +91,7 @@ export type PostStackNavigationParams = { }; export type TabNavigationParams = { - Home: { - openMessages: () => void; - }; + Home: undefined; Explore: undefined; // Activity: undefined; New: undefined;