Skip to content

Commit

Permalink
[fix] #120 링크 수정 내 버그 수정
Browse files Browse the repository at this point in the history
- 링크 수정에서 카테고리를 추가하고 돌아오면 추가한 카테고리 명이 적용되지 않던 버그를 수정
  • Loading branch information
stealmh committed Sep 17, 2024
1 parent 71f75d3 commit 022b5e3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Projects/App/Sources/MainTab/MainTabFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct MainTabFeature {
var pokit: PokitRootFeature.State
var remind: RemindFeature.State = .init()
@Presents var contentDetail: ContentDetailFeature.State?
@Shared(.inMemory("SelectCategory")) var selectedPokit: BaseCategoryItem?
@Shared(.inMemory("SelectCategory")) var categoryId: Int?
@Shared(.inMemory("PushTapped")) var isPushTapped: Bool = false

public init() {
Expand Down
4 changes: 2 additions & 2 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ public extension MainTabFeature {
}

case let .inner(.링크추가및수정이동(contentId: id)):
state.selectedPokit = nil
state.categoryId = nil
state.path.append(.링크추가및수정(ContentSettingFeature.State(contentId: id)))
return .send(.contentDetail(.dismiss))

/// - 링크 추가하기
case .delegate(.링크추가하기):
state.selectedPokit = nil
state.categoryId = nil
state.path.append(.링크추가및수정(ContentSettingFeature.State(urlText: state.link)))
state.link = nil
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct PokitCategorySettingFeature {
let type: SettingType
var isProfileSheetPresented: Bool = false
var pokitNameTextInpuState: PokitInputStyle.State = .default
@Shared(.inMemory("SelectCategory")) var selectCateogry: BaseCategoryItem?
@Shared(.inMemory("SelectCategory")) var categoryId: Int?
/// - 포킷 수정 API / 추가 API
/// categoryName
/// categoryImageId
Expand Down Expand Up @@ -242,7 +242,7 @@ private extension PokitCategorySettingFeature {
return .none

case let .카테고리_인메모리_저장(response):
state.selectCateogry = response
state.categoryId = response.id
return .none
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public struct ContentSettingFeature {
var linkTextInputState: PokitInputStyle.State = .default
var titleTextInpuState: PokitInputStyle.State = .default
var memoTextAreaState: PokitInputStyle.State = .default
@Shared(.inMemory("SelectCategory")) var selectedPokit: BaseCategoryItem?
@Shared(.inMemory("SelectCategory")) var categoryId: Int?
var selectedPokit: BaseCategoryItem?
var linkTitle: String? = nil
var linkImageURL: String? = nil
var showMaxCategoryPopup: Bool = false
Expand Down Expand Up @@ -112,7 +113,7 @@ public struct ContentSettingFeature {

public enum AsyncAction: Equatable {
case 컨텐츠_상세_조회(id: Int)
case 카테고리_상세_조회(id: Int)
case 카테고리_상세_조회(id: Int?, sharedId: Int?)
case 카테고리_목록_조회
case 컨텐츠_수정
case 컨텐츠_추가
Expand Down Expand Up @@ -269,9 +270,12 @@ private extension ContentSettingFeature {
state.domain.memo = content.memo
state.domain.alertYn = content.alertYn
state.contentLoading = false
return .run { [id = content.category.categoryId] send in
return .run { [
id = content.category.categoryId,
sharedCategoryId = state.categoryId
] send in
await send(.inner(.parsingURL))
await send(.async(.카테고리_상세_조회(id: id)))
await send(.async(.카테고리_상세_조회(id: id, sharedId: sharedCategoryId)))
}
case .카테고리_갱신(category: let category):
state.selectedPokit = BaseCategoryItem(
Expand Down Expand Up @@ -327,13 +331,23 @@ private extension ContentSettingFeature {
let content = try await contentClient.컨텐츠_상세_조회("\(id)").toDomain()
await send(.inner(.컨텐츠_갱신(content: content)))
}
case .카테고리_상세_조회(id: let id):
return .run { [id] send in
let category = try await categoryClient.카테고리_상세_조회("\(id)").toDomain()
await send(.inner(.카테고리_갱신(category: category)))
case let .카테고리_상세_조회(id, sharedId):
return .run { send in
if let sharedId {
let category = try await categoryClient.카테고리_상세_조회("\(sharedId)").toDomain()
await send(.inner(.카테고리_갱신(category: category)))
} else if let id {
let category = try await categoryClient.카테고리_상세_조회("\(id)").toDomain()
await send(.inner(.카테고리_갱신(category: category)))
}

}
case .카테고리_목록_조회:
return .run { [pageable = state.domain.pageable] send in
return .run { [
pageable = state.domain.pageable,
id = state.domain.categoryId,
sharedId = state.categoryId
] send in
let categoryList = try await categoryClient.카테고리_목록_조회(
BasePageableRequest(
page: pageable.page,
Expand All @@ -342,6 +356,8 @@ private extension ContentSettingFeature {
),
false
).toDomain()

await send(.async(.카테고리_상세_조회(id: id, sharedId: sharedId)))
await send(.inner(.카테고리_목록_갱신(categoryList: categoryList)), animation: .pokitDissolve)
}
case .컨텐츠_수정:
Expand Down

0 comments on commit 022b5e3

Please sign in to comment.