From 1a32c49bc984a3b53a8d0e77f12f8bb6c5352aa0 Mon Sep 17 00:00:00 2001 From: Jakz Date: Fri, 20 Oct 2023 11:46:08 +0800 Subject: [PATCH] Move mentionable hook to shared --- .../Feed/CommentsBottomSheet/CommentsBottomSheet.tsx | 2 +- .../components/Search/Community/CommunitySearchResult.tsx | 2 +- apps/mobile/src/components/Search/SearchResults.tsx | 2 +- apps/mobile/src/components/Search/User/UserSearchResult.tsx | 2 +- apps/mobile/src/screens/PostScreen/PostComposerScreen.tsx | 2 +- .../shared}/src/hooks/useMentionableMessage.ts | 5 +++-- packages/shared/src/utils/isFeatureEnabled.tsx | 3 ++- 7 files changed, 10 insertions(+), 8 deletions(-) rename {apps/mobile => packages/shared}/src/hooks/useMentionableMessage.ts (97%) diff --git a/apps/mobile/src/components/Feed/CommentsBottomSheet/CommentsBottomSheet.tsx b/apps/mobile/src/components/Feed/CommentsBottomSheet/CommentsBottomSheet.tsx index 2e2d4bc1fe..a609143e59 100644 --- a/apps/mobile/src/components/Feed/CommentsBottomSheet/CommentsBottomSheet.tsx +++ b/apps/mobile/src/components/Feed/CommentsBottomSheet/CommentsBottomSheet.tsx @@ -12,7 +12,6 @@ import { Keyboard } from 'react-native'; import Animated, { useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated'; import { graphql, useFragment, useLazyLoadQuery, usePaginationFragment } from 'react-relay'; import { useEventComment } from 'src/hooks/useEventComment'; -import { useMentionableMessage } from 'src/hooks/useMentionableMessage'; import { usePostComment } from 'src/hooks/usePostComment'; import { CommentsBottomSheetList } from '~/components/Feed/CommentsBottomSheet/CommentsBottomSheetList'; @@ -31,6 +30,7 @@ import { CommentsBottomSheetConnectedCommentsListQuery } from '~/generated/Comme import { CommentsBottomSheetConnectedPostCommentsListFragment$key } from '~/generated/CommentsBottomSheetConnectedPostCommentsListFragment.graphql'; import { CommentsBottomSheetConnectedPostCommentsListQuery } from '~/generated/CommentsBottomSheetConnectedPostCommentsListQuery.graphql'; import { CommentsBottomSheetQueryFragment$key } from '~/generated/CommentsBottomSheetQueryFragment.graphql'; +import { useMentionableMessage } from '~/shared/hooks/useMentionableMessage'; import { removeNullValues } from '~/shared/relay/removeNullValues'; import { noop } from '~/shared/utils/noop'; diff --git a/apps/mobile/src/components/Search/Community/CommunitySearchResult.tsx b/apps/mobile/src/components/Search/Community/CommunitySearchResult.tsx index 371467e73a..ddde3fbb30 100644 --- a/apps/mobile/src/components/Search/Community/CommunitySearchResult.tsx +++ b/apps/mobile/src/components/Search/Community/CommunitySearchResult.tsx @@ -1,11 +1,11 @@ import { useNavigation } from '@react-navigation/native'; import { useCallback } from 'react'; import { graphql, useFragment } from 'react-relay'; -import { MentionType } from 'src/hooks/useMentionableMessage'; import { CommunityProfilePicture } from '~/components/ProfilePicture/CommunityProfilePicture'; import { CommunitySearchResultFragment$key } from '~/generated/CommunitySearchResultFragment.graphql'; import { MainTabStackNavigatorProp } from '~/navigation/types'; +import { MentionType } from '~/shared/hooks/useMentionableMessage'; import { SearchResult } from '../SearchResult'; diff --git a/apps/mobile/src/components/Search/SearchResults.tsx b/apps/mobile/src/components/Search/SearchResults.tsx index 97aee79528..0b2333b2b5 100644 --- a/apps/mobile/src/components/Search/SearchResults.tsx +++ b/apps/mobile/src/components/Search/SearchResults.tsx @@ -2,12 +2,12 @@ import { FlashList, ListRenderItem } from '@shopify/flash-list'; import { useCallback, useDeferredValue, useMemo } from 'react'; import { View } from 'react-native'; import { graphql, useLazyLoadQuery } from 'react-relay'; -import { MentionType } from 'src/hooks/useMentionableMessage'; import { CommunitySearchResultFragment$key } from '~/generated/CommunitySearchResultFragment.graphql'; import { GallerySearchResultFragment$key } from '~/generated/GallerySearchResultFragment.graphql'; import { SearchResultsQuery } from '~/generated/SearchResultsQuery.graphql'; import { UserSearchResultFragment$key } from '~/generated/UserSearchResultFragment.graphql'; +import { MentionType } from '~/shared/hooks/useMentionableMessage'; import { Typography } from '../Typography'; import { CommunitySearchResult } from './Community/CommunitySearchResult'; diff --git a/apps/mobile/src/components/Search/User/UserSearchResult.tsx b/apps/mobile/src/components/Search/User/UserSearchResult.tsx index 850dd0b30b..8594677964 100644 --- a/apps/mobile/src/components/Search/User/UserSearchResult.tsx +++ b/apps/mobile/src/components/Search/User/UserSearchResult.tsx @@ -1,11 +1,11 @@ import { useNavigation } from '@react-navigation/native'; import { useCallback } from 'react'; import { graphql, useFragment } from 'react-relay'; -import { MentionType } from 'src/hooks/useMentionableMessage'; import { ProfilePicture } from '~/components/ProfilePicture/ProfilePicture'; import { UserSearchResultFragment$key } from '~/generated/UserSearchResultFragment.graphql'; import { MainTabStackNavigatorProp } from '~/navigation/types'; +import { MentionType } from '~/shared/hooks/useMentionableMessage'; import { SearchResult } from '../SearchResult'; diff --git a/apps/mobile/src/screens/PostScreen/PostComposerScreen.tsx b/apps/mobile/src/screens/PostScreen/PostComposerScreen.tsx index afff1a4097..c35932b5ff 100644 --- a/apps/mobile/src/screens/PostScreen/PostComposerScreen.tsx +++ b/apps/mobile/src/screens/PostScreen/PostComposerScreen.tsx @@ -3,7 +3,6 @@ import { Suspense, useCallback, useRef, useState } from 'react'; import { Keyboard, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { graphql, useFragment, useLazyLoadQuery } from 'react-relay'; -import { useMentionableMessage } from 'src/hooks/useMentionableMessage'; import { BackButton } from '~/components/BackButton'; import { GalleryBottomSheetModalType } from '~/components/GalleryBottomSheet/GalleryBottomSheetModal'; @@ -23,6 +22,7 @@ import { PostStackNavigatorParamList, } from '~/navigation/types'; import { contexts } from '~/shared/analytics/constants'; +import { useMentionableMessage } from '~/shared/hooks/useMentionableMessage'; import { noop } from '~/shared/utils/noop'; import { PostComposerNftFallback } from './PostComposerNftFallback'; diff --git a/apps/mobile/src/hooks/useMentionableMessage.ts b/packages/shared/src/hooks/useMentionableMessage.ts similarity index 97% rename from apps/mobile/src/hooks/useMentionableMessage.ts rename to packages/shared/src/hooks/useMentionableMessage.ts index 0ab516c56b..2874171636 100644 --- a/apps/mobile/src/hooks/useMentionableMessage.ts +++ b/packages/shared/src/hooks/useMentionableMessage.ts @@ -1,9 +1,10 @@ import { useCallback, useState } from 'react'; import { graphql, useFragment } from 'react-relay'; -import isFeatureEnabled, { FeatureFlag } from 'src/utils/isFeatureEnabled'; import { useMentionableMessageQueryFragment$key } from '~/generated/useMentionableMessageQueryFragment.graphql'; -import useDebounce from '~/shared/hooks/useDebounce'; + +import isFeatureEnabled, { FeatureFlag } from '../utils/isFeatureEnabled'; +import useDebounce from './useDebounce'; type MentionDataType = { interval: { diff --git a/packages/shared/src/utils/isFeatureEnabled.tsx b/packages/shared/src/utils/isFeatureEnabled.tsx index 3f4b450b29..546ec70704 100644 --- a/packages/shared/src/utils/isFeatureEnabled.tsx +++ b/packages/shared/src/utils/isFeatureEnabled.tsx @@ -4,7 +4,8 @@ import { isFeatureEnabledFragment$key, Role as RelayRole, } from '~/generated/isFeatureEnabledFragment.graphql'; -import { removeNullValues } from '~/relay/removeNullValues'; + +import { removeNullValues } from '../relay/removeNullValues'; export enum FeatureFlag { KOALA = 'KOALA',