Skip to content

Commit

Permalink
Stop requesting twitter content (#1718)
Browse files Browse the repository at this point in the history
* stop requesting twitter content

* disable twitter modal on web

* disable twitter on mobile

* lint

* bring back suggested users

---------

Co-authored-by: kaito <80802871+kaitoo1@users.noreply.github.com>
  • Loading branch information
Robinnnnn and kaitoo1 authored Jul 20, 2023
1 parent abc6197 commit b65e6f0
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 73 deletions.
75 changes: 48 additions & 27 deletions apps/mobile/src/screens/HomeScreen/ExploreScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { View } from 'react-native';
import { graphql, useLazyLoadQuery, useRefetchableFragment } from 'react-relay';

import { GalleryRefreshControl } from '~/components/GalleryRefreshControl';
import { USERS_PER_PAGE } from '~/components/Trending/constants';
import { LoadingTrendingPage } from '~/components/Trending/LoadingTrendingPage';
import { SuggestedSection } from '~/components/Trending/SuggestedSection';
import { TrendingSection } from '~/components/Trending/TrendingSection';
import { TwitterSection } from '~/components/Trending/TwitterSection';
import { ExploreScreenFragment$key } from '~/generated/ExploreScreenFragment.graphql';
import { ExploreScreenQuery } from '~/generated/ExploreScreenQuery.graphql';
import { SuggestedSectionQueryFragment$key } from '~/generated/SuggestedSectionQueryFragment.graphql';
Expand Down Expand Up @@ -51,20 +49,21 @@ function ExploreScreenInner({ queryRef }: ExploreScreenInnerProps) {
}
}
# [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
viewer {
__typename
... on Viewer {
socialAccounts @required(action: THROW) {
twitter {
__typename
}
}
}
# ... on Viewer {
# socialAccounts @required(action: THROW) {
# twitter {
# __typename
# }
# }
# }
}
# ...TwitterSectionQueryFragment
...TrendingSectionQueryFragment
...SuggestedSectionQueryFragment
...TwitterSectionQueryFragment
}
`,
queryRef
Expand All @@ -74,15 +73,17 @@ function ExploreScreenInner({ queryRef }: ExploreScreenInnerProps) {

const renderItem = useCallback<ListRenderItem<ListItemType>>(
({ item }) => {
if (item.kind === 'twitter') {
return (
<TwitterSection
title="Twitter Friends"
description="Curators you know from Twitter"
queryRef={query}
/>
);
} else if (item.kind === 'suggested') {
// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
// if (item.kind === 'twitter') {
// return (
// <TwitterSection
// title="Twitter Friends"
// description="Curators you know from Twitter"
// queryRef={query}
// />
// );
// }
if (item.kind === 'suggested') {
return (
<SuggestedSection
title="In your orbit"
Expand All @@ -109,10 +110,11 @@ function ExploreScreenInner({ queryRef }: ExploreScreenInnerProps) {
const items = useMemo((): ListItemType[] => {
const items: ListItemType[] = [];

// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
if (query.viewer?.__typename === 'Viewer') {
if (query.viewer.socialAccounts.twitter?.__typename) {
items.push({ kind: 'twitter', queryRef: query });
}
// if (query.viewer.socialAccounts.twitter?.__typename) {
// items.push({ kind: 'twitter', queryRef: query });
// }

items.push({ kind: 'suggested', queryRef: query });
}
Expand Down Expand Up @@ -155,17 +157,36 @@ function ExploreScreenInner({ queryRef }: ExploreScreenInnerProps) {
);
}

// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
//
// export function ExploreScreen() {
// const query = useLazyLoadQuery<ExploreScreenQuery>(
// graphql`
// query ExploreScreenQuery($twitterListFirst: Int!, $twitterListAfter: String) {
// ...ExploreScreenFragment
// }
// `,
// {
// twitterListFirst: USERS_PER_PAGE,
// twitterListAfter: null,
// }
// );

// return (
// <Suspense fallback={<LoadingTrendingPage />}>
// <ExploreScreenInner queryRef={query} />
// </Suspense>
// );
// }

