Skip to content

Commit

Permalink
[refactor] #173 링크 편집 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
stealmh committed Dec 30, 2024
1 parent b580782 commit 3282dc4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public struct PokitLinkEditFeature {
}

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

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

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

case .뷰가_나타났을때:
return fetchCateogryList()
Expand Down Expand Up @@ -223,7 +224,7 @@ private extension PokitLinkEditFeature {
state.selectedItems.removeAll()

if state.list.isEmpty {
return .send(.delegate(.링크_편집_종료))
return .send(.delegate(.링크_편집_종료(items: [])))
}
return .none
}
Expand Down
24 changes: 19 additions & 5 deletions Projects/Feature/FeaturePokit/Sources/PokitRootFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//
// Created by 김민호 on 7/16/24.

import Foundation

import ComposableArchitecture
import FeatureContentCard
import Domain
Expand Down Expand Up @@ -518,14 +520,26 @@ private extension PokitRootFeature {
case .contents:
return .none

case .linkEdit(.presented(.delegate(.링크_편집_종료))):
state.contents.removeAll()
case let .linkEdit(.presented(.delegate(.링크_편집_종료(list)))):
/// 링크가 비어있을때는 전부 삭제
if list.isEmpty {
state.contents.removeAll()
} else {
/// 링크가 일부 있을 때 -> 그 일부를 붙여넣기
var linkIds = IdentifiedArrayOf<ContentCardFeature.State>()
list.forEach { item in
state.contents.forEach { content in
if item.id == content.content.id {
linkIds.append(content)
}
}
}
state.contents.removeAll()
state.contents = linkIds
}
state.linkEdit = nil
return .none

case .linkEdit(.dismiss):
return .send(.view(.뷰가_나타났을때))

case .linkEdit:
return .none

Expand Down

0 comments on commit 3282dc4

Please sign in to comment.