From b07d75e71e6eba90f31b97a21cef1e8bfc345bcd Mon Sep 17 00:00:00 2001 From: youn9k Date: Thu, 27 Jun 2024 18:15:38 +0900 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=8E=A8=20::=20[#674]=20NoticeDomain?= =?UTF-8?q?=20API=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=20=EB=8C=80?= =?UTF-8?q?=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSource/RemoteNoticeDataSource.swift | 3 +++ .../Entity/FetchNoticeCategoriesEntity.swift | 8 ------ .../Interface/Entity/FetchNoticeEntity.swift | 8 ------ .../Entity/FetchNoticeIDListEntity.swift | 14 ++++++++++ .../Repository/NoticeRepository.swift | 11 +++----- .../UseCase/FetchNoticeAllUseCase.swift | 6 +++++ .../FetchNoticeCategoriesUseCase.swift | 8 ------ .../UseCase/FetchNoticeIDListUseCase.swift | 6 +++++ .../UseCase/FetchNoticePopupUseCase.swift | 6 +++++ .../UseCase/FetchNoticeUseCase.swift | 8 ------ .../NoticeDomain/Sources/API/NoticeAPI.swift | 27 +++++++++++++++---- .../RemoteNoticeDataSourceImpl.swift | 18 +++++++++++++ .../Repository/NoticeRepositoryImpl.swift | 20 ++++++++------ .../FetchNoticeCategoriesResponseDTO.swift | 8 ------ .../ResponseDTO/FetchNoticeIDListDTO.swift | 13 +++++++++ .../ResponseDTO/FetchNoticeResponseDTO.swift | 8 ------ .../UseCase/FetchNoticeAllUseCaseImpl.swift | 17 ++++++++++++ .../FetchNoticeIDListUseCaseImpl.swift | 17 ++++++++++++ .../UseCase/FetchNoticePopupUseCaseImpl.swift | 17 ++++++++++++ 19 files changed, 154 insertions(+), 69 deletions(-) create mode 100644 Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeIDListEntity.swift create mode 100644 Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeAllUseCase.swift create mode 100644 Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeIDListUseCase.swift create mode 100644 Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticePopupUseCase.swift create mode 100644 Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeIDListDTO.swift create mode 100644 Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift create mode 100644 Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift create mode 100644 Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift diff --git a/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift b/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift index 97f00c289..9f0c881b7 100644 --- a/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift +++ b/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift @@ -12,4 +12,7 @@ import RxSwift public protocol RemoteNoticeDataSource { func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> func fetchNoticeCategories() -> Single + func fetchNoticePopup() -> Single<[FetchNoticeEntity]> + func fetchNoticeAll() -> Single<[FetchNoticeEntity]> + func fetchNoticeIDList() -> Single } diff --git a/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeCategoriesEntity.swift b/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeCategoriesEntity.swift index 07b585f51..7a74e107f 100644 --- a/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeCategoriesEntity.swift +++ b/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeCategoriesEntity.swift @@ -1,11 +1,3 @@ -// -// FetchNoticeCategoriesEntity.swift -// DomainModuleTests -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation public struct FetchNoticeCategoriesEntity { diff --git a/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeEntity.swift b/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeEntity.swift index 1e1b70a3c..2dc2d92c7 100644 --- a/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeEntity.swift +++ b/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeEntity.swift @@ -1,11 +1,3 @@ -// -// FetchNoticeEntity.swift -// DomainModuleTests -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation public struct FetchNoticeEntity { diff --git a/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeIDListEntity.swift b/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeIDListEntity.swift new file mode 100644 index 000000000..d2206a08f --- /dev/null +++ b/Projects/Domains/NoticeDomain/Interface/Entity/FetchNoticeIDListEntity.swift @@ -0,0 +1,14 @@ +import Foundation + +public struct FetchNoticeIDListEntity { + public init( + status: String, + data: [Int] + ) { + self.status = status + self.data = data + } + + public let status: String + public let data: [Int] +} diff --git a/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift b/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift index 3aca83685..22742f50b 100644 --- a/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift +++ b/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift @@ -1,15 +1,10 @@ -// -// NoticeRepository.swift -// DomainModuleTests -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import RxSwift public protocol NoticeRepository { func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> func fetchNoticeCategories() -> Single + func fetchNoticePopup() -> Single<[FetchNoticeEntity]> + func fetchNoticeAll() -> Single<[FetchNoticeEntity]> + func fetchNoticeIDList() -> Single } diff --git a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeAllUseCase.swift b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeAllUseCase.swift new file mode 100644 index 000000000..740d5eae9 --- /dev/null +++ b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeAllUseCase.swift @@ -0,0 +1,6 @@ +import Foundation +import RxSwift + +public protocol FetchNoticeAllUseCase { + func execute() -> Single<[FetchNoticeEntity]> +} diff --git a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeCategoriesUseCase.swift b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeCategoriesUseCase.swift index fe0d012a0..f85908f3d 100644 --- a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeCategoriesUseCase.swift +++ b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeCategoriesUseCase.swift @@ -1,11 +1,3 @@ -// -// FetchNoticeCategoriesUseCase.swift -// DomainModuleTests -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import RxSwift diff --git a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeIDListUseCase.swift b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeIDListUseCase.swift new file mode 100644 index 000000000..f89096fd3 --- /dev/null +++ b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeIDListUseCase.swift @@ -0,0 +1,6 @@ +import Foundation +import RxSwift + +public protocol FetchNoticeIDListUseCase { + func execute() -> Single +} diff --git a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticePopupUseCase.swift b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticePopupUseCase.swift new file mode 100644 index 000000000..4323ef4a3 --- /dev/null +++ b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticePopupUseCase.swift @@ -0,0 +1,6 @@ +import Foundation +import RxSwift + +public protocol FetchNoticePopupUseCase { + func execute() -> Single<[FetchNoticeEntity]> +} diff --git a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift index db0956004..e06467577 100644 --- a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift +++ b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift @@ -1,11 +1,3 @@ -// -// FetchNoticeUseCase.swift -// DomainModuleTests -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import RxSwift diff --git a/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift b/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift index b664a1847..a177e39c7 100644 --- a/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift +++ b/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift @@ -15,15 +15,14 @@ import NoticeDomainInterface public enum NoticeAPI { case fetchNotice(type: NoticeType) case fetchNoticeCategories + case fetchNoticePopup + case fetchNoticeAll + case fetchNoticeIDList } extension NoticeAPI: WMAPI { public var domain: WMDomain { - switch self { - case .fetchNotice, - .fetchNoticeCategories: - return .notice - } + return .notice } public var urlPath: String { @@ -32,6 +31,12 @@ extension NoticeAPI: WMAPI { return "/\(type.rawValue)" case .fetchNoticeCategories: return "/categories" + case .fetchNoticePopup: + return "/popup" + case .fetchNoticeAll: + return "/all" + case .fetchNoticeIDList: + return "/ids" } } @@ -40,6 +45,12 @@ extension NoticeAPI: WMAPI { case .fetchNotice, .fetchNoticeCategories: return .get + case .fetchNoticePopup: + return .get + case .fetchNoticeAll: + return .get + case .fetchNoticeIDList: + return .get } } @@ -56,6 +67,12 @@ extension NoticeAPI: WMAPI { ) case .fetchNoticeCategories: return .requestPlain + case .fetchNoticePopup: + return .requestPlain + case .fetchNoticeAll: + return .requestPlain + case .fetchNoticeIDList: + return .requestPlain } } diff --git a/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift b/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift index 0935d6b77..4efe60943 100644 --- a/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift @@ -23,4 +23,22 @@ public final class RemoteNoticeDataSourceImpl: BaseRemoteDataSource, .map(FetchNoticeCategoriesResponseDTO.self) .map { $0.toDomain() } } + + public func fetchNoticePopup() -> Single<[FetchNoticeEntity]> { + request(.fetchNoticePopup) + .map([FetchNoticeResponseDTO].self) + .map { $0.map { $0.toDomain() } } + } + + public func fetchNoticeAll() -> Single<[FetchNoticeEntity]> { + request(.fetchNoticeAll) + .map([FetchNoticeResponseDTO].self) + .map { $0.map { $0.toDomain() } } + } + + public func fetchNoticeIDList() -> Single { + request(.fetchNoticeIDList) + .map(FetchNoticeIDListDTO.self) + .map { $0.toDomain() } + } } diff --git a/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift b/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift index abf78d42a..e00f9ba0a 100644 --- a/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift @@ -1,11 +1,3 @@ -// -// NoticeRepositoryImpl.swift -// DataModule -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import NoticeDomainInterface import RxSwift @@ -26,4 +18,16 @@ public final class NoticeRepositoryImpl: NoticeRepository { public func fetchNoticeCategories() -> Single { remoteNoticeDataSource.fetchNoticeCategories() } + + public func fetchNoticePopup() -> Single<[FetchNoticeEntity]> { + remoteNoticeDataSource.fetchNoticePopup() + } + + public func fetchNoticeAll() -> Single<[FetchNoticeEntity]> { + remoteNoticeDataSource.fetchNoticeAll() + } + + public func fetchNoticeIDList() -> Single { + remoteNoticeDataSource.fetchNoticeIDList() + } } diff --git a/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeCategoriesResponseDTO.swift b/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeCategoriesResponseDTO.swift index de01c5d2a..7c2a45c95 100644 --- a/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeCategoriesResponseDTO.swift +++ b/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeCategoriesResponseDTO.swift @@ -1,11 +1,3 @@ -// -// FetchNoticeCategoriesResponseDTO.swift -// DataMappingModule -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import NoticeDomainInterface diff --git a/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeIDListDTO.swift b/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeIDListDTO.swift new file mode 100644 index 000000000..329c3d6c1 --- /dev/null +++ b/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeIDListDTO.swift @@ -0,0 +1,13 @@ +import Foundation +import NoticeDomainInterface + +public struct FetchNoticeIDListDTO: Decodable { + let status: String + let data: [Int] +} + +public extension FetchNoticeIDListDTO { + func toDomain() -> FetchNoticeIDListEntity { + return FetchNoticeIDListEntity(status: status, data: data) + } +} diff --git a/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeResponseDTO.swift b/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeResponseDTO.swift index 7fdedc536..36f2214f4 100644 --- a/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeResponseDTO.swift +++ b/Projects/Domains/NoticeDomain/Sources/ResponseDTO/FetchNoticeResponseDTO.swift @@ -1,11 +1,3 @@ -// -// FetchNoticeResponseDTO.swift -// DataMappingModule -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import NoticeDomainInterface diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift new file mode 100644 index 000000000..6b99b944a --- /dev/null +++ b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift @@ -0,0 +1,17 @@ +import Foundation +import RxSwift +import NoticeDomainInterface + +public struct FetchNoticeAllUseCaseImpl: FetchNoticeAllUseCase { + private let noticeRepository: any NoticeRepository + + public init( + noticeRepository: NoticeRepository + ) { + self.noticeRepository = noticeRepository + } + + public func execute() -> Single<[FetchNoticeEntity]> { + return noticeRepository.fetchNoticeAll() + } +} diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift new file mode 100644 index 000000000..079021c72 --- /dev/null +++ b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift @@ -0,0 +1,17 @@ +import Foundation +import RxSwift +import NoticeDomainInterface + +public struct FetchNoticeIDListUseCaseImpl: FetchNoticeIDListUseCase { + private let noticeRepository: any NoticeRepository + + public init( + noticeRepository: NoticeRepository + ) { + self.noticeRepository = noticeRepository + } + + public func execute() -> Single { + return noticeRepository.fetchNoticeIDList() + } +} diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift new file mode 100644 index 000000000..70254d1ce --- /dev/null +++ b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift @@ -0,0 +1,17 @@ +import Foundation +import RxSwift +import NoticeDomainInterface + +public struct FetchNoticePopupUseCaseImpl: FetchNoticePopupUseCase { + private let noticeRepository: any NoticeRepository + + public init( + noticeRepository: NoticeRepository + ) { + self.noticeRepository = noticeRepository + } + + public func execute() -> Single<[FetchNoticeEntity]> { + return noticeRepository.fetchNoticePopup() + } +} From 469de30baec3f422e3cb9ee4f964f0fbf54c17a7 Mon Sep 17 00:00:00 2001 From: youn9k Date: Thu, 27 Jun 2024 18:15:45 +0900 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=8E=A8=20::=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?Formatting=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/DataSource/RemoteNoticeDataSourceImpl.swift | 6 +++--- .../Sources/Repository/NoticeRepositoryImpl.swift | 6 +++--- .../Sources/UseCase/FetchNoticeAllUseCaseImpl.swift | 4 ++-- .../Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift | 4 ++-- .../Sources/UseCase/FetchNoticePopupUseCaseImpl.swift | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift b/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift index 4efe60943..2df501825 100644 --- a/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift @@ -23,19 +23,19 @@ public final class RemoteNoticeDataSourceImpl: BaseRemoteDataSource, .map(FetchNoticeCategoriesResponseDTO.self) .map { $0.toDomain() } } - + public func fetchNoticePopup() -> Single<[FetchNoticeEntity]> { request(.fetchNoticePopup) .map([FetchNoticeResponseDTO].self) .map { $0.map { $0.toDomain() } } } - + public func fetchNoticeAll() -> Single<[FetchNoticeEntity]> { request(.fetchNoticeAll) .map([FetchNoticeResponseDTO].self) .map { $0.map { $0.toDomain() } } } - + public func fetchNoticeIDList() -> Single { request(.fetchNoticeIDList) .map(FetchNoticeIDListDTO.self) diff --git a/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift b/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift index e00f9ba0a..7a3435d9d 100644 --- a/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift @@ -18,15 +18,15 @@ public final class NoticeRepositoryImpl: NoticeRepository { public func fetchNoticeCategories() -> Single { remoteNoticeDataSource.fetchNoticeCategories() } - + public func fetchNoticePopup() -> Single<[FetchNoticeEntity]> { remoteNoticeDataSource.fetchNoticePopup() } - + public func fetchNoticeAll() -> Single<[FetchNoticeEntity]> { remoteNoticeDataSource.fetchNoticeAll() } - + public func fetchNoticeIDList() -> Single { remoteNoticeDataSource.fetchNoticeIDList() } diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift index 6b99b944a..0bf745e4e 100644 --- a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeAllUseCaseImpl.swift @@ -1,6 +1,6 @@ import Foundation -import RxSwift import NoticeDomainInterface +import RxSwift public struct FetchNoticeAllUseCaseImpl: FetchNoticeAllUseCase { private let noticeRepository: any NoticeRepository @@ -10,7 +10,7 @@ public struct FetchNoticeAllUseCaseImpl: FetchNoticeAllUseCase { ) { self.noticeRepository = noticeRepository } - + public func execute() -> Single<[FetchNoticeEntity]> { return noticeRepository.fetchNoticeAll() } diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift index 079021c72..2aed5cc38 100644 --- a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeIDListUseCaseImpl.swift @@ -1,6 +1,6 @@ import Foundation -import RxSwift import NoticeDomainInterface +import RxSwift public struct FetchNoticeIDListUseCaseImpl: FetchNoticeIDListUseCase { private let noticeRepository: any NoticeRepository @@ -10,7 +10,7 @@ public struct FetchNoticeIDListUseCaseImpl: FetchNoticeIDListUseCase { ) { self.noticeRepository = noticeRepository } - + public func execute() -> Single { return noticeRepository.fetchNoticeIDList() } diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift index 70254d1ce..2aae1fa20 100644 --- a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticePopupUseCaseImpl.swift @@ -1,6 +1,6 @@ import Foundation -import RxSwift import NoticeDomainInterface +import RxSwift public struct FetchNoticePopupUseCaseImpl: FetchNoticePopupUseCase { private let noticeRepository: any NoticeRepository @@ -10,7 +10,7 @@ public struct FetchNoticePopupUseCaseImpl: FetchNoticePopupUseCase { ) { self.noticeRepository = noticeRepository } - + public func execute() -> Single<[FetchNoticeEntity]> { return noticeRepository.fetchNoticePopup() } From b1ce01383b42b38ae7554631f0417adef2efd238 Mon Sep 17 00:00:00 2001 From: youn9k Date: Thu, 27 Jun 2024 21:03:48 +0900 Subject: [PATCH 03/13] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20[#674]=20?= =?UTF-8?q?=EC=9D=BD=EC=9D=80=20=EA=B3=B5=EC=A7=80=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EB=94=94=ED=8F=B4=ED=8A=B8=20=EC=A0=80=EC=9E=A5=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/AppComponent+Notice.swift | 4 ++-- .../DataSource/RemoteNoticeDataSource.swift | 1 - .../Interface/Enum/NoticeType.swift | 14 ----------- .../Repository/NoticeRepository.swift | 1 - .../UseCase/FetchNoticeUseCase.swift | 6 ----- .../NoticeDomain/Sources/API/NoticeAPI.swift | 15 +----------- .../RemoteNoticeDataSourceImpl.swift | 6 ----- .../Repository/NoticeRepositoryImpl.swift | 4 ---- .../UseCase/FetchNoticeUseCaseImpl.swift | 17 -------------- .../Testing/FetchNoticeAllUseCaseStub.swift | 9 ++++++++ .../Testing/FetchNoticeUseCaseStub.swift | 9 -------- .../Components/MainTabBarComponent.swift | 4 ++-- .../ViewModels/MainTabBarViewModel.swift | 18 ++++----------- .../Sources/Components/NoticeComponent.swift | 4 ++-- .../Sources/Reactors/MyInfoReactor.swift | 23 +++++++++++++++++-- .../Sources/ViewModels/NoticeViewModel.swift | 18 ++++++++++----- .../Testing/NoticeComponentStub.swift | 2 +- 17 files changed, 55 insertions(+), 100 deletions(-) delete mode 100644 Projects/Domains/NoticeDomain/Interface/Enum/NoticeType.swift delete mode 100644 Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift delete mode 100644 Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeUseCaseImpl.swift create mode 100644 Projects/Domains/NoticeDomain/Testing/FetchNoticeAllUseCaseStub.swift delete mode 100644 Projects/Domains/NoticeDomain/Testing/FetchNoticeUseCaseStub.swift diff --git a/Projects/App/Sources/Application/AppComponent+Notice.swift b/Projects/App/Sources/Application/AppComponent+Notice.swift index e2606e366..958a546ae 100644 --- a/Projects/App/Sources/Application/AppComponent+Notice.swift +++ b/Projects/App/Sources/Application/AppComponent+Notice.swift @@ -39,9 +39,9 @@ public extension AppComponent { } } - var fetchNoticeUseCase: any FetchNoticeUseCase { + var fetchNoticeAllUseCase: any FetchNoticeAllUseCase { shared { - FetchNoticeUseCaseImpl(noticeRepository: noticeRepository) + FetchNoticeAllUseCaseImpl(noticeRepository: noticeRepository) } } diff --git a/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift b/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift index 9f0c881b7..078a30721 100644 --- a/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift +++ b/Projects/Domains/NoticeDomain/Interface/DataSource/RemoteNoticeDataSource.swift @@ -10,7 +10,6 @@ import Foundation import RxSwift public protocol RemoteNoticeDataSource { - func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> func fetchNoticeCategories() -> Single func fetchNoticePopup() -> Single<[FetchNoticeEntity]> func fetchNoticeAll() -> Single<[FetchNoticeEntity]> diff --git a/Projects/Domains/NoticeDomain/Interface/Enum/NoticeType.swift b/Projects/Domains/NoticeDomain/Interface/Enum/NoticeType.swift deleted file mode 100644 index 991118b2c..000000000 --- a/Projects/Domains/NoticeDomain/Interface/Enum/NoticeType.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// NoticeType.swift -// DataMappingModule -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - -import Foundation - -public enum NoticeType: String { - case popup // 공지팝업 - case all // 전체공지 -} diff --git a/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift b/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift index 22742f50b..0755628b7 100644 --- a/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift +++ b/Projects/Domains/NoticeDomain/Interface/Repository/NoticeRepository.swift @@ -2,7 +2,6 @@ import Foundation import RxSwift public protocol NoticeRepository { - func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> func fetchNoticeCategories() -> Single func fetchNoticePopup() -> Single<[FetchNoticeEntity]> func fetchNoticeAll() -> Single<[FetchNoticeEntity]> diff --git a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift b/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift deleted file mode 100644 index e06467577..000000000 --- a/Projects/Domains/NoticeDomain/Interface/UseCase/FetchNoticeUseCase.swift +++ /dev/null @@ -1,6 +0,0 @@ -import Foundation -import RxSwift - -public protocol FetchNoticeUseCase { - func execute(type: NoticeType) -> Single<[FetchNoticeEntity]> -} diff --git a/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift b/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift index a177e39c7..0da97e75d 100644 --- a/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift +++ b/Projects/Domains/NoticeDomain/Sources/API/NoticeAPI.swift @@ -13,7 +13,6 @@ import Moya import NoticeDomainInterface public enum NoticeAPI { - case fetchNotice(type: NoticeType) case fetchNoticeCategories case fetchNoticePopup case fetchNoticeAll @@ -27,8 +26,6 @@ extension NoticeAPI: WMAPI { public var urlPath: String { switch self { - case let .fetchNotice(type): - return "/\(type.rawValue)" case .fetchNoticeCategories: return "/categories" case .fetchNoticePopup: @@ -42,8 +39,7 @@ extension NoticeAPI: WMAPI { public var method: Moya.Method { switch self { - case .fetchNotice, - .fetchNoticeCategories: + case .fetchNoticeCategories: return .get case .fetchNoticePopup: return .get @@ -56,15 +52,6 @@ extension NoticeAPI: WMAPI { public var task: Moya.Task { switch self { - case .fetchNotice: - return .requestParameters( - parameters: [ - "os": "ios", - "version": Bundle.main - .object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "" - ], - encoding: URLEncoding.queryString - ) case .fetchNoticeCategories: return .requestPlain case .fetchNoticePopup: diff --git a/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift b/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift index 2df501825..d936da175 100644 --- a/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/DataSource/RemoteNoticeDataSourceImpl.swift @@ -12,12 +12,6 @@ import NoticeDomainInterface import RxSwift public final class RemoteNoticeDataSourceImpl: BaseRemoteDataSource, RemoteNoticeDataSource { - public func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> { - request(.fetchNotice(type: type)) - .map([FetchNoticeResponseDTO].self) - .map { $0.map { $0.toDomain() }} - } - public func fetchNoticeCategories() -> Single { request(.fetchNoticeCategories) .map(FetchNoticeCategoriesResponseDTO.self) diff --git a/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift b/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift index 7a3435d9d..09c643f4c 100644 --- a/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift +++ b/Projects/Domains/NoticeDomain/Sources/Repository/NoticeRepositoryImpl.swift @@ -11,10 +11,6 @@ public final class NoticeRepositoryImpl: NoticeRepository { self.remoteNoticeDataSource = remoteNoticeDataSource } - public func fetchNotice(type: NoticeType) -> Single<[FetchNoticeEntity]> { - remoteNoticeDataSource.fetchNotice(type: type) - } - public func fetchNoticeCategories() -> Single { remoteNoticeDataSource.fetchNoticeCategories() } diff --git a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeUseCaseImpl.swift b/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeUseCaseImpl.swift deleted file mode 100644 index c0e9f1cae..000000000 --- a/Projects/Domains/NoticeDomain/Sources/UseCase/FetchNoticeUseCaseImpl.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Foundation -import NoticeDomainInterface -import RxSwift - -public struct FetchNoticeUseCaseImpl: FetchNoticeUseCase { - private let noticeRepository: any NoticeRepository - - public init( - noticeRepository: NoticeRepository - ) { - self.noticeRepository = noticeRepository - } - - public func execute(type: NoticeType) -> Single<[FetchNoticeEntity]> { - noticeRepository.fetchNotice(type: type) - } -} diff --git a/Projects/Domains/NoticeDomain/Testing/FetchNoticeAllUseCaseStub.swift b/Projects/Domains/NoticeDomain/Testing/FetchNoticeAllUseCaseStub.swift new file mode 100644 index 000000000..762ba890a --- /dev/null +++ b/Projects/Domains/NoticeDomain/Testing/FetchNoticeAllUseCaseStub.swift @@ -0,0 +1,9 @@ +import Foundation +import NoticeDomainInterface +import RxSwift + +public struct FetchNoticeAllUseCaseStub: FetchNoticeAllUseCase { + public func execute() -> Single<[FetchNoticeEntity]> { + return .just([]) + } +} diff --git a/Projects/Domains/NoticeDomain/Testing/FetchNoticeUseCaseStub.swift b/Projects/Domains/NoticeDomain/Testing/FetchNoticeUseCaseStub.swift deleted file mode 100644 index e5b237473..000000000 --- a/Projects/Domains/NoticeDomain/Testing/FetchNoticeUseCaseStub.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation -import NoticeDomainInterface -import RxSwift - -public struct FetchNoticeUseCaseStub: FetchNoticeUseCase { - public func execute(type: NoticeType) -> Single<[FetchNoticeEntity]> { - return .just([]) - } -} diff --git a/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift b/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift index 0e34e2e3a..786837746 100644 --- a/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift +++ b/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift @@ -12,7 +12,7 @@ import StorageFeature import StorageFeatureInterface public protocol MainTabBarDependency: Dependency { - var fetchNoticeUseCase: any FetchNoticeUseCase { get } + var fetchNoticeAllUseCase: any FetchNoticeAllUseCase { get } var homeComponent: HomeComponent { get } var searchFactory: any SearchFactory { get } var artistComponent: ArtistComponent { get } @@ -27,7 +27,7 @@ public final class MainTabBarComponent: Component { public func makeView() -> MainTabBarViewController { return MainTabBarViewController.viewController( viewModel: MainTabBarViewModel.init( - fetchNoticeUseCase: self.dependency.fetchNoticeUseCase + fetchNoticeAllUseCase: self.dependency.fetchNoticeAllUseCase ), homeComponent: self.dependency.homeComponent, searchFactory: self.dependency.searchFactory, diff --git a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift index 26cee36d0..e6a772aa4 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift @@ -1,11 +1,3 @@ -// -// MainTabBarViewModel.swift -// MainTabFeature -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import Foundation import NoticeDomainInterface import RxRelay @@ -13,13 +5,13 @@ import RxSwift import Utility public final class MainTabBarViewModel { - private let fetchNoticeUseCase: FetchNoticeUseCase + private let fetchNoticeAllUseCase: FetchNoticeAllUseCase private let disposeBag = DisposeBag() public init( - fetchNoticeUseCase: any FetchNoticeUseCase + fetchNoticeAllUseCase: any FetchNoticeAllUseCase ) { - self.fetchNoticeUseCase = fetchNoticeUseCase + self.fetchNoticeAllUseCase = fetchNoticeAllUseCase } public struct Input { @@ -36,8 +28,8 @@ public final class MainTabBarViewModel { DEBUG_LOG("igoredNoticeIds: \(igoredNoticeIds)") input.fetchNoticePopup - .flatMap { [fetchNoticeUseCase] _ -> Single<[FetchNoticeEntity]> in - return fetchNoticeUseCase.execute(type: .popup) + .flatMap { [fetchNoticeAllUseCase] _ -> Single<[FetchNoticeEntity]> in + return fetchNoticeAllUseCase.execute() .catchAndReturn([]) } .map { entities in diff --git a/Projects/Features/MyInfoFeature/Sources/Components/NoticeComponent.swift b/Projects/Features/MyInfoFeature/Sources/Components/NoticeComponent.swift index cd37cf78b..bfd0666f4 100644 --- a/Projects/Features/MyInfoFeature/Sources/Components/NoticeComponent.swift +++ b/Projects/Features/MyInfoFeature/Sources/Components/NoticeComponent.swift @@ -5,7 +5,7 @@ import NoticeDomainInterface import UIKit public protocol NoticeDependency: Dependency { - var fetchNoticeUseCase: any FetchNoticeUseCase { get } + var fetchNoticeAllUseCase: any FetchNoticeAllUseCase { get } var noticeDetailFactory: any NoticeDetailFactory { get } } @@ -13,7 +13,7 @@ public final class NoticeComponent: Component, NoticeFactory { public func makeView() -> UIViewController { return NoticeViewController.viewController( viewModel: .init( - fetchNoticeUseCase: dependency.fetchNoticeUseCase + fetchNoticeAllUseCase: dependency.fetchNoticeAllUseCase ), noticeDetailFactory: dependency.noticeDetailFactory ) diff --git a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift index 5ab143a02..4c0ef0318 100644 --- a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift +++ b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift @@ -17,6 +17,7 @@ final class MyInfoReactor: Reactor { case teamNavigationDidTap case settingNavigationDidTap case changeUserInfo(UserInfo?) + case changeReadNoticeIDs([Int]) } enum Mutation { @@ -27,6 +28,7 @@ final class MyInfoReactor: Reactor { case updateProfileImage(String) case updateNickname(String) case updatePlatform(String) + case updateIsAllNoticesRead(Bool) } enum NavigateType { @@ -44,6 +46,7 @@ final class MyInfoReactor: Reactor { var profileImage: String var nickname: String var platform: String + var isAllNoticesRead: Bool @Pulse var loginButtonDidTap: Bool? @Pulse var profileImageDidTap: Bool? @Pulse var navigateType: NavigateType? @@ -57,7 +60,8 @@ final class MyInfoReactor: Reactor { isLoggedIn: false, profileImage: "", nickname: "", - platform: "" + platform: "", + isAllNoticesRead: false ) observeUserInfoChanges() } @@ -89,6 +93,8 @@ final class MyInfoReactor: Reactor { updateNickname(userInfo), updatePlatform(userInfo) ) + case let .changeReadNoticeIDs(readIDs): + } } @@ -128,7 +134,20 @@ private extension MyInfoReactor { } .disposed(by: disposeBag) } - + + func observeReadNoticeIdChanges() { +// PreferenceManager.$readNoticeIDs +// .compactMap { $0 } +// .bind(with: self) { owner, readIDs in +// owner.action.onNext(.changeReadNoticeIDs(readIDs)) +// } +// .disposed(by: disposeBag) + } + + func updateIsAllNoticesRead(_ readIDs: [Int]) -> Observable { + + } + func updateIsLoggedIn(_ userInfo: UserInfo?) -> Observable { return .just(.updateIsLoggedIn(userInfo != nil)) } diff --git a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift index 68bd5a754..9a7688660 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift @@ -7,13 +7,13 @@ import RxSwift import Utility public final class NoticeViewModel { - private let fetchNoticeUseCase: FetchNoticeUseCase + private let fetchNoticeAllUseCase: FetchNoticeAllUseCase private let disposeBag = DisposeBag() public init( - fetchNoticeUseCase: any FetchNoticeUseCase + fetchNoticeAllUseCase: any FetchNoticeAllUseCase ) { - self.fetchNoticeUseCase = fetchNoticeUseCase + self.fetchNoticeAllUseCase = fetchNoticeAllUseCase } public struct Input { @@ -30,8 +30,8 @@ public final class NoticeViewModel { let output = Output() input.fetchNotice - .flatMap { [fetchNoticeUseCase] _ -> Single<[FetchNoticeEntity]> in - return fetchNoticeUseCase.execute(type: .all) + .flatMap { [fetchNoticeAllUseCase] _ -> Single<[FetchNoticeEntity]> in + return fetchNoticeAllUseCase.execute() .catchAndReturn([]) } .bind(to: output.dataSource) @@ -39,7 +39,13 @@ public final class NoticeViewModel { input.didTapList .withLatestFrom(output.dataSource) { ($0, $1) } - .map { $0.1[$0.0.row] } + .map { selectedIndexPath, entities in + entities[selectedIndexPath.row] + } + .do { entity in + //let savedIds: [Int] = Utility.PreferenceManager.readNoticeIDs ?? [] + //PreferenceManager.readNoticeIDs = savedIds.isEmpty ? [entity.id] : savedIds + [entity.id] + } .bind(to: output.goNoticeDetailScene) .disposed(by: disposeBag) diff --git a/Projects/Features/MyInfoFeature/Testing/NoticeComponentStub.swift b/Projects/Features/MyInfoFeature/Testing/NoticeComponentStub.swift index 7a03ab4ac..8ce8e626f 100644 --- a/Projects/Features/MyInfoFeature/Testing/NoticeComponentStub.swift +++ b/Projects/Features/MyInfoFeature/Testing/NoticeComponentStub.swift @@ -10,7 +10,7 @@ public final class NoticeComponentStub: NoticeFactory { public func makeView() -> UIViewController { return NoticeViewController.viewController( viewModel: .init( - fetchNoticeUseCase: FetchNoticeUseCaseStub() + fetchNoticeAllUseCase: FetchNoticeAllUseCaseStub() ), noticeDetailFactory: NoticeDetailComponentStub() ) From 197f4e2eac6f58226a6faaffe8aeceeefb9a0e47 Mon Sep 17 00:00:00 2001 From: youn9k Date: Thu, 27 Jun 2024 21:06:39 +0900 Subject: [PATCH 04/13] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=20[#674]=20?= =?UTF-8?q?=ED=8C=9D=EC=97=85=20=EB=A6=AC=EB=84=A4=EC=9D=B4=EB=B0=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 공지와 팝업을 구분합니다. --- .../ViewControllers/NoticePopupViewController.swift | 6 +++--- .../Sources/ViewModels/MainTabBarViewModel.swift | 10 +++++----- .../Utility/Sources/Manager/PreferenceManager.swift | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Projects/Features/MainTabFeature/Sources/ViewControllers/NoticePopupViewController.swift b/Projects/Features/MainTabFeature/Sources/ViewControllers/NoticePopupViewController.swift index de5669815..19b9a0948 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewControllers/NoticePopupViewController.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewControllers/NoticePopupViewController.swift @@ -53,13 +53,13 @@ public class NoticePopupViewController: UIViewController, ViewControllerFromStor } @IBAction func ignoreButtonAction(_ sender: Any) { - let savedIgoredNoticeIds: [Int] = Utility.PreferenceManager.ignoredNoticeIDs ?? [] + let savedIgoredNoticeIds: [Int] = Utility.PreferenceManager.ignoredPopupIDs ?? [] let currentNoticeIds: [Int] = output.originDataSource.value.map { $0.id } if savedIgoredNoticeIds.isEmpty { - Utility.PreferenceManager.ignoredNoticeIDs = currentNoticeIds + Utility.PreferenceManager.ignoredPopupIDs = currentNoticeIds } else { - Utility.PreferenceManager.ignoredNoticeIDs = savedIgoredNoticeIds + currentNoticeIds + Utility.PreferenceManager.ignoredPopupIDs = savedIgoredNoticeIds + currentNoticeIds } dismiss(animated: true) } diff --git a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift index e6a772aa4..6740ca87c 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift @@ -24,8 +24,8 @@ public final class MainTabBarViewModel { public func transform(from input: Input) -> Output { let output = Output() - let igoredNoticeIds: [Int] = Utility.PreferenceManager.ignoredNoticeIDs ?? [] - DEBUG_LOG("igoredNoticeIds: \(igoredNoticeIds)") + let ignoredPopupIDs: [Int] = Utility.PreferenceManager.ignoredPopupIDs ?? [] + DEBUG_LOG("ignoredPopupIDs: \(ignoredPopupIDs)") input.fetchNoticePopup .flatMap { [fetchNoticeAllUseCase] _ -> Single<[FetchNoticeEntity]> in @@ -33,12 +33,12 @@ public final class MainTabBarViewModel { .catchAndReturn([]) } .map { entities in - guard !igoredNoticeIds.isEmpty else { return entities } + guard !ignoredPopupIDs.isEmpty else { return entities } return entities.filter { entity in - return !igoredNoticeIds.contains(where: { $0 == entity.id }) + return !ignoredPopupIDs.contains(where: { $0 == entity.id }) } } - .debug("igoredNoticeIds") + .debug("ignoredPopupIDs") .bind(to: output.dataSource) .disposed(by: disposeBag) diff --git a/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift b/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift index 59cd09b24..3634f2f72 100644 --- a/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift +++ b/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift @@ -19,7 +19,7 @@ public final class PreferenceManager { case recentRecords // 최근 검색어 case startPage // 시작 페이지(탭) case appPermissionChecked // 앱 권한팝업 승인 - case ignoredNoticeIDs // 다시보지 않는 공지 IDs + case ignoredPopupIDs // 다시보지 않는 팝업 IDs } @UserDefaultWrapper(key: Constants.recentRecords.rawValue, defaultValue: nil) @@ -34,8 +34,8 @@ public final class PreferenceManager { @UserDefaultWrapper(key: Constants.appPermissionChecked.rawValue, defaultValue: nil) public static var appPermissionChecked: Bool? - @UserDefaultWrapper(key: Constants.ignoredNoticeIDs.rawValue, defaultValue: nil) - public static var ignoredNoticeIDs: [Int]? + @UserDefaultWrapper(key: Constants.ignoredPopupIDs.rawValue, defaultValue: nil) + public static var ignoredPopupIDs: [Int]? } @propertyWrapper From f283cf3eadf59a50e0cf842610f6da3a24b281a9 Mon Sep 17 00:00:00 2001 From: youn9k Date: Thu, 27 Jun 2024 22:00:29 +0900 Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=8E=A8=20::=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?Formatting=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Reactors/MyInfoReactor.swift | 11 ++++------- .../Sources/ViewModels/NoticeViewModel.swift | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift index 4c0ef0318..f7fae6ee2 100644 --- a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift +++ b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift @@ -94,7 +94,6 @@ final class MyInfoReactor: Reactor { updatePlatform(userInfo) ) case let .changeReadNoticeIDs(readIDs): - } } @@ -134,7 +133,7 @@ private extension MyInfoReactor { } .disposed(by: disposeBag) } - + func observeReadNoticeIdChanges() { // PreferenceManager.$readNoticeIDs // .compactMap { $0 } @@ -143,11 +142,9 @@ private extension MyInfoReactor { // } // .disposed(by: disposeBag) } - - func updateIsAllNoticesRead(_ readIDs: [Int]) -> Observable { - - } - + + func updateIsAllNoticesRead(_ readIDs: [Int]) -> Observable {} + func updateIsLoggedIn(_ userInfo: UserInfo?) -> Observable { return .just(.updateIsLoggedIn(userInfo != nil)) } diff --git a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift index 9a7688660..aa33f6369 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift @@ -43,8 +43,8 @@ public final class NoticeViewModel { entities[selectedIndexPath.row] } .do { entity in - //let savedIds: [Int] = Utility.PreferenceManager.readNoticeIDs ?? [] - //PreferenceManager.readNoticeIDs = savedIds.isEmpty ? [entity.id] : savedIds + [entity.id] + // let savedIds: [Int] = Utility.PreferenceManager.readNoticeIDs ?? [] + // PreferenceManager.readNoticeIDs = savedIds.isEmpty ? [entity.id] : savedIds + [entity.id] } .bind(to: output.goNoticeDetailScene) .disposed(by: disposeBag) From c25344a65d8dbf90554bdca0e7fbd58838d69872 Mon Sep 17 00:00:00 2001 From: youn9k Date: Thu, 27 Jun 2024 22:40:23 +0900 Subject: [PATCH 06/13] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#674]=20?= =?UTF-8?q?=EC=9E=98=EB=AA=BB=20=EC=88=98=EC=A0=95=ED=95=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9B=90=EC=83=81=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Components/MainTabBarComponent.swift | 4 ++-- .../Sources/ViewModels/MainTabBarViewModel.swift | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift b/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift index 786837746..46bad7c97 100644 --- a/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift +++ b/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift @@ -12,7 +12,7 @@ import StorageFeature import StorageFeatureInterface public protocol MainTabBarDependency: Dependency { - var fetchNoticeAllUseCase: any FetchNoticeAllUseCase { get } + var fetchNoticePopupUseCase: any FetchNoticePopupUseCase { get } var homeComponent: HomeComponent { get } var searchFactory: any SearchFactory { get } var artistComponent: ArtistComponent { get } @@ -27,7 +27,7 @@ public final class MainTabBarComponent: Component { public func makeView() -> MainTabBarViewController { return MainTabBarViewController.viewController( viewModel: MainTabBarViewModel.init( - fetchNoticeAllUseCase: self.dependency.fetchNoticeAllUseCase + fetchNoticePopupUseCase: self.dependency.fetchNoticePopupUseCase ), homeComponent: self.dependency.homeComponent, searchFactory: self.dependency.searchFactory, diff --git a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift index 6740ca87c..709411d87 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift @@ -5,13 +5,13 @@ import RxSwift import Utility public final class MainTabBarViewModel { - private let fetchNoticeAllUseCase: FetchNoticeAllUseCase + private let fetchNoticePopupUseCase: FetchNoticePopupUseCase private let disposeBag = DisposeBag() public init( - fetchNoticeAllUseCase: any FetchNoticeAllUseCase + fetchNoticePopupUseCase: any FetchNoticePopupUseCase ) { - self.fetchNoticeAllUseCase = fetchNoticeAllUseCase + self.fetchNoticePopupUseCase = fetchNoticePopupUseCase } public struct Input { @@ -28,8 +28,8 @@ public final class MainTabBarViewModel { DEBUG_LOG("ignoredPopupIDs: \(ignoredPopupIDs)") input.fetchNoticePopup - .flatMap { [fetchNoticeAllUseCase] _ -> Single<[FetchNoticeEntity]> in - return fetchNoticeAllUseCase.execute() + .flatMap { [fetchNoticePopupUseCase] _ -> Single<[FetchNoticeEntity]> in + return fetchNoticePopupUseCase.execute() .catchAndReturn([]) } .map { entities in From 0b6ce0f454df292ee4a6ff911f7821a1a14e7192 Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 09:33:09 +0900 Subject: [PATCH 07/13] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20[#674]=20?= =?UTF-8?q?=EB=AA=A8=EB=93=A0=20=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD?= =?UTF-8?q?=EC=9D=84=20=EC=9D=BD=EC=97=88=EB=8A=94=EC=A7=80=20=ED=8C=90?= =?UTF-8?q?=EB=B3=84=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/AppComponent+Notice.swift | 21 ++++++---- .../Sources/Components/MyInfoComponent.swift | 6 ++- .../Sources/Reactors/MyInfoReactor.swift | 38 ++++++++++++++----- .../MyInfo/MyInfoViewController.swift | 7 ++++ .../Sources/ViewModels/NoticeViewModel.swift | 4 +- .../Sources/Manager/PreferenceManager.swift | 4 ++ 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/Projects/App/Sources/Application/AppComponent+Notice.swift b/Projects/App/Sources/Application/AppComponent+Notice.swift index 958a546ae..739c7232c 100644 --- a/Projects/App/Sources/Application/AppComponent+Notice.swift +++ b/Projects/App/Sources/Application/AppComponent+Notice.swift @@ -1,11 +1,3 @@ -// -// AppComponent+Notice.swift -// WaktaverseMusic -// -// Created by KTH on 2023/04/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - import BaseFeature import MainTabFeature import MyInfoFeature @@ -44,10 +36,23 @@ public extension AppComponent { FetchNoticeAllUseCaseImpl(noticeRepository: noticeRepository) } } + + var fetchNoticePopupUseCase: any FetchNoticePopupUseCase { + shared { + FetchNoticePopupUseCaseImpl(noticeRepository: noticeRepository) + } + } var fetchNoticeCategoriesUseCase: any FetchNoticeCategoriesUseCase { shared { FetchNoticeCategoriesUseCaseImpl(noticeRepository: noticeRepository) } } + + var fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase { + shared { + FetchNoticeIDListUseCaseImpl(noticeRepository: noticeRepository) + } + + } } diff --git a/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift b/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift index 8a20d4e37..1ee04149c 100644 --- a/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift +++ b/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift @@ -3,6 +3,7 @@ import FruitDrawFeatureInterface import MyInfoFeatureInterface import NeedleFoundation import SignInFeatureInterface +import NoticeDomainInterface import UIKit public protocol MyInfoDependency: Dependency { @@ -16,12 +17,15 @@ public protocol MyInfoDependency: Dependency { var settingFactory: any SettingFactory { get } var profilePopComponent: ProfilePopComponent { get } var fruitDrawFactory: any FruitDrawFactory { get } + var fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase { get } } public final class MyInfoComponent: Component, MyInfoFactory { public func makeView() -> UIViewController { return MyInfoViewController.viewController( - reactor: MyInfoReactor(), + reactor: MyInfoReactor( + fetchNoticeIDListUseCase: dependency.fetchNoticeIDListUseCase + ), profilePopUpComponent: dependency.profilePopComponent, textPopUpFactory: dependency.textPopUpFactory, multiPurposePopUpFactory: dependency.multiPurposePopUpFactory, diff --git a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift index f7fae6ee2..065343b6f 100644 --- a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift +++ b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift @@ -4,6 +4,7 @@ import LogManager import ReactorKit import UserDomainInterface import Utility +import NoticeDomainInterface final class MyInfoReactor: Reactor { enum Action { @@ -51,11 +52,15 @@ final class MyInfoReactor: Reactor { @Pulse var profileImageDidTap: Bool? @Pulse var navigateType: NavigateType? } - + var initialState: State + private let fetchNoticeIDListUseCase : any FetchNoticeIDListUseCase private var disposeBag = DisposeBag() - init() { + init( + fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase + ) { + self.fetchNoticeIDListUseCase = fetchNoticeIDListUseCase self.initialState = .init( isLoggedIn: false, profileImage: "", @@ -64,6 +69,7 @@ final class MyInfoReactor: Reactor { isAllNoticesRead: false ) observeUserInfoChanges() + observeReadNoticeIdChanges() } func mutate(action: Action) -> Observable { @@ -94,6 +100,7 @@ final class MyInfoReactor: Reactor { updatePlatform(userInfo) ) case let .changeReadNoticeIDs(readIDs): + return updateIsAllNoticesRead(readIDs) } } @@ -120,6 +127,9 @@ final class MyInfoReactor: Reactor { case let .updatePlatform(platform): newState.platform = platform + + case let .updateIsAllNoticesRead(isAllNoticesRead): + newState.isAllNoticesRead = isAllNoticesRead } return newState } @@ -135,15 +145,25 @@ private extension MyInfoReactor { } func observeReadNoticeIdChanges() { -// PreferenceManager.$readNoticeIDs -// .compactMap { $0 } -// .bind(with: self) { owner, readIDs in -// owner.action.onNext(.changeReadNoticeIDs(readIDs)) -// } -// .disposed(by: disposeBag) + PreferenceManager.$ignoredPopupIDs + .map { $0 ?? [] } + .bind(with: self) { owner, readIDs in + owner.action.onNext(.changeReadNoticeIDs(readIDs)) + } + .disposed(by: disposeBag) } - func updateIsAllNoticesRead(_ readIDs: [Int]) -> Observable {} + func updateIsAllNoticesRead(_ readIDs: [Int]) -> Observable { + return fetchNoticeIDListUseCase.execute() + .catchAndReturn(FetchNoticeIDListEntity(status: "404", data: [])) + .asObservable() + .map { + let readIDsSet = Set(readIDs) + let allNoticeIDsSet = Set($0.data) + return allNoticeIDsSet.isSubset(of: readIDsSet) + } + .map { Mutation.updateIsAllNoticesRead($0) } + } func updateIsLoggedIn(_ userInfo: UserInfo?) -> Observable { return .just(.updateIsLoggedIn(userInfo != nil)) diff --git a/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift b/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift index 1327be8ff..6b847a89d 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift @@ -74,6 +74,13 @@ final class MyInfoViewController: BaseReactorViewController, Edit } override func bindState(reactor: MyInfoReactor) { + reactor.state.map(\.isAllNoticesRead) + .distinctUntilChanged() + .bind(with: self) { owner, isAllNoticesRead in + owner.myInfoView.newNotiIndicator.isHidden = isAllNoticesRead + } + .disposed(by: disposeBag) + reactor.state.map(\.isLoggedIn) .distinctUntilChanged() .bind(with: self) { owner, isLoggedIn in diff --git a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift index aa33f6369..d7f55b71d 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift @@ -43,8 +43,8 @@ public final class NoticeViewModel { entities[selectedIndexPath.row] } .do { entity in - // let savedIds: [Int] = Utility.PreferenceManager.readNoticeIDs ?? [] - // PreferenceManager.readNoticeIDs = savedIds.isEmpty ? [entity.id] : savedIds + [entity.id] + let savedIds: [Int] = Utility.PreferenceManager.readNoticeIDs ?? [] + PreferenceManager.readNoticeIDs = savedIds.isEmpty ? [entity.id] : savedIds + [entity.id] } .bind(to: output.goNoticeDetailScene) .disposed(by: disposeBag) diff --git a/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift b/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift index 3634f2f72..cc030681a 100644 --- a/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift +++ b/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift @@ -20,6 +20,7 @@ public final class PreferenceManager { case startPage // 시작 페이지(탭) case appPermissionChecked // 앱 권한팝업 승인 case ignoredPopupIDs // 다시보지 않는 팝업 IDs + case readNoticeIDs // 이미 읽은 공지 IDs } @UserDefaultWrapper(key: Constants.recentRecords.rawValue, defaultValue: nil) @@ -36,6 +37,9 @@ public final class PreferenceManager { @UserDefaultWrapper(key: Constants.ignoredPopupIDs.rawValue, defaultValue: nil) public static var ignoredPopupIDs: [Int]? + + @UserDefaultWrapper(key: Constants.readNoticeIDs.rawValue, defaultValue: nil) + public static var readNoticeIDs: [Int]? } @propertyWrapper From 4a26eb97e689291959b18de297d73a7a0171a080 Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 09:34:15 +0900 Subject: [PATCH 08/13] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#674]=20?= =?UTF-8?q?=EC=95=A1=EC=85=98=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Reactors/MyInfoReactor.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift index 065343b6f..1de0a2244 100644 --- a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift +++ b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift @@ -17,8 +17,8 @@ final class MyInfoReactor: Reactor { case mailNavigationDidTap case teamNavigationDidTap case settingNavigationDidTap - case changeUserInfo(UserInfo?) - case changeReadNoticeIDs([Int]) + case changedUserInfo(UserInfo?) + case changedReadNoticeIDs([Int]) } enum Mutation { @@ -92,14 +92,14 @@ final class MyInfoReactor: Reactor { return teamNavigationDidTap() case .settingNavigationDidTap: return settingNavigationDidTap() - case let .changeUserInfo(userInfo): + case let .changedUserInfo(userInfo): return .concat( updateIsLoggedIn(userInfo), updateProfileImage(userInfo), updateNickname(userInfo), updatePlatform(userInfo) ) - case let .changeReadNoticeIDs(readIDs): + case let .changedReadNoticeIDs(readIDs): return updateIsAllNoticesRead(readIDs) } } @@ -139,7 +139,7 @@ private extension MyInfoReactor { func observeUserInfoChanges() { PreferenceManager.$userInfo .bind(with: self) { owner, userInfo in - owner.action.onNext(.changeUserInfo(userInfo)) + owner.action.onNext(.changedUserInfo(userInfo)) } .disposed(by: disposeBag) } @@ -148,7 +148,7 @@ private extension MyInfoReactor { PreferenceManager.$ignoredPopupIDs .map { $0 ?? [] } .bind(with: self) { owner, readIDs in - owner.action.onNext(.changeReadNoticeIDs(readIDs)) + owner.action.onNext(.changedReadNoticeIDs(readIDs)) } .disposed(by: disposeBag) } From d6741769c1f2ec52704e51d24c6aba58abb84480 Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 09:34:19 +0900 Subject: [PATCH 09/13] =?UTF-8?q?=F0=9F=8E=A8=20::=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?Formatting=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../App/Sources/Application/AppComponent+Notice.swift | 5 ++--- .../Sources/Components/MyInfoComponent.swift | 2 +- .../MyInfoFeature/Sources/Reactors/MyInfoReactor.swift | 8 ++++---- .../ViewControllers/MyInfo/MyInfoViewController.swift | 2 +- .../Utility/Sources/Manager/PreferenceManager.swift | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Projects/App/Sources/Application/AppComponent+Notice.swift b/Projects/App/Sources/Application/AppComponent+Notice.swift index 739c7232c..3a4b64c28 100644 --- a/Projects/App/Sources/Application/AppComponent+Notice.swift +++ b/Projects/App/Sources/Application/AppComponent+Notice.swift @@ -36,7 +36,7 @@ public extension AppComponent { FetchNoticeAllUseCaseImpl(noticeRepository: noticeRepository) } } - + var fetchNoticePopupUseCase: any FetchNoticePopupUseCase { shared { FetchNoticePopupUseCaseImpl(noticeRepository: noticeRepository) @@ -48,11 +48,10 @@ public extension AppComponent { FetchNoticeCategoriesUseCaseImpl(noticeRepository: noticeRepository) } } - + var fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase { shared { FetchNoticeIDListUseCaseImpl(noticeRepository: noticeRepository) } - } } diff --git a/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift b/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift index 1ee04149c..b5297fc08 100644 --- a/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift +++ b/Projects/Features/MyInfoFeature/Sources/Components/MyInfoComponent.swift @@ -2,8 +2,8 @@ import BaseFeatureInterface import FruitDrawFeatureInterface import MyInfoFeatureInterface import NeedleFoundation -import SignInFeatureInterface import NoticeDomainInterface +import SignInFeatureInterface import UIKit public protocol MyInfoDependency: Dependency { diff --git a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift index 1de0a2244..dc74fc11c 100644 --- a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift +++ b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift @@ -1,10 +1,10 @@ import BaseFeature import Foundation import LogManager +import NoticeDomainInterface import ReactorKit import UserDomainInterface import Utility -import NoticeDomainInterface final class MyInfoReactor: Reactor { enum Action { @@ -52,9 +52,9 @@ final class MyInfoReactor: Reactor { @Pulse var profileImageDidTap: Bool? @Pulse var navigateType: NavigateType? } - + var initialState: State - private let fetchNoticeIDListUseCase : any FetchNoticeIDListUseCase + private let fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase private var disposeBag = DisposeBag() init( @@ -127,7 +127,7 @@ final class MyInfoReactor: Reactor { case let .updatePlatform(platform): newState.platform = platform - + case let .updateIsAllNoticesRead(isAllNoticesRead): newState.isAllNoticesRead = isAllNoticesRead } diff --git a/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift b/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift index 6b847a89d..7bf0755f1 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewControllers/MyInfo/MyInfoViewController.swift @@ -80,7 +80,7 @@ final class MyInfoViewController: BaseReactorViewController, Edit owner.myInfoView.newNotiIndicator.isHidden = isAllNoticesRead } .disposed(by: disposeBag) - + reactor.state.map(\.isLoggedIn) .distinctUntilChanged() .bind(with: self) { owner, isLoggedIn in diff --git a/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift b/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift index cc030681a..b58814bdc 100644 --- a/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift +++ b/Projects/Modules/Utility/Sources/Manager/PreferenceManager.swift @@ -37,7 +37,7 @@ public final class PreferenceManager { @UserDefaultWrapper(key: Constants.ignoredPopupIDs.rawValue, defaultValue: nil) public static var ignoredPopupIDs: [Int]? - + @UserDefaultWrapper(key: Constants.readNoticeIDs.rawValue, defaultValue: nil) public static var readNoticeIDs: [Int]? } From 4f5628133ebadb8936f802a5441f91641be82bb2 Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 17:49:14 +0900 Subject: [PATCH 10/13] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20[#674]=20?= =?UTF-8?q?=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20=ED=8C=90=EB=B3=84=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 앱 실행 시 최초 로그인이면(유저디폴트가 비어있음), 모두 읽음 처리하고 다음 부터 빨간 점 띄움 --- .../Components/MainTabBarComponent.swift | 4 +++- .../MainTabBarViewController.swift | 1 + .../ViewModels/MainTabBarViewModel.swift | 21 ++++++++++++++++++- .../Sources/Reactors/MyInfoReactor.swift | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift b/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift index 46bad7c97..1a04dd764 100644 --- a/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift +++ b/Projects/Features/MainTabFeature/Sources/Components/MainTabBarComponent.swift @@ -13,6 +13,7 @@ import StorageFeatureInterface public protocol MainTabBarDependency: Dependency { var fetchNoticePopupUseCase: any FetchNoticePopupUseCase { get } + var fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase { get } var homeComponent: HomeComponent { get } var searchFactory: any SearchFactory { get } var artistComponent: ArtistComponent { get } @@ -27,7 +28,8 @@ public final class MainTabBarComponent: Component { public func makeView() -> MainTabBarViewController { return MainTabBarViewController.viewController( viewModel: MainTabBarViewModel.init( - fetchNoticePopupUseCase: self.dependency.fetchNoticePopupUseCase + fetchNoticePopupUseCase: self.dependency.fetchNoticePopupUseCase, + fetchNoticeIDListUseCase: self.dependency.fetchNoticeIDListUseCase ), homeComponent: self.dependency.homeComponent, searchFactory: self.dependency.searchFactory, diff --git a/Projects/Features/MainTabFeature/Sources/ViewControllers/MainTabBarViewController.swift b/Projects/Features/MainTabFeature/Sources/ViewControllers/MainTabBarViewController.swift index c712a0369..8804a8d3b 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewControllers/MainTabBarViewController.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewControllers/MainTabBarViewController.swift @@ -91,6 +91,7 @@ public final class MainTabBarViewController: BaseViewController, ViewControllerF private extension MainTabBarViewController { func inputBind() { input.fetchNoticePopup.onNext(()) + input.fetchNoticeIDList.onNext(()) } func outputBind() { diff --git a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift index 709411d87..9c9dc51a9 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift @@ -6,16 +6,20 @@ import Utility public final class MainTabBarViewModel { private let fetchNoticePopupUseCase: FetchNoticePopupUseCase + private let fetchNoticeIDListUseCase: FetchNoticeIDListUseCase private let disposeBag = DisposeBag() public init( - fetchNoticePopupUseCase: any FetchNoticePopupUseCase + fetchNoticePopupUseCase: any FetchNoticePopupUseCase, + fetchNoticeIDListUseCase: any FetchNoticeIDListUseCase ) { self.fetchNoticePopupUseCase = fetchNoticePopupUseCase + self.fetchNoticeIDListUseCase = fetchNoticeIDListUseCase } public struct Input { let fetchNoticePopup: PublishSubject = PublishSubject() + let fetchNoticeIDList: PublishSubject = PublishSubject() } public struct Output { @@ -42,6 +46,21 @@ public final class MainTabBarViewModel { .bind(to: output.dataSource) .disposed(by: disposeBag) + input.fetchNoticeIDList + .filter { + let readNoticeIDs = PreferenceManager.readNoticeIDs ?? [] + return readNoticeIDs.isEmpty + } + .flatMap { [fetchNoticeIDListUseCase] _ -> Single in + return fetchNoticeIDListUseCase.execute() + .catchAndReturn(FetchNoticeIDListEntity(status: "404", data: [])) + } + .map { $0.data } + .bind { allNoticeIDs in + PreferenceManager.readNoticeIDs = allNoticeIDs + } + .disposed(by: disposeBag) + return output } } diff --git a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift index dc74fc11c..0d39e8808 100644 --- a/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift +++ b/Projects/Features/MyInfoFeature/Sources/Reactors/MyInfoReactor.swift @@ -145,7 +145,7 @@ private extension MyInfoReactor { } func observeReadNoticeIdChanges() { - PreferenceManager.$ignoredPopupIDs + PreferenceManager.$readNoticeIDs .map { $0 ?? [] } .bind(with: self) { owner, readIDs in owner.action.onNext(.changedReadNoticeIDs(readIDs)) From fe499fa12bb11384fe78e469d333efe0b9638add Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 17:49:23 +0900 Subject: [PATCH 11/13] =?UTF-8?q?=F0=9F=8E=A8=20::=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?Formatting=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ViewModels/MainTabBarViewModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift index 9c9dc51a9..7b1dfc976 100644 --- a/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift +++ b/Projects/Features/MainTabFeature/Sources/ViewModels/MainTabBarViewModel.swift @@ -47,7 +47,7 @@ public final class MainTabBarViewModel { .disposed(by: disposeBag) input.fetchNoticeIDList - .filter { + .filter { let readNoticeIDs = PreferenceManager.readNoticeIDs ?? [] return readNoticeIDs.isEmpty } @@ -60,7 +60,7 @@ public final class MainTabBarViewModel { PreferenceManager.readNoticeIDs = allNoticeIDs } .disposed(by: disposeBag) - + return output } } From 7438e06950ef5b9d3473e0e681406ca333999e15 Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 17:58:33 +0900 Subject: [PATCH 12/13] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20[#674]=20?= =?UTF-8?q?=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20=EC=9D=BD=EC=9D=8C=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ViewModels/NoticeDetailViewModel.swift | 7 +++++++ .../MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift index ca91c34c7..ad91c1724 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift @@ -17,6 +17,7 @@ public final class NoticeDetailViewModel { public init(model: FetchNoticeEntity) { self.model = model + readNotice(ID: self.model.id) } public struct Input { @@ -61,6 +62,12 @@ public final class NoticeDetailViewModel { } private extension NoticeDetailViewModel { + func readNotice(ID: Int) { + var newReadNoticeIDs = PreferenceManager.readNoticeIDs ?? [] + newReadNoticeIDs.append(ID) + PreferenceManager.readNoticeIDs = newReadNoticeIDs + } + func downloadImageSize(url: URL) -> Observable { return Observable.create { observer in KingfisherManager.shared.retrieveImage( diff --git a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift index d7f55b71d..f14ca1392 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeViewModel.swift @@ -42,10 +42,6 @@ public final class NoticeViewModel { .map { selectedIndexPath, entities in entities[selectedIndexPath.row] } - .do { entity in - let savedIds: [Int] = Utility.PreferenceManager.readNoticeIDs ?? [] - PreferenceManager.readNoticeIDs = savedIds.isEmpty ? [entity.id] : savedIds + [entity.id] - } .bind(to: output.goNoticeDetailScene) .disposed(by: disposeBag) From fed9ce0239dbe025664774be8ae89497852a29b0 Mon Sep 17 00:00:00 2001 From: youn9k Date: Fri, 28 Jun 2024 17:58:36 +0900 Subject: [PATCH 13/13] =?UTF-8?q?=F0=9F=8E=A8=20::=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?Formatting=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ViewModels/NoticeDetailViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift index ad91c1724..74b7c9935 100644 --- a/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift +++ b/Projects/Features/MyInfoFeature/Sources/ViewModels/NoticeDetailViewModel.swift @@ -67,7 +67,7 @@ private extension NoticeDetailViewModel { newReadNoticeIDs.append(ID) PreferenceManager.readNoticeIDs = newReadNoticeIDs } - + func downloadImageSize(url: URL) -> Observable { return Observable.create { observer in KingfisherManager.shared.retrieveImage(