|
@@ -10,6 +10,8 @@ import {
|
|
GetChannelsQueryVariables,
|
|
GetChannelsQueryVariables,
|
|
GetMostFollowedChannelsAllTimeQuery,
|
|
GetMostFollowedChannelsAllTimeQuery,
|
|
GetMostFollowedChannelsAllTimeQueryVariables,
|
|
GetMostFollowedChannelsAllTimeQueryVariables,
|
|
|
|
+ GetMostFollowedChannelsQuery,
|
|
|
|
+ GetMostFollowedChannelsQueryVariables,
|
|
GetMostViewedChannelsAllTimeQuery,
|
|
GetMostViewedChannelsAllTimeQuery,
|
|
GetMostViewedChannelsAllTimeQueryVariables,
|
|
GetMostViewedChannelsAllTimeQueryVariables,
|
|
GetMostViewedChannelsQuery,
|
|
GetMostViewedChannelsQuery,
|
|
@@ -21,6 +23,7 @@ import {
|
|
useGetChannelQuery,
|
|
useGetChannelQuery,
|
|
useGetChannelsQuery,
|
|
useGetChannelsQuery,
|
|
useGetMostFollowedChannelsAllTimeQuery,
|
|
useGetMostFollowedChannelsAllTimeQuery,
|
|
|
|
+ useGetMostFollowedChannelsQuery,
|
|
useGetMostViewedChannelsAllTimeQuery,
|
|
useGetMostViewedChannelsAllTimeQuery,
|
|
useGetMostViewedChannelsQuery,
|
|
useGetMostViewedChannelsQuery,
|
|
useGetVideoCountQuery,
|
|
useGetVideoCountQuery,
|
|
@@ -133,10 +136,45 @@ export const useUnfollowChannel = (opts?: UnfollowChannelOpts) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-type MostPopularChannelsOpts = QueryHookOptions<GetMostViewedChannelsQuery>
|
|
|
|
|
|
+type MostFollowedChannelsOpts = QueryHookOptions<GetMostFollowedChannelsQuery>
|
|
|
|
+export const useMostFollowedChannelsIds = (
|
|
|
|
+ variables?: GetMostFollowedChannelsQueryVariables,
|
|
|
|
+ opts?: MostFollowedChannelsOpts
|
|
|
|
+) => {
|
|
|
|
+ const { data, ...rest } = useGetMostFollowedChannelsQuery({ ...opts, variables })
|
|
|
|
+ return {
|
|
|
|
+ mostFollowedChannels: data?.mostFollowedChannels,
|
|
|
|
+ ...rest,
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const useMostFollowedChannels = (
|
|
|
|
+ variables?: GetMostFollowedChannelsQueryVariables,
|
|
|
|
+ opts?: MostFollowedChannelsOpts
|
|
|
|
+) => {
|
|
|
|
+ const { mostFollowedChannels } = useMostFollowedChannelsIds(variables, opts)
|
|
|
|
+
|
|
|
|
+ const mostFollowedChannelsIds = mostFollowedChannels?.map((item) => item.id)
|
|
|
|
+
|
|
|
|
+ const { channels, ...rest } = useChannels(
|
|
|
|
+ {
|
|
|
|
+ where: {
|
|
|
|
+ id_in: mostFollowedChannelsIds,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ { skip: !mostFollowedChannelsIds }
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ channels,
|
|
|
|
+ ...rest,
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type MostViewedChannelsOpts = QueryHookOptions<GetMostViewedChannelsQuery>
|
|
export const useMostViewedChannelsIds = (
|
|
export const useMostViewedChannelsIds = (
|
|
variables?: GetMostViewedChannelsQueryVariables,
|
|
variables?: GetMostViewedChannelsQueryVariables,
|
|
- opts?: MostPopularChannelsOpts
|
|
|
|
|
|
+ opts?: MostViewedChannelsOpts
|
|
) => {
|
|
) => {
|
|
const { data, ...rest } = useGetMostViewedChannelsQuery({ ...opts, variables })
|
|
const { data, ...rest } = useGetMostViewedChannelsQuery({ ...opts, variables })
|
|
return {
|
|
return {
|
|
@@ -147,16 +185,11 @@ export const useMostViewedChannelsIds = (
|
|
|
|
|
|
export const useMostViewedChannels = (
|
|
export const useMostViewedChannels = (
|
|
variables?: GetMostViewedChannelsQueryVariables,
|
|
variables?: GetMostViewedChannelsQueryVariables,
|
|
- opts?: MostPopularChannelsOpts
|
|
|
|
|
|
+ opts?: MostViewedChannelsOpts
|
|
) => {
|
|
) => {
|
|
const { mostViewedChannels } = useMostViewedChannelsIds(variables, opts)
|
|
const { mostViewedChannels } = useMostViewedChannelsIds(variables, opts)
|
|
|
|
|
|
- const mostViewedChannelsIds = useMemo(() => {
|
|
|
|
- if (mostViewedChannels) {
|
|
|
|
- return mostViewedChannels.map((item) => item.id)
|
|
|
|
- }
|
|
|
|
- return null
|
|
|
|
- }, [mostViewedChannels])
|
|
|
|
|
|
+ const mostViewedChannelsIds = mostViewedChannels?.map((item) => item.id)
|
|
|
|
|
|
const { channels, ...rest } = useChannels(
|
|
const { channels, ...rest } = useChannels(
|
|
{
|
|
{
|
|
@@ -194,7 +227,7 @@ export const useMostFollowedChannelsAllTimeIds = (
|
|
|
|
|
|
export const useMostFollowedChannelsAllTime = (
|
|
export const useMostFollowedChannelsAllTime = (
|
|
variables?: GetMostFollowedChannelsAllTimeQueryVariables,
|
|
variables?: GetMostFollowedChannelsAllTimeQueryVariables,
|
|
- opts?: MostPopularChannelsOpts
|
|
|
|
|
|
+ opts?: MostFollowedChannelsAllTimeOpts
|
|
) => {
|
|
) => {
|
|
const { mostFollowedChannelsAllTime } = useMostFollowedChannelsAllTimeIds(variables, opts)
|
|
const { mostFollowedChannelsAllTime } = useMostFollowedChannelsAllTimeIds(variables, opts)
|
|
|
|
|
|
@@ -222,10 +255,10 @@ export const useMostFollowedChannelsAllTime = (
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-type MostPopularChannelsAllTimeOpts = QueryHookOptions<GetMostViewedChannelsAllTimeQuery>
|
|
|
|
|
|
+type MostViewedChannelsAllTimeOpts = QueryHookOptions<GetMostViewedChannelsAllTimeQuery>
|
|
export const useMostViewedChannelsAllTimeIds = (
|
|
export const useMostViewedChannelsAllTimeIds = (
|
|
variables?: GetMostViewedChannelsAllTimeQueryVariables,
|
|
variables?: GetMostViewedChannelsAllTimeQueryVariables,
|
|
- opts?: MostPopularChannelsAllTimeOpts
|
|
|
|
|
|
+ opts?: MostViewedChannelsAllTimeOpts
|
|
) => {
|
|
) => {
|
|
const { data, ...rest } = useGetMostViewedChannelsAllTimeQuery({ ...opts, variables })
|
|
const { data, ...rest } = useGetMostViewedChannelsAllTimeQuery({ ...opts, variables })
|
|
return {
|
|
return {
|
|
@@ -236,7 +269,7 @@ export const useMostViewedChannelsAllTimeIds = (
|
|
|
|
|
|
export const useMostViewedChannelsAllTime = (
|
|
export const useMostViewedChannelsAllTime = (
|
|
variables?: GetMostViewedChannelsAllTimeQueryVariables,
|
|
variables?: GetMostViewedChannelsAllTimeQueryVariables,
|
|
- opts?: MostPopularChannelsOpts
|
|
|
|
|
|
+ opts?: MostViewedChannelsAllTimeOpts
|
|
) => {
|
|
) => {
|
|
const { mostViewedChannelsAllTime } = useMostViewedChannelsAllTimeIds(variables, opts)
|
|
const { mostViewedChannelsAllTime } = useMostViewedChannelsAllTimeIds(variables, opts)
|
|
|
|
|