@@ -6,6 +6,7 @@ import { FeedViewType, views } from "@follow/constants"
6
6
import { useTitle , useTypeScriptHappyCallback } from "@follow/hooks"
7
7
import type { FeedModel } from "@follow/models/types"
8
8
import { clsx , isBizId } from "@follow/utils/utils"
9
+ import type { FunctionComponent } from "react"
9
10
import { memo , useCallback , useEffect , useMemo , useRef , useState } from "react"
10
11
import { useTranslation } from "react-i18next"
11
12
import type {
@@ -42,6 +43,10 @@ const scrollSeekConfiguration: ScrollSeekConfiguration = {
42
43
enter : ( velocity ) => Math . abs ( velocity ) > 1000 ,
43
44
exit : ( velocity ) => Math . abs ( velocity ) < 1000 ,
44
45
}
46
+
47
+ export type VirtuosoComponentProps = { onlyShowArchivedButton : boolean }
48
+ type VirtuosoComponentPropsContext = { context ?: VirtuosoComponentProps }
49
+
45
50
function EntryColumnImpl ( ) {
46
51
const { t } = useTranslation ( )
47
52
const virtuosoRef = useRef < VirtuosoHandle > ( null )
@@ -116,7 +121,7 @@ function EntryColumnImpl() {
116
121
117
122
// Determine if the archived button should be shown
118
123
const showArchivedButton = commonConditions && entries . totalCount < 40 && feed ?. type === "feed"
119
- const hasNoEntries = entries . totalCount === 0 && ! entries . isLoading
124
+ const hasNoEntries = entries . queryTotalCount === 0 && ! entries . isLoading
120
125
121
126
// Determine if archived entries should be loaded
122
127
const shouldLoadArchivedEntries =
@@ -136,31 +141,35 @@ function EntryColumnImpl() {
136
141
const virtuosoOptions = {
137
142
components : {
138
143
List : EntryListContent ,
139
- Footer : useCallback ( ( ) => {
140
- if ( ! isFetchingNextPage ) {
141
- if ( showArchivedButton ) {
144
+ Footer : useCallback (
145
+ ( { context } : VirtuosoComponentPropsContext ) => {
146
+ if ( ! isFetchingNextPage ) {
147
+ if ( showArchivedButton ) {
148
+ return (
149
+ < div className = "flex justify-center py-4" >
150
+ < Button variant = "outline" onClick = { ( ) => setIsArchived ( true ) } >
151
+ { t ( "words.load_archived_entries" ) }
152
+ </ Button >
153
+ </ div >
154
+ )
155
+ } else {
156
+ return null
157
+ }
158
+ } else {
159
+ if ( context ?. onlyShowArchivedButton ) return null
142
160
return (
143
- < div className = "flex justify-center py-4" >
144
- < Button variant = "outline" onClick = { ( ) => setIsArchived ( true ) } >
145
- { t ( "words.load_archived_entries" ) }
146
- </ Button >
147
- </ div >
161
+ < EntryItemSkeleton
162
+ view = { view }
163
+ count = { Math . min (
164
+ entries . data ?. pages ?. [ 0 ] . data ?. length || 20 ,
165
+ entries . data ?. pages . at ( - 1 ) ?. remaining || 20 ,
166
+ ) }
167
+ />
148
168
)
149
- } else {
150
- return null
151
169
}
152
- } else {
153
- return (
154
- < EntryItemSkeleton
155
- view = { view }
156
- count = { Math . min (
157
- entries . data ?. pages ?. [ 0 ] . data ?. length || 20 ,
158
- entries . data ?. pages . at ( - 1 ) ?. remaining || 20 ,
159
- ) }
160
- />
161
- )
162
- }
163
- } , [ isFetchingNextPage , showArchivedButton , t , view , entries . data ?. pages ] ) ,
170
+ } ,
171
+ [ isFetchingNextPage , showArchivedButton , t , view , entries . data ?. pages ] ,
172
+ ) ,
164
173
ScrollSeekPlaceholder : useCallback ( ( ) => < EntryItemSkeleton view = { view } count = { 1 } /> , [ view ] ) ,
165
174
} ,
166
175
scrollSeekConfiguration,
@@ -194,7 +203,7 @@ function EntryColumnImpl() {
194
203
} ,
195
204
[ view ] ,
196
205
) ,
197
- } satisfies VirtuosoProps < string , unknown >
206
+ } satisfies VirtuosoProps < string , VirtuosoComponentProps >
198
207
199
208
const navigate = useNavigateEntry ( )
200
209
const isRefreshing = entries . isFetching && ! entries . isFetchingNextPage
@@ -272,7 +281,10 @@ const ListGird = ({
272
281
virtuosoRef,
273
282
hasNextPage,
274
283
} : {
275
- virtuosoOptions : Omit < VirtuosoGridProps < string , unknown > , "data" | "endReached" > & {
284
+ virtuosoOptions : Omit <
285
+ VirtuosoGridProps < string , VirtuosoComponentProps > ,
286
+ "data" | "endReached"
287
+ > & {
276
288
data : string [ ]
277
289
endReached : ( ) => Promise < any >
278
290
}
@@ -339,6 +351,11 @@ const ListGird = ({
339
351
data = { nextData }
340
352
/>
341
353
354
+ { virtuosoOptions . components ?. Footer &&
355
+ ( virtuosoOptions . components . Footer as FunctionComponent < VirtuosoComponentPropsContext > ) ( {
356
+ context : { onlyShowArchivedButton : true } ,
357
+ } ) }
358
+
342
359
{ FilteredContentTip }
343
360
</ >
344
361
)
0 commit comments