@@ -73,7 +73,7 @@ public struct FavoritesFeature: Reducer, Sendable {
7373
7474 case sort( PresentationAction < SortFeature . Action > )
7575
76- case _favoritesResponse( Result < [ FavoriteInfo ] , any Error > )
76+ case _favoritesResponse( Result < Favorite , any Error > )
7777 case _loadFavorites( offset: Int )
7878 case _startUnreadLoadingIndicator( id: Int )
7979 case _jumpRequestFailed
@@ -105,6 +105,7 @@ public struct FavoritesFeature: Reducer, Sendable {
105105 case . onAppear:
106106 guard state. favorites. isEmpty && state. favoritesImportant. isEmpty else { return . none }
107107 return . merge( [
108+ updatePageNavigation ( & state, offset: 0 ) ,
108109 . send( . _loadFavorites( offset: 0 ) ) ,
109110 . run { send in
110111 for await _ in notificationCenter. observe ( . favoritesUpdated) {
@@ -245,7 +246,7 @@ public struct FavoritesFeature: Reducer, Sendable {
245246 var favsImportant: [ FavoriteInfo] = [ ]
246247 var favorites: [ FavoriteInfo] = [ ]
247248
248- for favorite in response {
249+ for favorite in response. favorites {
249250 if favorite. isImportant {
250251 favsImportant. append ( favorite)
251252 } else {
@@ -257,14 +258,14 @@ public struct FavoritesFeature: Reducer, Sendable {
257258 state. favorites = favorites
258259
259260 // TODO: Is it ok?
260- state. pageNavigation . count = response. count
261+ // state.pageNavigation.count = response.count
261262
262263 state. isLoading = false
263264 state. isRefreshing = false
264265
265266 reportFullyDisplayed ( & state)
266267
267- return . none
268+ return updatePageNavigation ( & state , count : response . favoritesCount )
268269
269270 case let . _favoritesResponse ( . failure( error) ) :
270271 print( " FAVORITES RESPONSE FAILURE: \( error) " )
@@ -286,12 +287,26 @@ public struct FavoritesFeature: Reducer, Sendable {
286287 }
287288 }
288289
290+ // MARK: - Shared logic
291+
289292 private func reportFullyDisplayed( _ state: inout State) {
290293 guard !state. didLoadOnce else { return }
291294 analyticsClient. reportFullyDisplayed ( )
292295 state. didLoadOnce = true
293296 }
294297
298+ private func updatePageNavigation( _ state: inout State, count: Int = 0 , offset: Int? = nil ) - > Effect< Action> {
299+ return PageNavigationFeature ( )
300+ . reduce (
301+ into: & state. pageNavigation,
302+ action: . update(
303+ count: count,
304+ offset: offset
305+ )
306+ )
307+ . map ( Action . pageNavigation)
308+ }
309+
295310 private func goToEnd( id: Int) - > Effect< Action> {
296311 return . merge(
297312 . run { send in
0 commit comments