Skip to content

Commit

Permalink
[feat] #157 카테고리 상세에서 링크 상세 플로우 변경사항 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Nov 30, 2024
1 parent 9f85b99 commit 030a627
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public struct CategoryDetailFeature {
return identifiedArray
}
var contents: IdentifiedArrayOf<ContentCardFeature.State> = []
var kebobSelectedType: PokitDeleteBottomSheet.SheetType?
var selectedContentItem: BaseContentItem?
var shareSheetItem: BaseContentItem? = nil
/// sheet Presented
var isCategorySheetPresented: Bool = false
Expand Down Expand Up @@ -86,7 +84,7 @@ public struct CategoryDetailFeature {
case binding(BindingAction<State>)
case dismiss
case pagenation
case 카테고리_케밥_버튼_눌렀을때(PokitDeleteBottomSheet.SheetType, selectedItem: BaseContentItem?)
case 카테고리_케밥_버튼_눌렀을때
case 카테고리_선택_버튼_눌렀을때
case 카테고리_선택했을때(BaseCategoryItem)
case 필터_버튼_눌렀을때
Expand All @@ -110,7 +108,6 @@ public struct CategoryDetailFeature {
public enum AsyncAction: Equatable {
case 카테고리_내_컨텐츠_목록_조회_API
case 카테고리_목록_조회_API
case 컨텐츠_삭제_API(id: Int)
case 페이징_재조회
case 클립보드_감지
}
Expand Down Expand Up @@ -181,9 +178,7 @@ private extension CategoryDetailFeature {
case .binding:
return .none

case let .카테고리_케밥_버튼_눌렀을때(selectedType, selectedItem):
state.kebobSelectedType = selectedType
state.selectedContentItem = selectedItem
case .카테고리_케밥_버튼_눌렀을때:
return .run { send in await send(.inner(.카테고리_시트_활성화(true))) }

case .카테고리_선택_버튼_눌렀을때:
Expand Down Expand Up @@ -261,9 +256,7 @@ private extension CategoryDetailFeature {
state.domain.contentList.data?.removeAll { $0.id == id }
state.contents.removeAll { $0.content.id == id }
state.domain.category.contentCount -= 1
state.selectedContentItem = nil
state.isPokitDeleteSheetPresented = false
state.kebobSelectedType = nil
return .none
case .pagenation_API_반영(let contentList):
let list = state.domain.contentList.data ?? []
Expand Down Expand Up @@ -313,12 +306,6 @@ private extension CategoryDetailFeature {
: await send(.inner(.pagenation_API_반영(contentList)))
}

case let .컨텐츠_삭제_API(contentId):
return .run { send in
let _ = try await contentClient.컨텐츠_삭제("\(contentId)")
await send(.inner(.컨텐츠_삭제_API_반영(id: contentId)), animation: .pokitSpring)
}

case .페이징_재조회:
return .run { [
pageable = state.domain.pageable,
Expand Down Expand Up @@ -376,41 +363,20 @@ private extension CategoryDetailFeature {
case .categoryBottomSheet(let delegateAction):
switch delegateAction {
case .shareCellButtonTapped:
switch state.kebobSelectedType {
case .링크삭제:
state.shareSheetItem = state.selectedContentItem
case .포킷삭제:
kakaoShareClient.카테고리_카카오톡_공유(
CategoryKaKaoShareModel(
categoryName: state.domain.category.categoryName,
categoryId: state.domain.category.id,
imageURL: state.domain.category.categoryImage.imageURL
)
kakaoShareClient.카테고리_카카오톡_공유(
CategoryKaKaoShareModel(
categoryName: state.domain.category.categoryName,
categoryId: state.domain.category.id,
imageURL: state.domain.category.categoryImage.imageURL
)
default: return .none
}

)
state.isCategorySheetPresented = false
return .none

case .editCellButtonTapped:
return .run { [
content = state.selectedContentItem,
type = state.kebobSelectedType,
category = state.category
] send in
guard let type else { return }
switch type {
case .링크삭제:
guard let content else { return }
await send(.inner(.카테고리_시트_활성화(false)))
await send(.delegate(.링크수정(contentId: content.id)))
case .포킷삭제:
await send(.inner(.카테고리_시트_활성화(false)))
await send(.delegate(.포킷수정(category)))
}
return .run { [category = state.category] send in
await send(.inner(.카테고리_시트_활성화(false)))
await send(.delegate(.포킷수정(category)))
}

case .deleteCellButtonTapped:
return .run { send in
await send(.inner(.카테고리_시트_활성화(false)))
Expand All @@ -426,27 +392,11 @@ private extension CategoryDetailFeature {
return .run { send in await send(.inner(.카테고리_삭제_시트_활성화(false))) }

case .deleteButtonTapped:
guard let selectedType = state.kebobSelectedType else {
/// 🚨 Error Case [1]: 해당 타입의 항목을 삭제하려는데 선택한 `타입`이 없을 때
state.isPokitDeleteSheetPresented = false
return .none
}
switch selectedType {
case .링크삭제:
guard let selectedItem = state.selectedContentItem else {
/// 🚨 Error Case [1]: 링크 타입의 항목을 삭제하려는데 선택한 `링크항목`이 없을 때
state.isPokitDeleteSheetPresented = false
return .none
}
return .send(.async(.컨텐츠_삭제_API(id: selectedItem.id)))
case .포킷삭제:
state.isPokitDeleteSheetPresented = false
state.kebobSelectedType = nil
return .run { [categoryId = state.domain.category.id] send in
await send(.inner(.카테고리_삭제_시트_활성화(false)))
await send(.delegate(.포킷삭제))
try await categoryClient.카테고리_삭제(categoryId)
}
state.isPokitDeleteSheetPresented = false
return .run { [categoryId = state.domain.category.id] send in
await send(.inner(.카테고리_삭제_시트_활성화(false)))
await send(.delegate(.포킷삭제))
try await categoryClient.카테고리_삭제(categoryId)
}
}
/// - 필터 버튼을 눌렀을 때
Expand All @@ -472,9 +422,7 @@ private extension CategoryDetailFeature {
case let .contents(.element(id: _, action: .delegate(.컨텐츠_항목_눌렀을때(content)))):
return .send(.delegate(.contentItemTapped(content)))
case let .contents(.element(id: _, action: .delegate(.컨텐츠_항목_케밥_버튼_눌렀을때(content)))):
state.kebobSelectedType = .링크삭제
state.selectedContentItem = content
return .send(.inner(.카테고리_시트_활성화(true)))
return .send(.delegate(.contentItemTapped(content)))
case .contents:
return .none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public extension CategoryDetailView {
}
.sheet(isPresented: $store.isPokitDeleteSheetPresented) {
PokitDeleteBottomSheet(
type: store.kebobSelectedType ?? .포킷삭제,
type: .포킷삭제,
delegateSend: { store.send(.scope(.categoryDeleteBottomSheet($0))) }
)
}
Expand Down Expand Up @@ -95,7 +95,7 @@ private extension CategoryDetailView {
PokitHeaderItems(placement: .trailing) {
PokitToolbarButton(
.icon(.kebab),
action: { send(.카테고리_케밥_버튼_눌렀을때(.포킷삭제, selectedItem: nil)) }
action: { send(.카테고리_케밥_버튼_눌렀을때) }
)
}
}
Expand Down

0 comments on commit 030a627

Please sign in to comment.