From 12adf3f5eca9c635aa1870bfe5b7bf3ec32559f9 Mon Sep 17 00:00:00 2001 From: AhnSangHoon Date: Wed, 24 Aug 2022 21:24:49 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:recycle:=20=ED=83=80=EC=9D=B4=EB=A8=B8=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=20=EC=A4=91=EB=B3=B5=20biding=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0(#189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Sources/Common/SplashViewModel.swift | 10 +--------- .../Sources/Main/MainCollectionViewDataSource.swift | 5 +++-- Projects/App/Sources/Main/MainViewController.swift | 2 -- Projects/App/Sources/Main/MainViewModel.swift | 6 +----- Projects/App/Sources/Main/View/MainView.swift | 2 ++ 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Projects/App/Sources/Common/SplashViewModel.swift b/Projects/App/Sources/Common/SplashViewModel.swift index 0228543b..fb8c2819 100644 --- a/Projects/App/Sources/Common/SplashViewModel.swift +++ b/Projects/App/Sources/Common/SplashViewModel.swift @@ -44,19 +44,11 @@ final class SplashViewModel: SplashViewModelProtocol { } private func changeRootViewController(deadlineData: Int) { - - var isDeadlineDataExist = true - - if deadlineData == 0 { - isDeadlineDataExist = false - } - let rootViewController = MainViewController( MainViewModel( network: Network(), repository: CategoryRepository(CategoryService(network: Network())), - OCRRepository: OCRRepository(OCRService(network: Network())), - deadlineDataExist: isDeadlineDataExist + OCRRepository: OCRRepository(OCRService(network: Network())) )) let navigationController = UINavigationController(rootViewController: rootViewController) diff --git a/Projects/App/Sources/Main/MainCollectionViewDataSource.swift b/Projects/App/Sources/Main/MainCollectionViewDataSource.swift index b166a07b..773c14e3 100644 --- a/Projects/App/Sources/Main/MainCollectionViewDataSource.swift +++ b/Projects/App/Sources/Main/MainCollectionViewDataSource.swift @@ -24,7 +24,7 @@ final class MainCollectionViewDataSource: NSObject, UICollectionViewDataSource { var didDeadLineCountdownTimeOver = PublishRelay() var selectedCategoryIndexPath: IndexPath? = nil - private let disposeBag = DisposeBag() + private var deadLineDisposeBag = DisposeBag() func numberOfSections(in collectionView: UICollectionView) -> Int { // TODO: 마감임박 데이터 없을 때의 경우 처리 필요 @@ -67,7 +67,7 @@ final class MainCollectionViewDataSource: NSObject, UICollectionViewDataSource { cell.gifticonApplyButtonDelegate = self cell.countdownTimeOver .bind(to: didDeadLineCountdownTimeOver) - .disposed(by: disposeBag) + .disposed(by: deadLineDisposeBag) return cell case .category: guard let cell = collectionView.dequeReusableCell(CategoryCollectionViewCell.self, @@ -112,6 +112,7 @@ final class MainCollectionViewDataSource: NSObject, UICollectionViewDataSource { extension MainCollectionViewDataSource { func updateDeadLineData(_ list: [GifticonCard]) { deadLineData = list + deadLineDisposeBag = DisposeBag() } func updateCategoryData(_ list: [Category]) { diff --git a/Projects/App/Sources/Main/MainViewController.swift b/Projects/App/Sources/Main/MainViewController.swift index a8b59c15..e26f8a22 100644 --- a/Projects/App/Sources/Main/MainViewController.swift +++ b/Projects/App/Sources/Main/MainViewController.swift @@ -144,8 +144,6 @@ final class MainViewController: BaseViewController { mainView.configureDataSource(viewModel.mainDataSource) mainView.configureDelegate(viewModel.mainDelegate) - mainView.isDeadlineDataExist.accept(viewModel.isDeadlineDataExist.value) - view.addSubview(mainView) mainView.snp.makeConstraints { $0.top.equalTo(navigationBar.snp.bottom) diff --git a/Projects/App/Sources/Main/MainViewModel.swift b/Projects/App/Sources/Main/MainViewModel.swift index ad0324b5..0d3d7ccf 100644 --- a/Projects/App/Sources/Main/MainViewModel.swift +++ b/Projects/App/Sources/Main/MainViewModel.swift @@ -96,17 +96,13 @@ final class MainViewModel: MainViewModelProtocol { init( network: Networking, repository: CategoryRepositoryLogic, - OCRRepository: OCRRepositoryLogic, - deadlineDataExist: Bool + OCRRepository: OCRRepositoryLogic ) { self.gifticonService = GifticonService(network: network) self.categoryRepository = repository self.OCRRepository = OCRRepository - self.isDeadlineDataExist.accept(deadlineDataExist) - deadlineInfo() category() - gifticonList() bind() } diff --git a/Projects/App/Sources/Main/View/MainView.swift b/Projects/App/Sources/Main/View/MainView.swift index bfd95b5c..821a1535 100644 --- a/Projects/App/Sources/Main/View/MainView.swift +++ b/Projects/App/Sources/Main/View/MainView.swift @@ -34,6 +34,8 @@ final class MainView: BaseView { backgroundColor = .clear isDeadlineDataExist + .skip(1) + .throttle(.milliseconds(500), scheduler: MainScheduler.instance) .subscribe(onNext: { [weak self] _ in self?.reloadCollectionViewSection(.deadLine) }) From eef1b222890914a8301b66d369b6075396cdd37d Mon Sep 17 00:00:00 2001 From: AhnSangHoon Date: Wed, 24 Aug 2022 21:26:03 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:recycle:=20=ED=83=80=EC=9D=B4=EB=A8=B8=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=EC=8B=9C=20=EB=A7=88=EA=B0=90=EC=9E=84?= =?UTF-8?q?=EB=B0=95,=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=EB=B3=84=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=8B=A4=EC=8B=9C=20=EB=B0=9B?= =?UTF-8?q?=EC=95=84=EC=98=A4=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD(#189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Sources/Main/MainViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/App/Sources/Main/MainViewModel.swift b/Projects/App/Sources/Main/MainViewModel.swift index 0d3d7ccf..4df50490 100644 --- a/Projects/App/Sources/Main/MainViewModel.swift +++ b/Projects/App/Sources/Main/MainViewModel.swift @@ -193,7 +193,7 @@ extension MainViewModel { mainDataSource.didDeadLineCountdownTimeOver .subscribe(onNext: { [weak self] in - self?.deadlineInfo() + self?.reload() }) .disposed(by: disposeBag) } From 1bbacd66c438d76fcc05c507d59757804d574aa2 Mon Sep 17 00:00:00 2001 From: AhnSangHoon Date: Fri, 26 Aug 2022 01:01:19 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:recycle:=20=EB=A7=88=EA=B0=90=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EC=9D=B4=ED=9B=84=EC=97=90=EB=8F=84=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=97=90=20=EA=B8=B0=ED=94=84=ED=8B=B0?= =?UTF-8?q?=EC=BD=98=EC=9D=B4=20=EB=82=A8=EC=95=84=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=EB=8C=80=EC=9D=91=20(#189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Sources/Main/MainViewModel.swift | 3 +++ Projects/App/Sources/Usecase/GifticonEntity.swift | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Projects/App/Sources/Main/MainViewModel.swift b/Projects/App/Sources/Main/MainViewModel.swift index 4df50490..e934ff13 100644 --- a/Projects/App/Sources/Main/MainViewModel.swift +++ b/Projects/App/Sources/Main/MainViewModel.swift @@ -191,7 +191,10 @@ extension MainViewModel { }) .disposed(by: disposeBag) + // 마감 시간이 지나고 바로 리스트 재요청 시 그대로 남아있는 이슈가 있음 + // 따라서 delay 500ms를 추가함 mainDataSource.didDeadLineCountdownTimeOver + .delay(.milliseconds(500), scheduler: MainScheduler.instance) .subscribe(onNext: { [weak self] in self?.reload() }) diff --git a/Projects/App/Sources/Usecase/GifticonEntity.swift b/Projects/App/Sources/Usecase/GifticonEntity.swift index 0cbd904d..9d349daf 100644 --- a/Projects/App/Sources/Usecase/GifticonEntity.swift +++ b/Projects/App/Sources/Usecase/GifticonEntity.swift @@ -13,7 +13,9 @@ struct GifticonEntity { init(_ responseModel: [GifticonResponseModel] = []) { gifticonList = responseModel.compactMap({ model in - GifticonCard( + // 마감 시간이 지난 경우 리스트에 노출되지 않도록 방어 + guard model.sprinkleAt.fullStringDate().compare(Date()) != .orderedAscending else { return nil } + return GifticonCard( sprinkleTime: model.sprinkleAt, gifticonInfo: Gifticon( id: model.sprinkleID, @@ -22,7 +24,8 @@ struct GifticonEntity { expirationDate: model.expiredAt, category: Category(rawValue: model.category) ?? .all), numberOfParticipants: model.participants, - isParticipating: model.participateIn) + isParticipating: model.participateIn + ) }) } }