Skip to content

Commit 74c355d

Browse files
committed
Refactor: 오타 수정 및 분기 처리
1 parent 1e19065 commit 74c355d

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

Projects/Presentation/Sources/Home/View/HomeView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ final class HomeView: BaseViewController<HomeViewModel> {
300300
}
301301
.store(in: &cancellables)
302302

303-
viewModel.output.fetchRoutineReulstPublisher
303+
viewModel.output.fetchRoutineResultPublisher
304304
.receive(on: DispatchQueue.main)
305-
.sink { [weak self] fetchRoutineReulst in
306-
if fetchRoutineReulst {
305+
.sink { [weak self] fetchRoutineResult in
306+
if fetchRoutineResult {
307307
self?.viewModel.action(input: .fetchDailyRoutines(date: Date()))
308308
}
309309
}

Projects/Presentation/Sources/Home/View/RoutineDetailView.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,13 @@ final class RoutineDetailView: UIViewController {
310310
make.size.equalTo(Layout.buttonHeight)
311311
}
312312

313-
updateSubRoutineView()
314-
updateRepeatRoutine()
313+
if !routine.subRoutines.isEmpty {
314+
updateSubRoutineView()
315+
}
316+
317+
if !routine.repeatDay.isEmpty {
318+
updateRepeatRoutine()
319+
}
315320
}
316321

317322
private func updateSubRoutineView() {
@@ -334,8 +339,6 @@ final class RoutineDetailView: UIViewController {
334339
}
335340

336341
private func updateRepeatRoutine() {
337-
if !routine.repeatDay.isEmpty {
338-
repeatRoutineTitleLabel.text = "\(routine.repeatDay.map({ $0.koreanValue }).joined(separator: ", "))"
339-
}
342+
repeatRoutineTitleLabel.text = "\(routine.repeatDay.map({ $0.koreanValue }).joined(separator: ", "))"
340343
}
341344
}

Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ final class HomeViewModel: ViewModel {
1818

1919
struct Output {
2020
let nicknamePublisher: AnyPublisher<String, Never>
21-
let fetchRoutineReulstPublisher: AnyPublisher<Bool, Never>
21+
let fetchRoutineResultPublisher: AnyPublisher<Bool, Never>
2222
let routinesPublisher: AnyPublisher<[MainRoutine], Never>
2323
}
2424

2525
private(set) var output: Output
2626
private var routines: [String: [MainRoutine]] = [:]
2727
private let nicknameSubject = CurrentValueSubject<String, Never>("")
28-
private let fetchRoutineReulstSubject = PassthroughSubject<Bool, Never>()
28+
private let fetchRoutineResultSubject = PassthroughSubject<Bool, Never>()
2929
private let routinesSubject = CurrentValueSubject<[MainRoutine], Never>([])
3030

3131
private let calendar = Calendar.current
@@ -38,7 +38,7 @@ final class HomeViewModel: ViewModel {
3838
self.userDataUseCase = userDataUseCase
3939
self.output = Output(
4040
nicknamePublisher: nicknameSubject.eraseToAnyPublisher(),
41-
fetchRoutineReulstPublisher: fetchRoutineReulstSubject.eraseToAnyPublisher(),
41+
fetchRoutineResultPublisher: fetchRoutineResultSubject.eraseToAnyPublisher(),
4242
routinesPublisher: routinesSubject.eraseToAnyPublisher()
4343
)
4444
}
@@ -86,7 +86,7 @@ final class HomeViewModel: ViewModel {
8686
for (date, routineEntities) in entities {
8787
routines[date] = routineEntities.map({ $0.toMainRoutine() })
8888
}
89-
fetchRoutineReulstSubject.send(true)
89+
fetchRoutineResultSubject.send(true)
9090
} catch {
9191

9292
}

0 commit comments

Comments
 (0)