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

Commit

Permalink
Merge remote-tracking branch 'origin/staging' into feat/integrate-cre…
Browse files Browse the repository at this point in the history
…ator-token-collectors
  • Loading branch information
alantoa committed Nov 1, 2023
2 parents aeac95b + e2ba07e commit 29d37ab
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 498 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "showtime",
"version": "149.0.7",
"version": "149.0.12",
"private": true,
"license": "MIT",
"devDependencies": {
Expand Down
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 @@ -22,28 +22,6 @@ export const MessagesHeader = (props: HeaderProps) => {
const router = useRouter();
const isDark = useIsDarkMode();

const viewMembersList = useCallback(() => {
const as = `/channels/${props.channelId}/members`;

router.push(
Platform.select({
native: as,
web: {
pathname: router.pathname,
query: {
...router.query,
channelsMembersModal: true,
},
} as any,
}),
Platform.select({
native: as,
web: router.asPath,
}),
{ shallow: true }
);
}, [props.channelId, router]);

const inviteAllowlist = useCallback(() => {
const as = "/creator-token/import-allowlist";
router.push(
Expand Down Expand Up @@ -112,8 +90,7 @@ export const MessagesHeader = (props: HeaderProps) => {
/>
</Pressable>
) : (
// TODO: Creator Tokens P1 (hide hidden class)
<Pressable onPress={inviteAllowlist} tw="hidden">
<Pressable onPress={inviteAllowlist}>
<AccessTicket
height={Platform.OS === "web" ? 20 : 24}
width={Platform.OS === "web" ? 20 : 24}
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
14 changes: 8 additions & 6 deletions packages/app/components/creator-channels/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,17 @@ export type Channel = {
owner: ChannelProfile;
};

export type ChannelPermissions = {
can_send_messages: boolean;
can_upload_media: boolean;
can_view_creator_messages: boolean;
can_view_public_messages: boolean;
};

export type ChannelById = {
viewer_has_unlocked_messages: boolean;
latest_paid_nft_slug?: string;
permissions: {
can_send_messages: boolean;
can_upload_media: boolean;
can_view_creator_messages: boolean;
can_view_public_messages: boolean;
};
permissions: ChannelPermissions | null;
} & Channel;

export type ChannelSetting = {
Expand Down
Loading

0 comments on commit 29d37ab

Please sign in to comment.