Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: [#201] ๋ฐ์ดํ„ฐ fetching ์‹œ์  ๋ณ€๊ฒฝ #207

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class MassageStore: BaseStore {
}

enum Action {
case viewDidLoad
case viewWillAppear
case fetchMassageRankList
}

Expand All @@ -40,8 +40,8 @@ final class MassageStore: BaseStore {
extension MassageStore {
func mutate(state: State, action: Action) -> SideEffect<Mutation, Never> {
switch action {
case .viewDidLoad:
return viewDidLoad()
case .viewWillAppear:
return viewWillAppear()

case .fetchMassageRankList:
return fetchMassageRankList()
Expand All @@ -66,7 +66,7 @@ extension MassageStore {

// MARK: - Mutate
private extension MassageStore {
func viewDidLoad() -> SideEffect<Mutation, Never> {
func viewWillAppear() -> SideEffect<Mutation, Never> {
return self.fetchMassageRankList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ final class MassageViewController: BaseStoredViewController<MassageStore> {
private let massageNavigationBarLabel = DotoriNavigationBarLabel(text: L10n.Massage.massageTitle)
private let massageTableView = UITableView()
.set(\.backgroundColor, .clear)
.set(\.isHidden, true)
.set(\.separatorStyle, .none)
.set(\.sectionHeaderHeight, 0)
.then {
Expand Down Expand Up @@ -63,8 +62,8 @@ final class MassageViewController: BaseStoredViewController<MassageStore> {
}

override func bindAction() {
viewDidLoadPublisher
.map { Store.Action.viewDidLoad }
viewWillAppearPublisher
.map { Store.Action.viewWillAppear }
.sink(receiveValue: store.send(_:))
.store(in: &subscription)

Expand Down Expand Up @@ -96,11 +95,9 @@ final class MassageViewController: BaseStoredViewController<MassageStore> {
sharedState
.map(\.massageRankList)
.map(\.isEmpty)
.not()
.removeDuplicates()
.sink(with: self, receiveValue: { owner, massageIsEmpty in
owner.massageTableView.isHidden = massageIsEmpty
owner.emptySelfStudyStackView.isHidden = !massageIsEmpty
})
.assign(to: \.isHidden, on: emptySelfStudyStackView)
.store(in: &subscription)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ final class SelfStudyViewController: BaseStoredViewController<SelfStudyStore> {
.set(\.separatorStyle, .none)
.set(\.sectionHeaderHeight, 0)
.set(\.sectionFooterHeight, 0)
.set(\.isHidden, true)
.then {
$0.register(cellType: SelfStudyCell.self)
}
Expand Down Expand Up @@ -77,7 +76,7 @@ final class SelfStudyViewController: BaseStoredViewController<SelfStudyStore> {
}

override func bindAction() {
viewDidLoadPublisher
viewWillAppearPublisher
.merge(with: selfStudyRefreshContorol.controlPublisher(for: .valueChanged).map { _ in })
.map { Store.Action.fetchSelfStudyRank }
.sink(receiveValue: store.send(_:))
Expand All @@ -103,11 +102,9 @@ final class SelfStudyViewController: BaseStoredViewController<SelfStudyStore> {
sharedState
.map(\.selfStudyRankList)
.map(\.isEmpty)
.not()
.removeDuplicates()
.sink(with: self, receiveValue: { owner, selfStudyIsEmpty in
owner.selfStudyTableView.isHidden = selfStudyIsEmpty
owner.emptySelfStudyStackView.isHidden = !selfStudyIsEmpty
})
.assign(to: \.isHidden, on: emptySelfStudyStackView)
.store(in: &subscription)

sharedState
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Combine

public extension Publisher where Output == Bool {
func not() -> Publishers.Map<Self, Bool> {
self.map { !$0 }
}
}
Loading