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

[Fix] #399 - deprecated API 반영 및 가입 일자 계산 로직 수정 #401

Merged
merged 11 commits into from
Oct 16, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public extension Date {
dateComponents.year = year
dateComponents.month = month
dateComponents.day = day
return calendar.date(from: dateComponents) ?? nil

let usaDate = calendar.date(from: dateComponents)
return usaDate!.addingTimeInterval(10 * 60 * 60)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 9시간이 아닌 10시간을 더하신 이유가 궁금해요!

  2. TimeZone.current로 설정하면 한국날짜(UTC +9)로 지정되는 것으로 알고 있는데,
    해당 데이터에 추가적으로 9시간 혹은 10시간을 더하면 (UTC +18)이 되는 건 아니겠죠,,?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 10시간은 제가 이것저것 해보다가 그대로 올린 것 같습니다ㅎㅎ 수정하겠습니다!
  2. calendar.date 함수의 반환값이 Date 객체인데, Date 객체는 항상 UTC 기준으로 생성된다고 해요. Date의 시간대를 변경하려면 DateFormatter를 사용해야하는데 DateFormatter를 사용하는 것보다 시간을 더해주는 것이 오버헤드가 더 적어 기존 방법을 유지하는 것을 좋을 듯 합니다 !

덕분에 새로이 알고 갑니다!_!👍

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ extension AppMyPageRepository: AppMyPageRepositoryInterface {
.asDriver()
}

public func getNotificationIsAllowed() -> Driver<Bool> {
self.userService
.getNotificationIsAllowed()
.map(\.isOptIn)
.asDriver()
}

public func optInPushNotificationInGeneral(to isOn: Bool) -> Driver<Bool> {
self.userService
.optInPushNotificationInGeneral(to: isOn)
.map(\.isOptIn)
.asDriver()
}

public func deregisterPushToken(with token: String) -> AnyPublisher<Bool, Error> {
self.userService.deregisterPushToken(with: token)
.map {
Expand Down
14 changes: 1 addition & 13 deletions SOPT-iOS/Projects/Data/Sources/Repository/MainRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import Networks
public class MainRepository {

private let userService: UserService
private let configService: ConfigService
private let descriptionService: DescriptionService
private let pokeService: PokeService

private let cancelBag = CancelBag()

public init(userService: UserService, configService: ConfigService, descriptionService: DescriptionService, pokeService: PokeService) {
public init(userService: UserService, descriptionService: DescriptionService, pokeService: PokeService) {
self.userService = userService
self.configService = configService
self.descriptionService = descriptionService
self.pokeService = pokeService
}
Expand Down Expand Up @@ -53,16 +51,6 @@ extension MainRepository: MainRepositoryInterface {
.eraseToAnyPublisher()
}

public func getServiceState() -> AnyPublisher<ServiceStateModel, MainError> {
configService.getServiceAvailability()
.mapError { error in
print(error)
return MainError.networkError(message: "GetServiceState 에러")
}
.map { $0.toDomain() }
.eraseToAnyPublisher()
}

public func getMainViewDescription() -> AnyPublisher<MainDescriptionModel, MainError> {
descriptionService.getMainViewDescription()
.mapError { error in
Expand Down
11 changes: 0 additions & 11 deletions SOPT-iOS/Projects/Data/Sources/Repository/SettingRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ extension SettingRepository: SettingRepositoryInterface {
.eraseToAnyPublisher()
}

public func editNickname(nickname: String) -> AnyPublisher<Bool, Never> {
return userService.changeNickname(nickname: nickname)
.map { _ in true }
.replaceError(with: false)
.handleEvents(receiveOutput: { isSuccessed in
guard isSuccessed else { return }
UserDefaultKeyList.User.soptampName = nickname
})
.eraseToAnyPublisher()
}

public func withdrawal() -> AnyPublisher<Bool, Never> {
return userService.withdraw()
.handleEvents(receiveOutput: { status in
Expand Down
31 changes: 0 additions & 31 deletions SOPT-iOS/Projects/Data/Sources/Repository/SignUpRepository.swift

This file was deleted.

6 changes: 0 additions & 6 deletions SOPT-iOS/Projects/Data/Sources/Transform/MainTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ extension MainEntity {
return UserMainInfoModel.init(status: user.status, name: user.name, profileImage: user.profileImage, historyList: user.historyList, attendanceScore: operation?.attendanceScore, announcement: operation?.announcement, isAllConfirm: isAllConfirm)
}
}

extension ServiceStateEntity {
public func toDomain() -> ServiceStateModel {
return ServiceStateModel(isAvailable: isAvailable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ extension AppDelegate {
implement: {
MainRepository(
userService: DefaultUserService(),
configService: DefaultConfigService(),
descriptionService: DefaultDescriptionService(),
pokeService: DefaultPokeService()
)
Expand Down Expand Up @@ -79,14 +78,6 @@ extension AppDelegate {
)
}
)
container.register(
interface: SignUpRepositoryInterface.self,
implement: {
SignUpRepository(
service: DefaultUserService()
)
}
)
container.register(
interface: MissionListRepositoryInterface.self,
implement: {
Expand Down
17 changes: 0 additions & 17 deletions SOPT-iOS/Projects/Domain/Sources/Model/ServiceStateModel.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ import Core

public protocol AppMyPageRepositoryInterface {
func resetStamp() -> Driver<Bool>
func getNotificationIsAllowed() -> Driver<Bool>
func optInPushNotificationInGeneral(to isOn: Bool) -> Driver<Bool>
func deregisterPushToken(with token: String) -> AnyPublisher<Bool, Error>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Combine

public protocol MainRepositoryInterface {
func getUserMainInfo() -> AnyPublisher<UserMainInfoModel?, MainError>
func getServiceState() -> AnyPublisher<ServiceStateModel, MainError>
func getMainViewDescription() -> AnyPublisher<MainDescriptionModel, MainError>
func registerPushToken(with token: String) -> AnyPublisher<Bool, Error>
func checkPokeNewUser() -> AnyPublisher<Bool, Error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ import Combine
public protocol SettingRepositoryInterface {
func resetStamp() -> Driver<Bool>
func editSentence(sentence: String) -> AnyPublisher<Bool, Never>
func editNickname(nickname: String) -> AnyPublisher<Bool, Never>
func withdrawal() -> AnyPublisher<Bool, Never>
}

This file was deleted.

18 changes: 0 additions & 18 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/AppMyPageUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import Combine

public protocol AppMyPageUseCase {
func resetStamp()
func fetchUserNotificationIsAllowed()
func optInPushNotificationInGeneral(to isOn: Bool)
func deregisterPushToken()

var resetSuccess: PassthroughSubject<Bool, Error> { get }
Expand Down Expand Up @@ -46,22 +44,6 @@ extension DefaultAppMyPageUseCase: AppMyPageUseCase {
}.store(in: self.cancelBag)
}

public func fetchUserNotificationIsAllowed() {
self.repository
.getNotificationIsAllowed()
.sink { isAllowed in
self.originUserNotificationIsAllowedStatus.send(isAllowed)
}.store(in: self.cancelBag)
}

public func optInPushNotificationInGeneral(to isOn: Bool) {
self.repository
.optInPushNotificationInGeneral(to: isOn)
.sink { isOn in
self.optInPushNotificationResult.send(isOn)
}.store(in: self.cancelBag)
}

public func deregisterPushToken() {
guard let pushToken = UserDefaultKeyList.User.pushToken, !pushToken.isEmpty else { return }

Expand Down
15 changes: 0 additions & 15 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/MainUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import Combine

public protocol MainUseCase {
var userMainInfo: PassthroughSubject<UserMainInfoModel?, Never> { get set }
var serviceState: PassthroughSubject<ServiceStateModel, Never> { get set }
var mainDescription: PassthroughSubject<MainDescriptionModel, Never> { get set }
var mainErrorOccurred: PassthroughSubject<MainError, Never> { get set }
var isPokeNewUser: PassthroughSubject<Bool, Never> { get set }
var appService: PassthroughSubject<[AppServiceModel], Never> { get set }
var hotBoard: PassthroughSubject<HotBoardModel, Never> { get set }

func getUserMainInfo()
func getServiceState()
func getMainViewDescription()
func registerPushToken()
func checkPokeNewUser()
Expand All @@ -34,7 +32,6 @@ public class DefaultMainUseCase {
private var cancelBag = CancelBag()

public var userMainInfo = PassthroughSubject<UserMainInfoModel?, Never>()
public var serviceState = PassthroughSubject<ServiceStateModel, Never>()
public var mainDescription = PassthroughSubject<MainDescriptionModel, Never>()
public var mainErrorOccurred = PassthroughSubject<MainError, Never>()
public var isPokeNewUser = PassthroughSubject<Bool, Never>()
Expand All @@ -61,18 +58,6 @@ extension DefaultMainUseCase: MainUseCase {
}.store(in: self.cancelBag)
}

public func getServiceState() {
repository.getServiceState()
.sink { [weak self] event in
print("MainUseCase getServiceState: \(event)")
if case Subscribers.Completion.failure = event {
self?.mainErrorOccurred.send(.networkError(message: "GetServiceState 실패"))
}
} receiveValue: { [weak self] serviceStateModel in
self?.serviceState.send(serviceStateModel)
}.store(in: self.cancelBag)
}

public func getMainViewDescription() {
repository.getMainViewDescription()
.replaceError(with: .defaultDescription)
Expand Down
11 changes: 0 additions & 11 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/SettingUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import Core

public protocol SettingUseCase {
func resetStamp()
func editNickname(nickname: String)
func withdrawal()
var editNicknameSuccess: PassthroughSubject<Bool, Error> { get set }
var resetSuccess: PassthroughSubject<Bool, Error> { get set }
var withdrawalSuccess: PassthroughSubject<Bool, Error> { get set }
}
Expand All @@ -25,7 +23,6 @@ public class DefaultSettingUseCase {
private var cancelBag = CancelBag()

public var resetSuccess = PassthroughSubject<Bool, Error>()
public var editNicknameSuccess = PassthroughSubject<Bool, Error>()
public var withdrawalSuccess = PassthroughSubject<Bool, Error>()

public init(repository: SettingRepositoryInterface) {
Expand All @@ -42,14 +39,6 @@ extension DefaultSettingUseCase: SettingUseCase {
}.store(in: self.cancelBag)
}

public func editNickname(nickname: String) {
self.repository.editNickname(nickname: nickname)
.withUnretained(self)
.sink { owner, editSuccessed in
owner.editNicknameSuccess.send(editSuccessed)
}.store(in: self.cancelBag)
}

public func resetStamp() {
repository.resetStamp()
.sink { success in
Expand Down
55 changes: 0 additions & 55 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/SignUpUseCase.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Domain
final class MockMainRepository: MainRepositoryInterface {

var userInfoModelResponse: Result<UserMainInfoModel?, MainError>!
var serviceStateModelResponse: Result<ServiceStateModel, MainError>!

private(set) var cancelBag = CancelBag()

Expand All @@ -33,19 +32,4 @@ final class MockMainRepository: MainRepositoryInterface {
}
.eraseToAnyPublisher()
}

func getServiceState() -> AnyPublisher<Domain.ServiceStateModel, Domain.MainError> {
return Future { [weak self] promise in
guard let self = self else { return }
switch self.serviceStateModelResponse {
case .success(let model):
promise(.success(model))
case .failure(let error):
promise(.failure(error))
case .none:
XCTFail("Should Set serviceStateModelResponse")
}
}
.eraseToAnyPublisher()
}
}
Loading