Skip to content

Commit

Permalink
[fix] #154 포킷 추가 시 포킷상세 업데이트
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Nov 6, 2024
1 parent 6a01b00 commit cc7b3af
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
14 changes: 12 additions & 2 deletions Projects/App/Sources/MainTabSplit/Pokit/PokitSplitFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,22 @@ private extension PokitSplitFeature {
.send(.포킷(.delegate(.미분류_카테고리_컨텐츠_조회))),
.send(.카테고리상세(.delegate(.카테고리_내_컨텐츠_목록_조회)))
)
case .링크추가(.delegate(.포킷추가하기)):
state.포킷추가및수정 = .init(type: .추가)
return .none
case .링크추가:
return .none

// - MARK: 포킷추가및수정
case .포킷추가및수정(.presented(.delegate(.settingSuccess))):
return .send(.포킷(.delegate(.미분류_카테고리_컨텐츠_조회)))
case let .포킷추가및수정(.presented(.delegate(.settingSuccess(category)))):
var mergeEffect: [Effect<Action>] = [
.send(.포킷(.delegate(.미분류_카테고리_컨텐츠_조회))),
.send(.포킷추가및수정(.dismiss))
]
if let category {
mergeEffect.append(.send(.inner(.카테고리_상세_활성화(category))))
}
return .merge(mergeEffect)
case .포킷추가및수정:
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public struct PokitCategorySettingFeature {

public enum DelegateAction: Equatable {
/// 이전화면으로 돌아가 카테고리 항목을 추가하면됨
case settingSuccess
case settingSuccess(BaseCategoryItem?)
case linkCopyDetected(URL?)
}
}
Expand Down Expand Up @@ -182,14 +182,25 @@ private extension PokitCategorySettingFeature {
createdAt: ""
)
await send(.inner(.카테고리_인메모리_저장(responseToCategoryDomain)))
await send(.delegate(.settingSuccess))
await send(.delegate(.settingSuccess(responseToCategoryDomain)))

case .수정:
guard let categoryId = domain.categoryId else { return }
guard let image = domain.categoryImage else { return }
let request = CategoryEditRequest(categoryName: domain.categoryName, categoryImageId: image.id)
let _ = try await categoryClient.카테고리_수정(categoryId, request)
await send(.delegate(.settingSuccess))
let response = try await categoryClient.카테고리_수정(categoryId, request)
let category = BaseCategoryItem(
id: response.categoryId,
userId: 0,
categoryName: response.categoryName,
categoryImage: BaseCategoryImage(
imageId: response.categoryImage.imageId,
imageURL: response.categoryImage.imageUrl
),
contentCount: 0,
createdAt: ""
)
await send(.delegate(.settingSuccess(category)))

case .공유추가:
guard let categoryId = domain.categoryId else { return }
Expand All @@ -201,7 +212,7 @@ private extension PokitCategorySettingFeature {
categoryImageId: image.id
)
)
await send(.delegate(.settingSuccess))
await send(.delegate(.settingSuccess(nil)))
}
} catch: { error, send in
guard let errorResponse = error as? ErrorResponse else { return }
Expand Down

0 comments on commit cc7b3af

Please sign in to comment.