@@ -118,6 +118,7 @@ public struct CategoryDetailFeature {
118118 case 카테고리_내_컨텐츠_목록_조회
119119 case 컨텐츠_삭제( id: Int )
120120 case pagenation_네트워크
121+ case 페이징_재조회
121122 }
122123
123124 public enum ScopeAction : Equatable {
@@ -307,6 +308,45 @@ private extension CategoryDetailFeature {
307308 case . pagenation_네트워크:
308309 state. domain. pageable. page += 1
309310 return . send( . async( . 카테고리_내_컨텐츠_목록_조회) )
311+ case . 페이징_재조회:
312+ return . run { [
313+ pageable = state. domain. pageable,
314+ categoryId = state. domain. category. id,
315+ condition = state. domain. condition
316+ ] send in
317+ let stream = AsyncThrowingStream < BaseContentListInquiry , Error > { continuation in
318+ Task {
319+ for page in 0 ... pageable. page {
320+ let paeagableRequest = BasePageableRequest (
321+ page: page,
322+ size: pageable. size,
323+ sort: pageable. sort
324+ )
325+ let conditionRequest = BaseConditionRequest (
326+ categoryIds: condition. categoryIds,
327+ isRead: condition. isUnreadFlitered,
328+ favorites: condition. isFavoriteFlitered
329+ )
330+ let contentList = try await contentClient. 카테고리_내_컨텐츠_목록_조회 (
331+ " \( categoryId) " ,
332+ paeagableRequest,
333+ conditionRequest
334+ ) . toDomain ( )
335+ continuation. yield ( contentList)
336+ }
337+ continuation. finish ( )
338+ }
339+ }
340+ var contentItems : BaseContentListInquiry ? = nil
341+ for try await contentList in stream {
342+ let items = contentItems? . data ?? [ ]
343+ let newItems = contentList. data ?? [ ]
344+ contentItems = contentList
345+ contentItems? . data = items + newItems
346+ }
347+ guard let contentItems else { return }
348+ await send ( . inner( . 카테고리_내_컨텐츠_목록_갱신( contentItems) ) , animation: . pokitSpring)
349+ }
310350 }
311351 }
312352
@@ -413,7 +453,7 @@ private extension CategoryDetailFeature {
413453 func handleDelegateAction( _ action: Action . DelegateAction , state: inout State ) -> Effect < Action > {
414454 switch action {
415455 case . 카테고리_내_컨텐츠_목록_조회:
416- return . send( . async( . 카테고리_내_컨텐츠_목록_조회 ) )
456+ return . send( . async( . 페이징_재조회 ) )
417457 default :
418458 return . none
419459 }
0 commit comments