Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
refactor: remove suggested creators, deprecated (#2496)
Browse files Browse the repository at this point in the history
  • Loading branch information
hirbod authored Nov 1, 2023
1 parent 2ea78ff commit e02aaee
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 329 deletions.
38 changes: 3 additions & 35 deletions packages/app/components/creator-channels/channels.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { breakpoints } from "design-system/theme";
import {
useJoinedChannelsList,
useOwnedChannelsList,
useSuggestedChannelsList,
} from "./hooks/use-channels-list";
import { useJoinChannel } from "./hooks/use-join-channel";
import { CreatorChannelsList as CreatorChannelsListMobile } from "./list";
Expand All @@ -46,12 +45,6 @@ const channelsSection = {
"Get exclusive updates, presale access and unreleased content from your favorite creators.",
};

const suggestedChannelsSection = {
type: "section",
title: "Popular creators",
tw: "text-xl",
};

const CreatorChannelsHeader = memo(
({
title,
Expand Down Expand Up @@ -330,10 +323,6 @@ export const CreatorChannels = memo(() => {
isLoading: isLoadingJoinedChannels,
} = useJoinedChannelsList();

// suggested channels
const { data: suggestedChannelsData, isLoading: isLoadingSuggestedChannels } =
useSuggestedChannelsList();

// since we're quering two different endpoints, and based on the amount of data from the first endpoint
// we have to transform our data a bit and decide if we build a section list or a single FlashList
// we're going to useMemo for that and return the data in the format we need
Expand All @@ -353,16 +342,6 @@ export const CreatorChannels = memo(() => {
...joinedChannelsData,
]
: []),
// check if we have any suggested channels, if we do, we're going to add a section for them (+ the suggested channels)
...(suggestedChannelsData.length > 0
? [
suggestedChannelsSection,
...suggestedChannelsData.map((suggestedChannel) => ({
...suggestedChannel,
itemType: "creator",
})),
]
: []),
];
} else {
return [
Expand All @@ -378,11 +357,7 @@ export const CreatorChannels = memo(() => {
...joinedChannelsData,
];
}
}, [
joinedChannelsData,
ownedChannelsData,
suggestedChannelsData,
]) as CreatorChannelsListItemProps[];
}, [joinedChannelsData, ownedChannelsData]) as CreatorChannelsListItemProps[];

const renderItem = useCallback(({ item }: CreatorChannelsListProps) => {
if (item.type === "section") {
Expand All @@ -403,11 +378,7 @@ export const CreatorChannels = memo(() => {
}, []);

const ListFooterComponent = useCallback(() => {
if (
isLoadingJoinedChannels ||
isLoadingOwnChannels ||
isLoadingSuggestedChannels
) {
if (isLoadingJoinedChannels || isLoadingOwnChannels) {
return <CCSkeleton />;
}

Expand All @@ -427,7 +398,6 @@ export const CreatorChannels = memo(() => {
}, [
isLoadingJoinedChannels,
isLoadingOwnChannels,
isLoadingSuggestedChannels,
isLoadingMoreJoinedChannels,
]);
if (!isLgWidth) {
Expand Down Expand Up @@ -463,9 +433,7 @@ export const CreatorChannels = memo(() => {
<InfiniteScrollList
useWindowScroll={false}
data={
isLoadingOwnChannels ||
isLoadingJoinedChannels ||
isLoadingSuggestedChannels
isLoadingOwnChannels || isLoadingJoinedChannels
? []
: transformedData
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,37 +81,3 @@ export const useJoinedChannelsList = () => {
data: newData,
};
};

export const useSuggestedChannelsList = (params?: { pageSize?: number }) => {
const pageSize = params?.pageSize || PAGE_SIZE;
const channelsFetcher = useCallback(
(index: number, previousPageData: []) => {
if (previousPageData && !previousPageData.length) return null;
return `/v1/channels/suggested?page=${index + 1}&limit=${pageSize}`;
},
[pageSize]
);

const queryState = useInfiniteListQuerySWR<CreatorChannel[]>(
channelsFetcher,
{
pageSize,
}
);
const newData = useMemo(() => {
let newData: CreatorChannel[] = [];
if (queryState.data) {
queryState.data.forEach((p) => {
if (p) {
newData = newData.concat(p);
}
});
}
return newData;
}, [queryState.data]);

return {
...queryState,
data: newData,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { Logger } from "app/lib/logger";
import { useLogInPromise } from "app/lib/login-promise";
import { captureException } from "app/lib/sentry";

import {
useJoinedChannelsList,
useSuggestedChannelsList,
} from "./use-channels-list";
import { useJoinedChannelsList } from "./use-channels-list";

async function joinChannel(
url: string,
Expand All @@ -34,7 +31,6 @@ export const useJoinChannel = () => {
joinChannel
);
const joinedChannels = useJoinedChannelsList();
const suggestedChannels = useSuggestedChannelsList();
const { onboardingPromise } = useOnboardingPromise();

const handleSubmit = useStableCallback(
Expand All @@ -47,7 +43,6 @@ export const useJoinChannel = () => {
captureException(e);
Logger.error(e);
} finally {
suggestedChannels.mutate();
joinedChannels.mutate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { axios } from "app/lib/axios";
import { Logger } from "app/lib/logger";
import { captureException } from "app/lib/sentry";

import {
useJoinedChannelsList,
useSuggestedChannelsList,
} from "./use-channels-list";
import { useJoinedChannelsList } from "./use-channels-list";

async function leaveChannel(
url: string,
Expand All @@ -26,7 +23,6 @@ export const useLeaveChannel = () => {
leaveChannel
);
const joinedChannels = useJoinedChannelsList();
const suggestedChannels = useSuggestedChannelsList();

const handleSubmit = useStableCallback(
async ({ channelId }: { channelId: string }) => {
Expand All @@ -37,7 +33,6 @@ export const useLeaveChannel = () => {
Logger.error(e);
} finally {
joinedChannels.mutate();
suggestedChannels.mutate();
}
}
);
Expand Down
46 changes: 4 additions & 42 deletions packages/app/components/creator-channels/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { LeanText } from "./components/lean-text";
import {
useJoinedChannelsList,
useOwnedChannelsList,
useSuggestedChannelsList,
} from "./hooks/use-channels-list";
import { useJoinChannel } from "./hooks/use-join-channel";
import {
Expand Down Expand Up @@ -340,12 +339,6 @@ const channelsSection = {
"Get exclusive updates, presale access and unreleased content from your favorite creators.",
};

const suggestedChannelsSection = {
type: "section",
title: "Popular creators",
tw: "text-xl",
};

export const CreatorChannelsList = memo(
({ useWindowScroll = true }: { useWindowScroll?: boolean }) => {
const listRef = useRef<FlashList<any>>(null);
Expand Down Expand Up @@ -376,14 +369,6 @@ export const CreatorChannelsList = memo(
isLoading: isLoadingJoinedChannels,
} = useJoinedChannelsList();

// suggested channels
const {
data: suggestedChannelsData,
refresh: refreshSuggestedChannels,
isLoading: isLoadingSuggestedChannels,
isRefreshing: isRefreshingSuggestedChannels,
} = useSuggestedChannelsList();

// since we're quering two different endpoints, and based on the amount of data from the first endpoint
// we have to transform our data a bit and decide if we build a section list or a single FlashList
// we're going to useMemo for that and return the data in the format we need
Expand All @@ -403,16 +388,6 @@ export const CreatorChannelsList = memo(
...joinedChannelsData,
]
: []),
// check if we have any suggested channels, if we do, we're going to add a section for them (+ the suggested channels)
...(suggestedChannelsData.length > 0
? [
suggestedChannelsSection,
...suggestedChannelsData.map((suggestedChannel) => ({
...suggestedChannel,
itemType: "creator",
})),
]
: []),
];
} else {
return [
Expand All @@ -431,7 +406,6 @@ export const CreatorChannelsList = memo(
}, [
joinedChannelsData,
ownedChannelsData,
suggestedChannelsData,
]) as CreatorChannelsListItemProps[];

const renderItem = useCallback(({ item }: CreatorChannelsListProps) => {
Expand Down Expand Up @@ -479,17 +453,9 @@ export const CreatorChannelsList = memo(
]);

const refreshPage = useCallback(async () => {
await Promise.all([
refresh(),
refreshOwnedChannels(),
refreshSuggestedChannels(),
]);
}, [refresh, refreshOwnedChannels, refreshSuggestedChannels]);
if (
isLoadingOwnChannels ||
isLoadingJoinedChannels ||
isLoadingSuggestedChannels
) {
await Promise.all([refresh(), refreshOwnedChannels()]);
}, [refresh, refreshOwnedChannels]);
if (isLoadingOwnChannels || isLoadingJoinedChannels) {
return <CCSkeleton />;
}
return (
Expand Down Expand Up @@ -521,11 +487,7 @@ export const CreatorChannelsList = memo(
// Todo: unity refresh control same as tab view
refreshControl={
<RefreshControl
refreshing={
isRefreshing ||
isRefreshingOwnedChannels ||
isRefreshingSuggestedChannels
}
refreshing={isRefreshing || isRefreshingOwnedChannels}
onRefresh={refreshPage}
progressViewOffset={headerHeight}
tintColor={isDark ? colors.gray[200] : colors.gray[700]}
Expand Down
2 changes: 0 additions & 2 deletions packages/app/components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { breakpoints } from "design-system/theme";
import { EmptyPlaceholder } from "../empty-placeholder";
import { ListHeaderComponent } from "./header";
import { HomeItem, HomeItemSketelon } from "./home-item";
import { PopularCreators } from "./popular-creators";
import { TrendingCarousel } from "./trending-carousel";

const ViewabilityInfiniteScrollList =
Expand All @@ -44,7 +43,6 @@ export const Home = () => {
return (
<>
<HomeItem nft={item} mediaSize={mediaSize} index={index} />
<PopularCreators />
</>
);
}
Expand Down
Loading

0 comments on commit e02aaee

Please sign in to comment.