From c55eef510b723d0ab3a18cf4c383afb5fcbd6029 Mon Sep 17 00:00:00 2001 From: Gordon Choi Date: Wed, 7 Dec 2022 02:52:09 +0900 Subject: [PATCH] =?UTF-8?q?#141=20#156=20#158=20feat:=20=EB=B6=84=EB=A6=AC?= =?UTF-8?q?=EB=90=98=EC=96=B4=20=EC=9E=88=EB=8D=98=20=EC=9D=8C=EC=95=85=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EB=A1=9C=EC=A7=81=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Domain/UseCase/SearchMusicUseCase.swift | 2 ++ .../DiaryEditViewController.swift | 20 ++++++++----------- .../ViewModel/DiaryEditViewModel.swift | 2 ++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Segno/Segno/Domain/UseCase/SearchMusicUseCase.swift b/Segno/Segno/Domain/UseCase/SearchMusicUseCase.swift index 41abb80..766eb10 100644 --- a/Segno/Segno/Domain/UseCase/SearchMusicUseCase.swift +++ b/Segno/Segno/Domain/UseCase/SearchMusicUseCase.swift @@ -24,6 +24,8 @@ final class SearchMusicUseCaseImpl: SearchMusicUseCase { init(musicRepository: MusicRepository = MusicRepositoryImpl()) { self.musicRepository = musicRepository + + subscribeShazamResult() } func startSearching() { diff --git a/Segno/Segno/Presentation/ViewController/DiaryEditViewController.swift b/Segno/Segno/Presentation/ViewController/DiaryEditViewController.swift index 2cc7e6e..fa47862 100644 --- a/Segno/Segno/Presentation/ViewController/DiaryEditViewController.swift +++ b/Segno/Segno/Presentation/ViewController/DiaryEditViewController.swift @@ -281,10 +281,10 @@ final class DiaryEditViewController: UIViewController { } } -// 샤잠킷 로직 부분 - 추후 뜯어서 옮길 계획입니다. +// 샤잠킷 로직 부분 extension DiaryEditViewController { private func bindLabel() { - shazamSession.isSearching + viewModel.isSearching .observe(on: MainScheduler.instance) .subscribe(onNext: { searchState in switch searchState { @@ -307,30 +307,26 @@ extension DiaryEditViewController { } private func bindSearchResult() { - shazamSession.result + viewModel.musicInfo + .observe(on: MainScheduler.instance) .subscribe(onNext: { result in switch result { case .success(let song): let title = song.title let artist = song.artist - let musicInfo = MusicInfo(shazamSong: song) // 뷰모델에서 이 작업을 할 때, 향후 사용될 엔티티 - debugPrint(musicInfo) + debugPrint(song) - DispatchQueue.main.async { - self.musicInfoLabel.text = "\(artist) - \(title)" - } + self.musicInfoLabel.text = "\(artist) - \(title)" case .failure(_): - DispatchQueue.main.async { - self.musicInfoLabel.text = "음악을 찾지 못했어요." - } + self.musicInfoLabel.text = "음악을 찾지 못했어요." } }) .disposed(by: disposeBag) } private func searchTapped() { - shazamSession.toggleSearch() // 지워질 예정 + viewModel.toggleSearchMusic() } } diff --git a/Segno/Segno/Presentation/ViewModel/DiaryEditViewModel.swift b/Segno/Segno/Presentation/ViewModel/DiaryEditViewModel.swift index 8ddb352..71d6442 100644 --- a/Segno/Segno/Presentation/ViewModel/DiaryEditViewModel.swift +++ b/Segno/Segno/Presentation/ViewModel/DiaryEditViewModel.swift @@ -25,6 +25,7 @@ final class DiaryEditViewModel { self.searchMusicUseCase = searchMusicUseCase subscribeSearchingStatus() + subscribeSearchResult() } func addTags() { @@ -58,6 +59,7 @@ final class DiaryEditViewModel { func subscribeSearchResult() { searchMusicUseCase.musicInfoResult .subscribe(onNext: { + self.toggleSearchMusic() self.musicInfo.onNext($0) }) .disposed(by: disposeBag)