Skip to content

Commit dd95088

Browse files
ShapeKim98stealmh
authored andcommitted
[fix] #120 CategoryDetail 페이징 재조회 로직 추가
1 parent 3434ed2 commit dd95088

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

Projects/App/Sources/MainTab/MainTabPath.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public extension MainTabFeature {
137137

138138
/// - 컨텐츠 상세보기 내부 액션 실행
139139
case .contentDetail(.presented(.delegate(.즐겨찾기_갱신_완료))),
140-
.contentDetail(.presented(.delegate(.컨텐츠_조회_완료))):
140+
.contentDetail(.presented(.delegate(.컨텐츠_조회_완료))),
141+
.contentDetail(.presented(.delegate(.컨텐츠_삭제_완료))):
141142
guard let stackElementId = state.path.ids.last,
142143
let lastPath = state.path.last else {
143144
switch state.selectedTab {

Projects/Feature/FeatureCategoryDetail/Sources/CategoryDetailFeature.swift

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)