Skip to content

Commit

Permalink
[feat] #177 포킷 이동 성공시 팝업 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
stealmh committed Jan 12, 2025
1 parent 2771d5b commit ad5a996
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ public extension MainTabFeature {
let .path(.element(_, action: .포킷추가및수정(.delegate(.linkCopyDetected(url))))),
let .path(.element(_, action: .링크목록(.delegate(.linkCopyDetected(url))))):
return .run { send in await send(.inner(.linkCopySuccess(url)), animation: .pokitSpring) }
/// 바텀메세지
case let .pokit(.delegate(.linkPopup(text))):
state.linkPopup = .text(title: text)
return .none
/// 링크목록 `안읽음`
case .remind(.delegate(.링크목록_안읽음)):
state.path.append(.링크목록(ContentListFeature.State(contentType: .unread)))
Expand Down
28 changes: 17 additions & 11 deletions Projects/Feature/FeaturePokit/Sources/PokitLinkEditFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public struct PokitLinkEditFeature {
}

public enum DelegateAction: Equatable {
case 링크_편집_종료(items: [BaseContentItem])
case 링크_편집_종료(items: [BaseContentItem], type: LinkEditType)
}
}

Expand Down Expand Up @@ -135,8 +135,7 @@ private extension PokitLinkEditFeature {
return .none

case .dismiss:
return .send(.delegate(.링크_편집_종료(items: state.list.elements)))
// return .run { _ in await dismiss() }
return .send(.delegate(.링크_편집_종료(items: state.list.elements, type: .dismiss)))

case .뷰가_나타났을때:
return fetchCateogryList()
Expand Down Expand Up @@ -170,7 +169,7 @@ private extension PokitLinkEditFeature {
.send(.inner(.경고팝업_활성화(.error(title: "링크를 선택해주세요."))))
)
} else {
return moveContentList(categoryId: pokit.id, state: &state)
return moveContentList(category: pokit, state: &state)
}

case .링크팝업_버튼_눌렀을때:
Expand Down Expand Up @@ -212,7 +211,7 @@ private extension PokitLinkEditFeature {

case let .미분류_API_반영(type):
/// 1. 시트 내리기
if type == .링크이동 {
if case .링크이동 = type {
state.categorySelectSheetPresetend = false
} else {
state.linkDeleteSheetPresented = false
Expand All @@ -222,10 +221,16 @@ private extension PokitLinkEditFeature {
.map { $0.id }
.forEach { state.list.remove(id: $0) }
state.selectedItems.removeAll()

/// 3. 분류가 남은 링크가 없을 때 편집하기 종료
if state.list.isEmpty {
return .send(.delegate(.링크_편집_종료(items: [])))
return .send(.delegate(.링크_편집_종료(items: [], type: type)))
}
/// 4. 링크이동을 했을 때 바텀 메세지 출력
if case let .링크이동(categoryName) = type {
state.linkPopup = .text(title: "\(categoryName)\n카테고리로 이동되었습니다.")
return .none
}

return .none
}
}
Expand Down Expand Up @@ -286,12 +291,12 @@ private extension PokitLinkEditFeature {
}

/// 미분류 링크 카테고리 이동 API
func moveContentList(categoryId: Int, state: inout State) -> Effect<Action> {
func moveContentList(category: BaseCategoryItem, state: inout State) -> Effect<Action> {
return .run { [contentIds = state.selectedItems] send in
let contentIds = contentIds.map { $0.id }
let request = ContentMoveRequest(contentIds: contentIds, categoryId: categoryId)
let request = ContentMoveRequest(contentIds: contentIds, categoryId: category.id)
try await contentClient.미분류_링크_포킷_이동(request)
await send(.inner(.미분류_API_반영(.링크이동)))
await send(.inner(.미분류_API_반영(.링크이동(categoryName: category.categoryName))))
} catch: { error, send in
await send(.inner(.error(error)))
}
Expand All @@ -309,7 +314,8 @@ private extension PokitLinkEditFeature {
}
public extension PokitLinkEditFeature {
enum LinkEditType: Equatable {
case 링크이동
case dismiss
case 링크이동(categoryName: String)
case 링크삭제
}
}
8 changes: 7 additions & 1 deletion Projects/Feature/FeaturePokit/Sources/PokitRootFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public struct PokitRootFeature {
case settingButtonTapped

case categoryTapped(BaseCategoryItem)
case linkPopup(text: String)
case 수정하기(BaseCategoryItem)
case 링크수정하기(id: Int)
/// 링크상세로 이동
Expand Down Expand Up @@ -544,7 +545,7 @@ private extension PokitRootFeature {
case .contents:
return .none

case let .linkEdit(.presented(.delegate(.링크_편집_종료(list)))):
case let .linkEdit(.presented(.delegate(.링크_편집_종료(list, type)))):
/// 링크가 비어있을때는 전부 삭제
if list.isEmpty {
state.contents.removeAll()
Expand All @@ -562,6 +563,11 @@ private extension PokitRootFeature {
state.contents = linkIds
}
state.linkEdit = nil

if case let .링크이동(categoryName) = type {
let text = "\(categoryName)\n카테고리로 이동되었습니다."
return .send(.delegate(.linkPopup(text: text)))
}
return .none

case .linkEdit:
Expand Down

0 comments on commit ad5a996

Please sign in to comment.