@@ -40,6 +40,9 @@ public struct ContentListFeature {
4040 contentList. forEach { identifiedArray. append ( $0) }
4141 return identifiedArray
4242 }
43+ var contentCount : Int {
44+ get { domain. contentCount }
45+ }
4346 var isListDescending = true
4447 /// sheet item
4548 var bottomSheetItem : BaseContentItem ? = nil
@@ -87,15 +90,16 @@ public struct ContentListFeature {
8790 case pagenation_네트워크_결과( BaseContentListInquiry )
8891 case pagenation_초기화
8992 case 컨텐츠_목록_갱신( BaseContentListInquiry )
93+ case 컨텐츠_개수_갱신( Int )
9094 }
9195
9296 public enum AsyncAction : Equatable {
9397 case 읽지않음_컨텐츠_조회
9498 case 즐겨찾기_링크모음_조회
9599 case 컨텐츠_삭제( id: Int )
96100 case pagenation_네트워크
97- case 컨텐츠_목록_갱신
98101 case 페이징_재조회
102+ case 컨텐츠_개수_조회
99103 }
100104
101105 public enum ScopeAction : Equatable {
@@ -175,7 +179,6 @@ private extension ContentListFeature {
175179 ]
176180 return . send( . inner( . pagenation_초기화) , animation: . pokitDissolve)
177181 case . backButtonTapped:
178-
179182 return . run { _ in await dismiss ( ) }
180183 case . contentListViewOnAppeared:
181184 return . run { [ type = state. contentType] send in
@@ -193,7 +196,7 @@ private extension ContentListFeature {
193196 }
194197
195198 case . pagenation:
196- return . run { send in await send ( . async( . pagenation_네트워크) ) }
199+ return . send( . async( . pagenation_네트워크) )
197200 case . 링크_공유_완료:
198201 state. shareSheetItem = nil
199202 return . none
@@ -232,6 +235,9 @@ private extension ContentListFeature {
232235 case let . 컨텐츠_목록_갱신( contentList) :
233236 state. domain. contentList = contentList
234237 return . none
238+ case let . 컨텐츠_개수_갱신( count) :
239+ state. domain. contentCount = count
240+ return . none
235241 }
236242 }
237243
@@ -240,6 +246,7 @@ private extension ContentListFeature {
240246 switch action {
241247 case . 읽지않음_컨텐츠_조회:
242248 return . run { [ pageable = state. domain. pageable] send in
249+ await send ( . async( . 컨텐츠_개수_조회) )
243250 let contentList = try await remindClient. 읽지않음_컨텐츠_조회 (
244251 BasePageableRequest (
245252 page: pageable. page,
@@ -254,6 +261,7 @@ private extension ContentListFeature {
254261 }
255262 case . 즐겨찾기_링크모음_조회:
256263 return . run { [ pageable = state. domain. pageable] send in
264+ await send ( . async( . 컨텐츠_개수_조회) )
257265 let contentList = try await remindClient. 즐겨찾기_링크모음_조회 (
258266 BasePageableRequest (
259267 page: pageable. page,
@@ -267,7 +275,9 @@ private extension ContentListFeature {
267275 )
268276 }
269277 case . 컨텐츠_삭제( id: let id) :
270- return . run { [ id] send in
278+ return . run { [ count = state. domain. contentCount] send in
279+ let newCount = count - 1
280+ await send ( . inner( . 컨텐츠_개수_갱신( newCount) ) , animation: . pokitSpring)
271281 let _ = try await contentClient. 컨텐츠_삭제 ( " \( id) " )
272282 await send ( . inner( . 컨텐츠_삭제_반영( id: id) ) , animation: . pokitSpring)
273283 }
@@ -323,6 +333,7 @@ private extension ContentListFeature {
323333 pageable = state. domain. pageable,
324334 contentType = state. contentType
325335 ] send in
336+ await send ( . async( . 컨텐츠_개수_조회) )
326337 let stream = AsyncThrowingStream < BaseContentListInquiry , Error > { continuation in
327338 Task {
328339 for page in 0 ... pageable. page {
@@ -357,6 +368,17 @@ private extension ContentListFeature {
357368 guard let contentItems else { return }
358369 await send ( . inner( . 컨텐츠_목록_갱신( contentItems) ) , animation: . pokitSpring)
359370 }
371+ case . 컨텐츠_개수_조회:
372+ return . run { [ contentType = state. contentType ] send in
373+ switch contentType {
374+ case . favorite:
375+ let count = try await remindClient. 즐겨찾기_컨텐츠_개수_조회 ( ) . count
376+ await send ( . inner( . 컨텐츠_개수_갱신( count) ) , animation: . pokitSpring)
377+ case . unread:
378+ let count = try await remindClient. 읽지않음_컨텐츠_개수_조회 ( ) . count
379+ await send ( . inner( . 컨텐츠_개수_갱신( count) ) , animation: . pokitSpring)
380+ }
381+ }
360382 }
361383 }
362384
0 commit comments