From 7926d74635e125e8d554e3220bb0fd768daec8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=95?= <108233361+ShapeKim98@users.noreply.github.com> Date: Sun, 6 Oct 2024 18:38:38 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[refactor]=20#129=20ContentListFeature=20?= =?UTF-8?q?=EC=95=A1=EC=85=98=20=ED=95=9C=EA=B8=80=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContentList/ContentListFeature.swift | 189 ++++++++---------- .../Sources/ContentList/ContentListView.swift | 16 +- 2 files changed, 89 insertions(+), 116 deletions(-) diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift index 0e4404a0..3cea4c0a 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift @@ -66,40 +66,38 @@ public struct ContentListFeature { public enum View: Equatable, BindableAction { /// - Binding case binding(BindingAction) + + case pagenation /// - Button Tapped - case linkCardTapped(content: BaseContentItem) - case kebabButtonTapped(content: BaseContentItem) - case bottomSheetButtonTapped( + case bottomSheet( delegate: PokitBottomSheet.Delegate, content: BaseContentItem ) - case deleteAlertConfirmTapped(content: BaseContentItem) - case sortTextLinkTapped - case backButtonTapped + case 컨텐츠_항목_눌렀을때(content: BaseContentItem) + case 컨텐츠_항목_케밥_버튼_눌렀을때(content: BaseContentItem) + case 컨텐츠_삭제_눌렀을때(content: BaseContentItem) + case 정렬_버튼_눌렀을때 + case 뒤로가기_버튼_눌렀을때 /// - On Appeared - case contentListViewOnAppeared - case pagenation + case 뷰가_나타났을때 - case 링크_공유_완료 + case 링크_공유시트_해제 } public enum InnerAction: Equatable { - case dismissBottomSheet - case 컨텐츠_목록_조회(BaseContentListInquiry) - case 컨텐츠_삭제_반영(id: Int) - case pagenation_네트워크_결과(BaseContentListInquiry) - case pagenation_초기화 - case 컨텐츠_목록_갱신(BaseContentListInquiry) - case 컨텐츠_개수_갱신(Int) + case 바텀시트_해제 + case 컨텐츠_목록_조회_API_반영(BaseContentListInquiry) + case 컨텐츠_삭제_API_반영(id: Int) + case 컨텐츠_목록_조회_페이징_API_반영(BaseContentListInquiry) + case 페이징_초기화 + case 컨텐츠_개수_업데이트(Int) } public enum AsyncAction: Equatable { - case 읽지않음_컨텐츠_조회 - case 즐겨찾기_링크모음_조회 - case 컨텐츠_삭제(id: Int) - case pagenation_네트워크 - case 페이징_재조회 - case 컨텐츠_개수_조회 + case 컨텐츠_삭제_API(id: Int) + case 컨텐츠_목록_조회_페이징_API + case 컨텐츠_목록_조회_API + case 컨텐츠_개수_조회_API } public enum ScopeAction: Equatable { @@ -148,6 +146,7 @@ public struct ContentListFeature { /// - Reducer body public var body: some ReducerOf { Reduce(self.core) + ._printChanges() } } //MARK: - FeatureAction Effect @@ -155,49 +154,46 @@ private extension ContentListFeature { /// - View Effect func handleViewAction(_ action: Action.View, state: inout State) -> Effect { switch action { - case .kebabButtonTapped(let content): + case .컨텐츠_항목_케밥_버튼_눌렀을때(let content): state.bottomSheetItem = content return .none - case .linkCardTapped(let content): + case .컨텐츠_항목_눌렀을때(let content): return .send(.delegate(.링크상세(content: content))) - case .bottomSheetButtonTapped(let delegate, let content): + case .bottomSheet(let delegate, let content): return .run { send in - await send(.inner(.dismissBottomSheet)) + await send(.inner(.바텀시트_해제)) await send(.scope(.bottomSheet(delegate: delegate, content: content))) } - case .deleteAlertConfirmTapped: + case .컨텐츠_삭제_눌렀을때: guard let id = state.alertItem?.id else { return .none } return .run { [id] send in - await send(.async(.컨텐츠_삭제(id: id))) + await send(.async(.컨텐츠_삭제_API(id: id))) } case .binding: return .none - case .sortTextLinkTapped: + case .정렬_버튼_눌렀을때: state.isListDescending.toggle() state.domain.pageable.sort = [ state.isListDescending ? "createdAt,desc" : "createdAt,asc" ] - return .send(.inner(.pagenation_초기화), animation: .pokitDissolve) - case .backButtonTapped: + return .send(.inner(.페이징_초기화), animation: .pokitDissolve) + case .뒤로가기_버튼_눌렀을때: return .run { _ in await dismiss() } - case .contentListViewOnAppeared: - return .run { [type = state.contentType] send in - switch type { - case .unread: - await send(.async(.읽지않음_컨텐츠_조회), animation: .pokitDissolve) - case .favorite: - await send(.async(.즐겨찾기_링크모음_조회), animation: .pokitDissolve) - } - - for await _ in self.pasteBoard.changes() { - let url = try await pasteBoard.probableWebURL() - await send(.delegate(.linkCopyDetected(url)), animation: .pokitSpring) + case .뷰가_나타났을때: + return .merge([ + .send(.async(.컨텐츠_개수_조회_API)), + .send(.async(.컨텐츠_목록_조회_API)), + .run { send in + for await _ in self.pasteBoard.changes() { + let url = try await pasteBoard.probableWebURL() + await send(.delegate(.linkCopyDetected(url)), animation: .pokitSpring) + } } - } - + ]) + case .pagenation: - return .send(.async(.pagenation_네트워크)) - case .링크_공유_완료: + return .send(.async(.컨텐츠_목록_조회_페이징_API)) + case .링크_공유시트_해제: state.shareSheetItem = nil return .none } @@ -206,36 +202,28 @@ private extension ContentListFeature { /// - Inner Effect func handleInnerAction(_ action: Action.InnerAction, state: inout State) -> Effect { switch action { - case .dismissBottomSheet: + case .바텀시트_해제: state.bottomSheetItem = nil return .none - case .컨텐츠_목록_조회(let contentList): + case .컨텐츠_목록_조회_페이징_API_반영(let contentList): let list = state.domain.contentList.data ?? [] guard let newList = contentList.data else { return .none } state.domain.contentList = contentList state.domain.contentList.data = list + newList return .none - case .컨텐츠_삭제_반영(id: let id): + case .컨텐츠_삭제_API_반영(id: let id): state.alertItem = nil state.domain.contentList.data?.removeAll { $0.id == id } return .none - case .pagenation_네트워크_결과(let contentList): + case .컨텐츠_목록_조회_API_반영(let contentList): state.domain.contentList = contentList return .none - case .pagenation_초기화: + case .페이징_초기화: state.domain.pageable.page = 0 state.domain.contentList.data = nil - switch state.contentType { - case .unread: - return .send(.async(.읽지않음_컨텐츠_조회), animation: .pokitDissolve) - case .favorite: - return .send(.async(.즐겨찾기_링크모음_조회), animation: .pokitDissolve) - } - case let .컨텐츠_목록_갱신(contentList): - state.domain.contentList = contentList - return .none - case let .컨텐츠_개수_갱신(count): + return .send(.async(.컨텐츠_목록_조회_API), animation: .pokitDissolve) + case let .컨텐츠_개수_업데이트(count): state.domain.contentCount = count return .none } @@ -244,62 +232,47 @@ private extension ContentListFeature { /// - Async Effect func handleAsyncAction(_ action: Action.AsyncAction, state: inout State) -> Effect { switch action { - case .읽지않음_컨텐츠_조회: - return .run { [pageable = state.domain.pageable] send in - await send(.async(.컨텐츠_개수_조회)) - let contentList = try await remindClient.읽지않음_컨텐츠_조회( - BasePageableRequest( - page: pageable.page, - size: pageable.size, - sort: pageable.sort - ) - ).toDomain() - await send( - .inner(.컨텐츠_목록_조회(contentList)), - animation: pageable.page == 0 ? .pokitDissolve : nil - ) - } - case .즐겨찾기_링크모음_조회: - return .run { [pageable = state.domain.pageable] send in - await send(.async(.컨텐츠_개수_조회)) - let contentList = try await remindClient.즐겨찾기_링크모음_조회( - BasePageableRequest( - page: pageable.page, - size: pageable.size, - sort: pageable.sort - ) - ).toDomain() - await send( - .inner(.컨텐츠_목록_조회(contentList)), - animation: pageable.page == 0 ? .pokitDissolve : nil - ) - } - case .컨텐츠_삭제(id: let id): + case .컨텐츠_삭제_API(id: let id): return .run { [count = state.domain.contentCount] send in let newCount = count - 1 - await send(.inner(.컨텐츠_개수_갱신(newCount)), animation: .pokitSpring) + await send(.inner(.컨텐츠_개수_업데이트(newCount)), animation: .pokitSpring) let _ = try await contentClient.컨텐츠_삭제("\(id)") - await send(.inner(.컨텐츠_삭제_반영(id: id)), animation: .pokitSpring) + await send(.inner(.컨텐츠_삭제_API_반영(id: id)), animation: .pokitSpring) } - case .pagenation_네트워크: + case .컨텐츠_목록_조회_페이징_API: state.domain.pageable.page += 1 - return .run { [type = state.contentType] send in + return .run { [ + type = state.contentType, + pageable = state.domain.pageable + ] send in + var contentList: BaseContentListInquiry switch type { case .unread: - await send(.async(.읽지않음_컨텐츠_조회)) - break + contentList = try await remindClient.읽지않음_컨텐츠_조회( + BasePageableRequest( + page: pageable.page, + size: pageable.size, + sort: pageable.sort + ) + ).toDomain() case .favorite: - await send(.async(.즐겨찾기_링크모음_조회)) - break + contentList = try await remindClient.즐겨찾기_링크모음_조회( + BasePageableRequest( + page: pageable.page, + size: pageable.size, + sort: pageable.sort + ) + ).toDomain() } + + await send(.inner(.컨텐츠_목록_조회_페이징_API_반영(contentList))) } - case .페이징_재조회: + case .컨텐츠_목록_조회_API: return .run { [ pageable = state.domain.pageable, contentType = state.contentType ] send in - await send(.async(.컨텐츠_개수_조회)) let stream = AsyncThrowingStream { continuation in Task { for page in 0...pageable.page { @@ -332,17 +305,17 @@ private extension ContentListFeature { contentItems?.data = items + newItems } guard let contentItems else { return } - await send(.inner(.컨텐츠_목록_갱신(contentItems)), animation: .pokitSpring) + await send(.inner(.컨텐츠_목록_조회_API_반영(contentItems))) } - case .컨텐츠_개수_조회: + case .컨텐츠_개수_조회_API: return .run { [ contentType = state.contentType ] send in switch contentType { case .favorite: let count = try await remindClient.즐겨찾기_컨텐츠_개수_조회().count - await send(.inner(.컨텐츠_개수_갱신(count)), animation: .pokitSpring) + await send(.inner(.컨텐츠_개수_업데이트(count)), animation: .pokitSpring) case .unread: let count = try await remindClient.읽지않음_컨텐츠_개수_조회().count - await send(.inner(.컨텐츠_개수_갱신(count)), animation: .pokitSpring) + await send(.inner(.컨텐츠_개수_업데이트(count)), animation: .pokitSpring) } } } @@ -372,7 +345,7 @@ private extension ContentListFeature { func handleDelegateAction(_ action: Action.DelegateAction, state: inout State) -> Effect { switch action { case .컨텐츠_목록_조회: - return .send(.async(.페이징_재조회)) + return .send(.async(.컨텐츠_목록_조회_API)) default: return .none } diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift index 1fb27e51..f8ec982b 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift @@ -38,7 +38,7 @@ public extension ContentListView { items: [.share, .edit, .delete], height: 224, delegateSend: { - send(.bottomSheetButtonTapped(delegate: $0, content: content)) + send(.bottomSheet(delegate: $0, content: content)) } ) } @@ -46,7 +46,7 @@ public extension ContentListView { if let shareURL = URL(string: content.data) { PokitShareSheet( items: [shareURL], - completion: { send(.링크_공유_완료) } + completion: { send(.링크_공유시트_해제) } ) .presentationDetents([.medium, .large]) } @@ -56,9 +56,9 @@ public extension ContentListView { "링크를 정말 삭제하시겠습니까?", message: "함께 저장한 모든 정보가 삭제되며, \n복구하실 수 없습니다.", confirmText: "삭제" - ) { send(.deleteAlertConfirmTapped(content: content)) } + ) { send(.컨텐츠_삭제_눌렀을때(content: content)) } } - .task { await send(.contentListViewOnAppeared, animation: .pokitDissolve).finish() } + .task { await send(.뷰가_나타났을때, animation: .pokitDissolve).finish() } } } } @@ -76,7 +76,7 @@ private extension ContentListView { PokitIconLTextLink( store.isListDescending ? "최신순" : "오래된순", icon: .icon(.align), - action: { send(.sortTextLinkTapped) } + action: { send(.정렬_버튼_눌렀을때) } ) .contentTransition(.numericText()) } @@ -103,8 +103,8 @@ private extension ContentListView { PokitLinkCard( link: content, - action: { send(.linkCardTapped(content: content)) }, - kebabAction: { send(.kebabButtonTapped(content: content)) } + action: { send(.컨텐츠_항목_눌렀을때(content: content)) }, + kebabAction: { send(.컨텐츠_항목_케밥_버튼_눌렀을때(content: content)) } ) .divider(isFirst: isFirst, isLast: isLast) } @@ -128,7 +128,7 @@ private extension ContentListView { PokitHeader(title: store.contentType.title) { PokitHeaderItems(placement: .leading) { PokitToolbarButton(.icon(.arrowLeft)) { - send(.backButtonTapped) + send(.뒤로가기_버튼_눌렀을때) } } } From 8342b992134b33d1bb54c32762c7e8faa3a9221c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=95?= <108233361+ShapeKim98@users.noreply.github.com> Date: Sun, 6 Oct 2024 18:55:23 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[refactor]=20#129=20action=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=ED=95=B8=EB=93=A4=EB=A7=81=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContentList/ContentListFeature.swift | 133 +++++++++--------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift index 3cea4c0a..fca442dd 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift @@ -160,15 +160,13 @@ private extension ContentListFeature { case .컨텐츠_항목_눌렀을때(let content): return .send(.delegate(.링크상세(content: content))) case .bottomSheet(let delegate, let content): - return .run { send in - await send(.inner(.바텀시트_해제)) - await send(.scope(.bottomSheet(delegate: delegate, content: content))) - } + return .concatenate( + .send(.inner(.바텀시트_해제)), + .send(.scope(.bottomSheet(delegate: delegate, content: content))) + ) case .컨텐츠_삭제_눌렀을때: guard let id = state.alertItem?.id else { return .none } - return .run { [id] send in - await send(.async(.컨텐츠_삭제_API(id: id))) - } + return .send(.async(.컨텐츠_삭제_API(id: id))) case .binding: return .none case .정렬_버튼_눌렀을때: @@ -180,7 +178,7 @@ private extension ContentListFeature { case .뒤로가기_버튼_눌렀을때: return .run { _ in await dismiss() } case .뷰가_나타났을때: - return .merge([ + return .merge( .send(.async(.컨텐츠_개수_조회_API)), .send(.async(.컨텐츠_목록_조회_API)), .run { send in @@ -189,8 +187,7 @@ private extension ContentListFeature { await send(.delegate(.linkCopyDetected(url)), animation: .pokitSpring) } } - ]) - + ) case .pagenation: return .send(.async(.컨텐츠_목록_조회_페이징_API)) case .링크_공유시트_해제: @@ -233,80 +230,43 @@ private extension ContentListFeature { func handleAsyncAction(_ action: Action.AsyncAction, state: inout State) -> Effect { switch action { case .컨텐츠_삭제_API(id: let id): - return .run { [count = state.domain.contentCount] send in - let newCount = count - 1 - await send(.inner(.컨텐츠_개수_업데이트(newCount)), animation: .pokitSpring) - let _ = try await contentClient.컨텐츠_삭제("\(id)") - await send(.inner(.컨텐츠_삭제_API_반영(id: id)), animation: .pokitSpring) - } + let count = state.domain.contentCount + let newCount = count - 1 + + return .merge( + .send(.inner(.컨텐츠_개수_업데이트(newCount))), + .run { send in + let _ = try await contentClient.컨텐츠_삭제("\(id)") + await send(.inner(.컨텐츠_삭제_API_반영(id: id)), animation: .pokitSpring) + } + ) case .컨텐츠_목록_조회_페이징_API: state.domain.pageable.page += 1 return .run { [ type = state.contentType, - pageable = state.domain.pageable + pageableRequest = BasePageableRequest( + page: state.domain.pageable.page, + size: state.domain.pageable.size, + sort: state.domain.pageable.sort + ) ] send in - var contentList: BaseContentListInquiry + let contentList: BaseContentListInquiry switch type { case .unread: contentList = try await remindClient.읽지않음_컨텐츠_조회( - BasePageableRequest( - page: pageable.page, - size: pageable.size, - sort: pageable.sort - ) + pageableRequest ).toDomain() case .favorite: contentList = try await remindClient.즐겨찾기_링크모음_조회( - BasePageableRequest( - page: pageable.page, - size: pageable.size, - sort: pageable.sort - ) + pageableRequest ).toDomain() } await send(.inner(.컨텐츠_목록_조회_페이징_API_반영(contentList))) } case .컨텐츠_목록_조회_API: - return .run { [ - pageable = state.domain.pageable, - contentType = state.contentType - ] send in - let stream = AsyncThrowingStream { continuation in - Task { - for page in 0...pageable.page { - let paeagableRequest = BasePageableRequest( - page: page, - size: pageable.size, - sort: pageable.sort - ) - switch contentType { - case .favorite: - let contentList = try await remindClient.즐겨찾기_링크모음_조회( - paeagableRequest - ).toDomain() - continuation.yield(contentList) - case .unread: - let contentList = try await remindClient.읽지않음_컨텐츠_조회( - paeagableRequest - ).toDomain() - continuation.yield(contentList) - } - } - continuation.finish() - } - } - var contentItems: BaseContentListInquiry? = nil - for try await contentList in stream { - let items = contentItems?.data ?? [] - let newItems = contentList.data ?? [] - contentItems = contentList - contentItems?.data = items + newItems - } - guard let contentItems else { return } - await send(.inner(.컨텐츠_목록_조회_API_반영(contentItems))) - } + return contentListFetch(state: &state) case .컨텐츠_개수_조회_API: return .run { [ contentType = state.contentType ] send in switch contentType { @@ -350,6 +310,47 @@ private extension ContentListFeature { return .none } } + + func contentListFetch(state: inout State) -> Effect { + return .run { [ + pageable = state.domain.pageable, + contentType = state.contentType + ] send in + let stream = AsyncThrowingStream { continuation in + Task { + for page in 0...pageable.page { + let paeagableRequest = BasePageableRequest( + page: page, + size: pageable.size, + sort: pageable.sort + ) + switch contentType { + case .favorite: + let contentList = try await remindClient.즐겨찾기_링크모음_조회( + paeagableRequest + ).toDomain() + continuation.yield(contentList) + case .unread: + let contentList = try await remindClient.읽지않음_컨텐츠_조회( + paeagableRequest + ).toDomain() + continuation.yield(contentList) + } + } + continuation.finish() + } + } + var contentItems: BaseContentListInquiry? = nil + for try await contentList in stream { + let items = contentItems?.data ?? [] + let newItems = contentList.data ?? [] + contentItems = contentList + contentItems?.data = items + newItems + } + guard let contentItems else { return } + await send(.inner(.컨텐츠_목록_조회_API_반영(contentItems))) + } + } } public extension ContentListFeature { From 19809c8ea34500a628b4f02f85b9467e3fae49b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=95?= <108233361+ShapeKim98@users.noreply.github.com> Date: Sun, 6 Oct 2024 18:59:29 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[fix]=20#129=20=EA=B2=BD=EA=B3=A0=EC=8B=9C?= =?UTF-8?q?=ED=8A=B8=20=EC=95=88=EB=8B=AB=ED=9E=88=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ContentList/ContentListFeature.swift | 4 ++++ .../Sources/ContentList/ContentListView.swift | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift index fca442dd..833a865f 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift @@ -82,6 +82,7 @@ public struct ContentListFeature { case 뷰가_나타났을때 case 링크_공유시트_해제 + case 경고시트_해제 } public enum InnerAction: Equatable { @@ -193,6 +194,9 @@ private extension ContentListFeature { case .링크_공유시트_해제: state.shareSheetItem = nil return .none + case .경고시트_해제: + state.alertItem = nil + return .none } } diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift index f8ec982b..1e3089e6 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift @@ -55,8 +55,10 @@ public extension ContentListView { PokitAlert( "링크를 정말 삭제하시겠습니까?", message: "함께 저장한 모든 정보가 삭제되며, \n복구하실 수 없습니다.", - confirmText: "삭제" - ) { send(.컨텐츠_삭제_눌렀을때(content: content)) } + confirmText: "삭제", + action: { send(.컨텐츠_삭제_눌렀을때(content: content)) }, + cancelAction: { send(.경고시트_해제) } + ) } .task { await send(.뷰가_나타났을때, animation: .pokitDissolve).finish() } } From 0dfe4f3146895cd99bb7a017111e0ca60a07520e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=95?= <108233361+ShapeKim98@users.noreply.github.com> Date: Sun, 6 Oct 2024 20:18:08 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[refactor]=20#129=20ContentListFeature=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ContentList/ContentListFeature.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift index 833a865f..2a3e58b3 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift @@ -273,14 +273,15 @@ private extension ContentListFeature { return contentListFetch(state: &state) case .컨텐츠_개수_조회_API: return .run { [ contentType = state.contentType ] send in + let count: Int switch contentType { case .favorite: - let count = try await remindClient.즐겨찾기_컨텐츠_개수_조회().count - await send(.inner(.컨텐츠_개수_업데이트(count)), animation: .pokitSpring) + count = try await remindClient.즐겨찾기_컨텐츠_개수_조회().count case .unread: - let count = try await remindClient.읽지않음_컨텐츠_개수_조회().count - await send(.inner(.컨텐츠_개수_업데이트(count)), animation: .pokitSpring) + count = try await remindClient.읽지않음_컨텐츠_개수_조회().count } + + await send(.inner(.컨텐츠_개수_업데이트(count)), animation: .pokitSpring) } } } From b8eaaece10b0786d1819caab2dabe448cb1be53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=95?= <108233361+ShapeKim98@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:55:36 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[refactor]=20#129=20=ED=94=BC=EB=93=9C?= =?UTF-8?q?=EB=B0=B1=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContentList/ContentListFeature.swift | 31 ++++++++++++------- .../Sources/ContentList/ContentListView.swift | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift index 2a3e58b3..b5797db0 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListFeature.swift @@ -77,7 +77,7 @@ public struct ContentListFeature { case 컨텐츠_항목_케밥_버튼_눌렀을때(content: BaseContentItem) case 컨텐츠_삭제_눌렀을때(content: BaseContentItem) case 정렬_버튼_눌렀을때 - case 뒤로가기_버튼_눌렀을때 + case dismiss /// - On Appeared case 뷰가_나타났을때 @@ -99,6 +99,7 @@ public struct ContentListFeature { case 컨텐츠_목록_조회_페이징_API case 컨텐츠_목록_조회_API case 컨텐츠_개수_조회_API + case 클립보드_감지 } public enum ScopeAction: Equatable { @@ -176,18 +177,13 @@ private extension ContentListFeature { state.isListDescending ? "createdAt,desc" : "createdAt,asc" ] return .send(.inner(.페이징_초기화), animation: .pokitDissolve) - case .뒤로가기_버튼_눌렀을때: + case .dismiss: return .run { _ in await dismiss() } case .뷰가_나타났을때: return .merge( .send(.async(.컨텐츠_개수_조회_API)), .send(.async(.컨텐츠_목록_조회_API)), - .run { send in - for await _ in self.pasteBoard.changes() { - let url = try await pasteBoard.probableWebURL() - await send(.delegate(.linkCopyDetected(url)), animation: .pokitSpring) - } - } + .send(.async(.클립보드_감지)) ) case .pagenation: return .send(.async(.컨텐츠_목록_조회_페이징_API)) @@ -239,10 +235,7 @@ private extension ContentListFeature { return .merge( .send(.inner(.컨텐츠_개수_업데이트(newCount))), - .run { send in - let _ = try await contentClient.컨텐츠_삭제("\(id)") - await send(.inner(.컨텐츠_삭제_API_반영(id: id)), animation: .pokitSpring) - } + contentDelete(contentId: id) ) case .컨텐츠_목록_조회_페이징_API: @@ -283,6 +276,13 @@ private extension ContentListFeature { await send(.inner(.컨텐츠_개수_업데이트(count)), animation: .pokitSpring) } + case .클립보드_감지: + return .run { send in + for await _ in self.pasteBoard.changes() { + let url = try await pasteBoard.probableWebURL() + await send(.delegate(.linkCopyDetected(url)), animation: .pokitSpring) + } + } } } @@ -356,6 +356,13 @@ private extension ContentListFeature { await send(.inner(.컨텐츠_목록_조회_API_반영(contentItems))) } } + + func contentDelete(contentId: Int) -> Effect { + return .run { send in + let _ = try await contentClient.컨텐츠_삭제("\(contentId)") + await send(.inner(.컨텐츠_삭제_API_반영(id: contentId)), animation: .pokitSpring) + } + } } public extension ContentListFeature { diff --git a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift index 1e3089e6..53b6de19 100644 --- a/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift +++ b/Projects/Feature/FeatureContentList/Sources/ContentList/ContentListView.swift @@ -130,7 +130,7 @@ private extension ContentListView { PokitHeader(title: store.contentType.title) { PokitHeaderItems(placement: .leading) { PokitToolbarButton(.icon(.arrowLeft)) { - send(.뒤로가기_버튼_눌렀을때) + send(.dismiss) } } }