mirror of
				https://github.com/tooot-app/app
				synced 2025-06-05 22:19:13 +02:00 
			
		
		
		
	Fix timeline when length is short
When list is short, it somehow can fetch more
This commit is contained in:
		| @@ -39,7 +39,16 @@ const Timeline: React.FC<Props> = ({ | |||||||
|     return () => AppState.removeEventListener('change', handleAppStateChange) |     return () => AppState.removeEventListener('change', handleAppStateChange) | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
|   const queryKey: App.QueryKey = [page, { page, hashtag, list, toot, account }] |   const queryKey: App.QueryKey = [ | ||||||
|  |     page, | ||||||
|  |     { | ||||||
|  |       page, | ||||||
|  |       ...(hashtag && { hashtag }), | ||||||
|  |       ...(list && { list }), | ||||||
|  |       ...(toot && { toot }), | ||||||
|  |       ...(account && { account }) | ||||||
|  |     } | ||||||
|  |   ] | ||||||
|   const { |   const { | ||||||
|     isSuccess, |     isSuccess, | ||||||
|     isLoading, |     isLoading, | ||||||
| @@ -50,7 +59,14 @@ const Timeline: React.FC<Props> = ({ | |||||||
|     fetchMore, |     fetchMore, | ||||||
|     refetch |     refetch | ||||||
|   } = useInfiniteQuery(queryKey, timelineFetch, { |   } = useInfiniteQuery(queryKey, timelineFetch, { | ||||||
|     getFetchMore: last => last?.toots.length > 0 |     getFetchMore: (last, all) => { | ||||||
|  |       const allLastGroup = all[all.length - 1]! | ||||||
|  |       return ( | ||||||
|  |         last?.toots.length > 0 && | ||||||
|  |         allLastGroup.toots[allLastGroup.toots.length - 1].id !== | ||||||
|  |           last?.toots[last?.toots.length - 1].id | ||||||
|  |       ) | ||||||
|  |     } | ||||||
|   }) |   }) | ||||||
|   const flattenData = data ? data.flatMap(d => [...d?.toots]) : [] |   const flattenData = data ? data.flatMap(d => [...d?.toots]) : [] | ||||||
|   const flattenPointer = data ? data.flatMap(d => [d?.pointer]) : [] |   const flattenPointer = data ? data.flatMap(d => [d?.pointer]) : [] | ||||||
| @@ -71,7 +87,7 @@ const Timeline: React.FC<Props> = ({ | |||||||
|   const flRenderItem = useCallback(({ item }) => { |   const flRenderItem = useCallback(({ item }) => { | ||||||
|     switch (page) { |     switch (page) { | ||||||
|       case 'Conversations': |       case 'Conversations': | ||||||
|         return <TimelineConversation item={item} /> |         return <TimelineConversation item={item} queryKey={queryKey} /> | ||||||
|       case 'Notifications': |       case 'Notifications': | ||||||
|         return <TimelineNotifications notification={item} queryKey={queryKey} /> |         return <TimelineNotifications notification={item} queryKey={queryKey} /> | ||||||
|       default: |       default: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user