export function ExploreScreen() {
const query = useLazyLoadQuery<ExploreScreenQuery>(
graphql`
query ExploreScreenQuery($twitterListFirst: Int!, $twitterListAfter: String) {
query ExploreScreenQuery {
...ExploreScreenFragment
}
`,
{
twitterListFirst: USERS_PER_PAGE,
twitterListAfter: null,
}
{}
);

return (
Expand Down
15 changes: 7 additions & 8 deletions apps/web/pages/[username]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import styled from 'styled-components';

import breakpoints, { pageGutter } from '~/components/core/breakpoints';
import useVerifyEmailOnPage from '~/components/Email/useVerifyEmailOnPage';
import useOpenTwitterFollowingModal from '~/components/Twitter/useOpenTwitterFollowingModal';
import useOpenTwitterModal from '~/components/Twitter/useOpenTwitterModal';
import { USER_PER_PAGE } from '~/constants/twitter';
import { GalleryNavbar } from '~/contexts/globalLayout/GlobalNavbar/GalleryNavbar/GalleryNavbar';
import { useGlobalNavbarHeight } from '~/contexts/globalLayout/GlobalNavbar/useGlobalNavbarHeight';
import { StandardSidebar } from '~/contexts/globalLayout/GlobalSidebar/StandardSidebar';
Expand All @@ -29,9 +27,7 @@ const UsernameQueryNode = graphql`
$sharedCommunitiesFirst: Int
$sharedCommunitiesAfter: String
$sharedFollowersFirst: Int
$sharedFollowersAfter: String
$twitterListFirst: Int!
$twitterListAfter: String
$sharedFollowersAfter: String # [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again # $twitterListFirst: Int! # $twitterListAfter: String
) {
userByUsername(username: $username) @required(action: THROW) {
... on GalleryUser {
Expand All @@ -47,7 +43,8 @@ const UsernameQueryNode = graphql`
...useVerifyEmailOnPageQueryFragment
...StandardSidebarFragment
...useOpenTwitterModalFragment
...useOpenTwitterFollowingModalFragment
# [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
# ...useOpenTwitterFollowingModalFragment
}
`;

Expand Down Expand Up @@ -93,7 +90,8 @@ export default function UserGallery({ username, preloadedQuery }: UserGalleryPro

useVerifyEmailOnPage(query);
useOpenTwitterModal(query);
useOpenTwitterFollowingModal(query);
// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
// useOpenTwitterFollowingModal(query);

return (
<GalleryRoute
Expand Down Expand Up @@ -128,7 +126,8 @@ UserGallery.preloadQuery = ({ relayEnvironment, query }: PreloadQueryArgs) => {
username: query.username,
sharedCommunitiesFirst: COMMUNITIES_PER_PAGE,
sharedFollowersFirst: FOLLOWERS_PER_PAGE,
twitterListFirst: USER_PER_PAGE,
// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
// twitterListFirst: USER_PER_PAGE,
},
{ fetchPolicy: 'store-or-network' }
);
Expand Down
43 changes: 32 additions & 11 deletions apps/web/pages/explore.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
import { graphql, useLazyLoadQuery } from 'react-relay';

import useOpenTwitterFollowingModal from '~/components/Twitter/useOpenTwitterFollowingModal';
import { USER_PER_PAGE } from '~/constants/twitter';
import { HomeNavbar } from '~/contexts/globalLayout/GlobalNavbar/HomeNavbar/HomeNavbar';
import { StandardSidebar } from '~/contexts/globalLayout/GlobalSidebar/StandardSidebar';
import { exploreQuery } from '~/generated/exploreQuery.graphql';
import GalleryRoute from '~/scenes/_Router/GalleryRoute';
import ExplorePage from '~/scenes/Home/ExploreHomePage';

// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
//
// export default function Explore() {
// const query = useLazyLoadQuery<exploreQuery>(
// graphql`
// query exploreQuery($twitterListFirst: Int!, $twitterListAfter: String) {
// ...ExploreHomePageFragment
// ...HomeNavbarFragment
// ...StandardSidebarFragment

// ...useOpenTwitterFollowingModalFragment
// }
// `,
// {
// twitterListFirst: USER_PER_PAGE,
// twitterListAfter: null,
// }
// );

// useOpenTwitterFollowingModal(query);

// return (
// <GalleryRoute
// navbar={<HomeNavbar queryRef={query} />}
// sidebar={<StandardSidebar queryRef={query} />}
// element={<ExplorePage queryRef={query} />}
// />
// );
// }

export default function Explore() {
const query = useLazyLoadQuery<exploreQuery>(
graphql`
query exploreQuery($twitterListFirst: Int!, $twitterListAfter: String) {
query exploreQuery {
...ExploreHomePageFragment
...HomeNavbarFragment
...StandardSidebarFragment
...useOpenTwitterFollowingModalFragment
}
`,
{
twitterListFirst: USER_PER_PAGE,
twitterListAfter: null,
}
{}
);

useOpenTwitterFollowingModal(query);

return (
<GalleryRoute
navbar={<HomeNavbar queryRef={query} />}
Expand Down
15 changes: 7 additions & 8 deletions apps/web/pages/trending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { graphql, loadQuery, PreloadedQuery, usePreloadedQuery } from 'react-rel

import { ITEMS_PER_PAGE, MAX_PIECES_DISPLAYED_PER_FEED_EVENT } from '~/components/Feed/constants';
import { NOTES_PER_PAGE } from '~/components/Feed/Socialize/CommentsModal/CommentsModal';
import useOpenTwitterFollowingModal from '~/components/Twitter/useOpenTwitterFollowingModal';
import { USER_PER_PAGE } from '~/constants/twitter';
import { HomeNavbar } from '~/contexts/globalLayout/GlobalNavbar/HomeNavbar/HomeNavbar';
import { StandardSidebar } from '~/contexts/globalLayout/GlobalSidebar/StandardSidebar';
import { trendingPageQuery } from '~/generated/trendingPageQuery.graphql';
Expand All @@ -19,13 +17,12 @@ const trendingPageQueryNode = graphql`
$trendingBefore: String
$globalLast: Int!
$globalBefore: String
$visibleTokensPerFeedEvent: Int!
$twitterListFirst: Int!
$twitterListAfter: String
$visibleTokensPerFeedEvent: Int! # [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again # $twitterListFirst: Int! # $twitterListAfter: String
) {
...TrendingHomePageFragment
...HomeNavbarFragment
...useOpenTwitterFollowingModalFragment
# [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
# ...useOpenTwitterFollowingModalFragment
...StandardSidebarFragment
}
`;
Expand All @@ -37,7 +34,8 @@ type Props = {
export default function Trending({ preloadedQuery }: Props) {
const query = usePreloadedQuery(trendingPageQueryNode, preloadedQuery);

useOpenTwitterFollowingModal(query);
// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
// useOpenTwitterFollowingModal(query);

return (
<GalleryRoute
Expand All @@ -57,7 +55,8 @@ Trending.preloadQuery = ({ relayEnvironment }: PreloadQueryArgs) => {
globalLast: ITEMS_PER_PAGE,
trendingLast: ITEMS_PER_PAGE,
visibleTokensPerFeedEvent: MAX_PIECES_DISPLAYED_PER_FEED_EVENT,
twitterListFirst: USER_PER_PAGE,
// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
// twitterListFirst: USER_PER_PAGE,
},
{ fetchPolicy: 'store-or-network' }
);
Expand Down
40 changes: 21 additions & 19 deletions apps/web/src/components/Explore/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { graphql, useFragment } from 'react-relay';
import styled from 'styled-components';

import { ExploreFragment$key } from '~/generated/ExploreFragment.graphql';
import { ReportingErrorBoundary } from '~/shared/errors/ReportingErrorBoundary';

import { VStack } from '../core/Spacer/Stack';
import SuggestedSection from './SuggestedSection';
import TrendingSection from './TrendingSection';
import TwitterSection from './TwitterSection';

type Props = {
queryRef: ExploreFragment$key;
Expand All @@ -32,18 +30,19 @@ export default function Explore({ queryRef }: Props) {
viewer {
__typename
... on Viewer {
socialAccounts @required(action: THROW) {
twitter {
__typename
}
}
}
# [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
# ... on Viewer {
# socialAccounts @required(action: THROW) {
# twitter {
# __typename
# }
# }
# }
}
# ...TwitterSectionQueryFragment
...TrendingSectionQueryFragment
...SuggestedSectionQueryFragment
...TwitterSectionQueryFragment
}
`,
queryRef
Expand All @@ -53,15 +52,18 @@ export default function Explore({ queryRef }: Props) {
<StyledExplorePage gap={48}>
{query.viewer?.__typename === 'Viewer' && (
<>
{query.viewer.socialAccounts?.twitter?.__typename && (
<ReportingErrorBoundary fallback={null}>
<TwitterSection
title="Twitter Friends"
subTitle="Curators you know from Twitter"
queryRef={query}
/>
</ReportingErrorBoundary>
)}
{
// [GAL-3763] Revive this if / when elon lets us import twitter follower graphs again
// query.viewer.socialAccounts?.twitter?.__typename && (
// <ReportingErrorBoundary fallback={null}>
// <TwitterSection
// title="Twitter Friends"
// subTitle="Curators you know from Twitter"
// queryRef={query}
// />
// </ReportingErrorBoundary>
// )
}
<SuggestedSection
title="In your orbit"
subTitle="Curators you may enjoy based on your activity"
Expand Down

0 comments on commit b65e6f0

Please sign in to comment.