@@ -25,19 +25,15 @@ public struct CategorySharingFeature {
2525 @ObservableState
2626 public struct State : Equatable {
2727 fileprivate var domain : CategorySharing
28- var category : CategorySharing . Category {
29- get { domain. sharedCategory. category }
30- }
28+ var category : CategorySharing . Category { domain. sharedCategory. category }
3129 var contents : IdentifiedArrayOf < CategorySharing . Content > ? {
3230 var identifiedArray = IdentifiedArrayOf < CategorySharing . Content > ( )
3331 domain. sharedCategory. contentList. data. forEach { content in
3432 identifiedArray. append ( content)
3533 }
3634 return identifiedArray
3735 }
38- var hasNext : Bool {
39- get { domain. sharedCategory. contentList. hasNext }
40- }
36+ var hasNext : Bool { domain. sharedCategory. contentList. hasNext }
4137 var error : BaseError ?
4238 var isErrorSheetPresented : Bool = false
4339
@@ -63,27 +59,26 @@ public struct CategorySharingFeature {
6359
6460 @CasePathable
6561 public enum View : Equatable , BindableAction {
66- case 저장버튼_클릭
67- case 컨텐츠_아이템_클릭( CategorySharing . Content )
68- case 뒤로가기버튼_클릭
69- case 경고_확인버튼_클릭
70-
71- case 다음페이지_로딩_onAppear
72-
7362 case binding( BindingAction < State > )
63+ case dismiss
64+
65+ case 저장_버튼_눌렀을때
66+ case 컨텐츠_항목_눌렀을때( CategorySharing . Content )
67+ case 경고_확인버튼_눌렀을때
68+ case 페이지_로딩중일때
7469 }
7570
7671 public enum InnerAction : Equatable {
77- case 공유받은_카테고리_갱신 ( CategorySharing . SharedCategory )
72+ case 공유받은_카테고리_API_반영 ( CategorySharing . SharedCategory )
7873 case 경고_닫음
7974 case 경고_띄움( BaseError )
8075 }
8176
8277 public enum AsyncAction : Equatable {
83- case 공유받은_카테고리_조회
78+ case 공유받은_카테고리_조회_API
8479 }
8580
86- public enum ScopeAction : Equatable { case doNothing }
81+ public enum ScopeAction : Equatable { case 없음 }
8782
8883 public enum DelegateAction : Equatable {
8984 case 컨텐츠_아이템_클릭( categoryId: Int , content: CategorySharing . Content )
@@ -130,32 +125,39 @@ private extension CategorySharingFeature {
130125 /// - View Effect
131126 func handleViewAction( _ action: Action . View , state: inout State ) -> Effect < Action > {
132127 switch action {
133- case . 저장버튼_클릭:
128+ case . binding:
129+ return . none
130+
131+ case . dismiss:
132+ return . run { _ in await dismiss ( ) }
133+
134+ case . 저장_버튼_눌렀을때:
134135 let sharedCategory = state. domain. sharedCategory. category
135136 return . send( . delegate( . 공유받은_카테고리_추가( sharedCategory: sharedCategory) ) )
136- case let . 컨텐츠_아이템_클릭( content) :
137+
138+ case let . 컨텐츠_항목_눌렀을때( content) :
137139 return . send( . delegate( . 컨텐츠_아이템_클릭( categoryId: state. category. categoryId , content: content) ) )
138- case . 뒤로가기버튼_클릭:
139- return . run { _ in await dismiss ( ) }
140- case . 경고_확인버튼_클릭:
141- return . none
142- case . binding:
140+
141+ case . 경고_확인버튼_눌렀을때:
143142 return . none
144- case . 다음페이지_로딩_onAppear:
145- return . send( . async( . 공유받은_카테고리_조회) )
143+
144+ case . 페이지_로딩중일때:
145+ return . send( . async( . 공유받은_카테고리_조회_API) )
146146 }
147147 }
148148
149149 /// - Inner Effect
150150 func handleInnerAction( _ action: Action . InnerAction , state: inout State ) -> Effect < Action > {
151151 switch action {
152- case let . 공유받은_카테고리_갱신 ( sharedCategory) :
152+ case let . 공유받은_카테고리_API_반영 ( sharedCategory) :
153153 state. domain. sharedCategory = sharedCategory
154154 return . none
155+
155156 case let . 경고_띄움( baseError) :
156157 state. error = baseError
157158 state. isErrorSheetPresented = true
158159 return . none
160+
159161 case . 경고_닫음:
160162 state. isErrorSheetPresented = false
161163 state. error = nil
@@ -166,21 +168,18 @@ private extension CategorySharingFeature {
166168 /// - Async Effect
167169 func handleAsyncAction( _ action: Action . AsyncAction , state: inout State ) -> Effect < Action > {
168170 switch action {
169- case . 공유받은_카테고리_조회 :
171+ case . 공유받은_카테고리_조회_API :
170172 state. domain. pageable. page += 1
171173 return . run { [
172174 categoryId = state. domain. sharedCategory. category. categoryId,
173175 pageable = state. domain. pageable
174176 ] send in
177+ let request = BasePageableRequest ( page: pageable. page, size: pageable. size, sort: pageable. sort)
175178 let sharedCategory = try await categoryClient. 공유받은_카테고리_조회 (
176179 " \( categoryId) " ,
177- BasePageableRequest (
178- page: pageable. page,
179- size: pageable. size,
180- sort: pageable. sort
181- )
180+ request
182181 ) . toDomain ( )
183- await send ( . inner( . 공유받은_카테고리_갱신 ( sharedCategory) ) , animation: . pokitDissolve)
182+ await send ( . inner( . 공유받은_카테고리_API_반영 ( sharedCategory) ) , animation: . pokitDissolve)
184183 }
185184 }
186185 }
0 commit comments