Skip to content

Commit

Permalink
[Fix] #244 - Mypage Manaer 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Mar 21, 2024
1 parent fb48362 commit 4f4f7aa
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protocol HomeFlowControllerFactory {

protocol MyPageFlowControllerFactory {
func makeMyInfoViewController(coordinator: MypageCoordinator) -> MyPageViewController
func makeMyInfoAccountViewController(coordinator: MypageCoordinator) -> MyInfoAccountViewController
func makeMyInfoAccountViewController(coordinator: MypageCoordinator) -> MyPageAccountViewController
func makeWithdrawViewController(coordinator: MypageCoordinator) -> NottodoModalViewController
}

Expand Down Expand Up @@ -192,16 +192,19 @@ extension ViewControllerFactoryImpl {
return viewController
}

func makeMyInfoAccountViewController(coordinator: MypageCoordinator) -> MyInfoAccountViewController {
func makeMyInfoAccountViewController(coordinator: MypageCoordinator) -> MyPageAccountViewController {
let authAPI = DefaultAuthService()
let manager = MyPageManagerImpl(authAPI: authAPI)
let viewModel = MyPageAccountViewModelImpl(coordinator: coordinator, manager: manager)
let viewController = MyInfoAccountViewController(viewModel: viewModel)
let viewController = MyPageAccountViewController(viewModel: viewModel)
return viewController
}

func makeWithdrawViewController(coordinator: MypageCoordinator) -> NottodoModalViewController {
let viewController = NottodoModalViewController(coordinator: coordinator)
let authAPI = DefaultAuthService()
let manager = MyPageManagerImpl(authAPI: authAPI)
let viewModel = ModalViewModelImpl(coordinator: coordinator, manager: manager)
let viewController = NottodoModalViewController(viewModel: viewModel)
return viewController
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Foundation
import Combine

protocol MyPageManger {
func logout() -> AnyPublisher<Int, Error>
func withdrawl() -> AnyPublisher<Int, Error>
func logout() -> AnyPublisher<Void, Error>
func withdrawl() -> AnyPublisher<Void, Error>
func kakaoLogout()
func kakaoWithdrawal()
}
34 changes: 32 additions & 2 deletions iOS-NOTTODO/iOS-NOTTODO/Network/Manager/MyPageManagerImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import Foundation
import Combine

import KakaoSDKUser

final class MyPageManagerImpl: MyPageManger {

private let authAPI: AuthServiceProtocol
Expand All @@ -17,13 +19,41 @@ final class MyPageManagerImpl: MyPageManger {
self.authAPI = authAPI
}

func logout() -> AnyPublisher<Int, Error> {
func logout() -> AnyPublisher<Void, Error> {
authAPI.logout()
.map { [weak self] _ in
self?.kakaoLogout()
}
.eraseToAnyPublisher()
}

func withdrawl() -> AnyPublisher<Int, Error> {
func withdrawl() -> AnyPublisher<Void, Error> {
authAPI.withdrawal()
.map { [weak self] _ in
if !KeychainUtil.getBool(DefaultKeys.isAppleLogin) {
self?.kakaoWithdrawal()
}
}
.eraseToAnyPublisher()
}

func kakaoLogout() {
UserApi.shared.logout {(error) in
if let error = error {
print(error)
} else {
print("logout() success.")
}
}
}

func kakaoWithdrawal() {
UserApi.shared.unlink {(error) in
if let error = error {
print(error)
} else {
print("unlink() success.")
}
}
}
}

0 comments on commit 4f4f7aa

Please sign in to comment.