File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
src/hooks/useGetChannelVideos Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ export function useGetChannelVideos({
5959 skip,
6060 // pollingInterval,
6161 selectFromResult : ( result ) => {
62- const { data } = result ;
63- let { count = 0 , total = 0 } = data || { } ;
62+ let { data } = result ;
6463 let ids : string [ ] = [ ] ;
6564
6665 if ( data ) {
66+ let { count = 0 , total = 0 } = data ;
6767 // Fix: wrong total count (ex: maxResults = 6, total = 2, count = 1)
6868 if (
6969 activitiesMaxResults &&
@@ -104,15 +104,17 @@ export function useGetChannelVideos({
104104 endIndex = Math . min ( endIndex , startIndex + maxResults ) ;
105105 }
106106 ids = ids . slice ( startIndex , endIndex ) ;
107+ // Update data
108+ data = {
109+ ...data ,
110+ count,
111+ total,
112+ } ;
107113 }
108114
109115 return {
110116 ...result ,
111- data : {
112- ...data ,
113- count,
114- total,
115- } ,
117+ data,
116118 ids,
117119 } ;
118120 } ,
@@ -130,11 +132,11 @@ export function useGetChannelVideos({
130132 // pollingInterval,
131133 selectFromResult : ( result ) => {
132134 let { data } = result ;
133- let items = data ?. items ;
134- let count = items ?. length || 0 ;
135- let total = activities . data ?. total || 0 ;
136135
137- if ( items ) {
136+ if ( data ) {
137+ let items = data . items ;
138+ let count = items ?. length || 0 ;
139+ let total = activities . data ?. total || 0 ;
138140 // Fix: force filter by publish date (since we may receive wrong activities data from the youtube API sometimes)
139141 if ( publishedAfter ) {
140142 items = items . filter (
You can’t perform that action at this time.
0 commit comments