Skip to content

Commit

Permalink
[feat] #167 링크 저장 팝업 클릭 시 포킷상세(미분류) 이동 로직으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Dec 9, 2024
1 parent 2cdb372 commit 413a6be
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
20 changes: 14 additions & 6 deletions Projects/App/Sources/MainTab/MainTabFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct MainTabFeature {
@Presents var contentDetail: ContentDetailFeature.State?
@Shared(.inMemory("SelectCategory")) var categoryId: Int?
@Shared(.inMemory("PushTapped")) var isPushTapped: Bool = false
var savedContentId: Int?
var categoryOfSavedContent: BaseCategoryItem?

public init() {
self.pokit = .init()
Expand Down Expand Up @@ -78,6 +78,7 @@ public struct MainTabFeature {
case 경고_띄움(BaseError)
case errorSheetPresented(Bool)
case 링크팝업_활성화(PokitLinkPopup.PopupType)
case 카테고리상세_이동(category: BaseCategoryItem)
}
public enum AsyncAction: Equatable {
case 공유받은_카테고리_조회(categoryId: Int)
Expand All @@ -98,7 +99,7 @@ public struct MainTabFeature {
switch action {
case .binding(\.linkPopup):
guard state.linkPopup == nil else { return .none }
state.savedContentId = nil
state.categoryOfSavedContent = nil
return .none
case .binding:
return .none
Expand Down Expand Up @@ -222,7 +223,14 @@ private extension MainTabFeature {
case let .링크팝업_활성화(type):
state.linkPopup = type
return .none

case let .카테고리상세_이동(category):
if category.categoryName == "미분류" {
state.selectedTab = .pokit
state.path.removeAll()
return .send(.pokit(.delegate(.미분류_카테고리_활성화)))
}
state.path.append(.카테고리상세(.init(category: category)))
return .none
default: return .none
}
}
Expand Down Expand Up @@ -259,9 +267,9 @@ private extension MainTabFeature {
return .send(.delegate(.링크추가하기))
case .success:
state.linkPopup = nil
state.contentDetail = .init(contentId: state.savedContentId)
state.savedContentId = nil
return .none
guard let category = state.categoryOfSavedContent else { return .none }
state.categoryOfSavedContent = nil
return .send(.inner(.카테고리상세_이동(category: category)))
case .error, .text, .warning, .none:
return .none
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public extension MainTabFeature {

/// - 링크추가 및 수정에서 저장하기 눌렀을 때
case let .path(.element(stackElementId, action: .링크추가및수정(.delegate(.저장하기_완료(contentId))))):
state.savedContentId = contentId
state.categoryOfSavedContent = contentId
state.path.removeLast()
switch state.path.last {
case .검색:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public struct ContentSettingFeature {
public enum ScopeAction: Equatable { case 없음 }

public enum DelegateAction: Equatable {
case 저장하기_완료(contentId: Int)
case 저장하기_완료(category: BaseCategoryItem)
case 포킷추가하기
case dismiss
}
Expand Down Expand Up @@ -373,10 +373,13 @@ private extension ContentSettingFeature {
categoryListFetch(request: request)
)
case .컨텐츠_수정_API:
guard let contentId = state.domain.contentId,
let categoryId = state.selectedPokit?.id else {
return .none
}
guard
let contentId = state.domain.contentId,
let categoryId = state.selectedPokit?.id,
let category = state.domain.categoryListInQuiry.data?.first(where: {
$0.id == categoryId
})
else { return .none }
let request = ContentBaseRequest(
data: state.domain.data,
title: state.domain.title,
Expand All @@ -391,14 +394,17 @@ private extension ContentSettingFeature {
request
)
await send(.inner(.선택한_포킷_인메모리_삭제))
await send(.delegate(.저장하기_완료(contentId: contentId)))
await send(.delegate(.저장하기_완료(category: category)))
} catch: { error, send in
await send(.inner(.error(error)))
}
case .컨텐츠_추가_API:
guard let categoryId = state.selectedPokit?.id else {
return .none
}
guard
let categoryId = state.selectedPokit?.id,
let category = state.domain.categoryListInQuiry.data?.first(where: {
$0.id == categoryId
})
else { return .none }
let request = ContentBaseRequest(
data: state.domain.data,
title: state.domain.title,
Expand All @@ -410,7 +416,7 @@ private extension ContentSettingFeature {
return .run { send in
let content = try await contentClient.컨텐츠_추가(request)
await send(.inner(.선택한_포킷_인메모리_삭제))
await send(.delegate(.저장하기_완료(contentId: content.contentId)))
await send(.delegate(.저장하기_완료(category: category)))
} catch: { error, send in
await send(.inner(.error(error)))
}
Expand Down
6 changes: 6 additions & 0 deletions Projects/Feature/FeaturePokit/Sources/PokitRootFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public struct PokitRootFeature {

case 포킷추가_버튼_눌렀을때
case 링크추가_버튼_눌렀을때

case 미분류_카테고리_활성화
}
}

Expand Down Expand Up @@ -513,6 +515,10 @@ private extension PokitRootFeature {

default: return .none
}
case .미분류_카테고리_활성화:
state.folderType = .folder(.미분류)
state.sortType = .sort(.최신순)
return .send(.inner(.sort))
default:
return .none
}
Expand Down

0 comments on commit 413a6be

Please sign in to comment.