인증 완료 후 동작 실행
This commit is contained in:
@@ -14,6 +14,8 @@ struct ChatTabView: View {
|
||||
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
|
||||
@AppStorage("auth") private var auth: Bool = UserDefaults.bool(forKey: UserDefaultsKey.auth)
|
||||
|
||||
@StateObject var mypageViewModel = MyPageViewModel()
|
||||
|
||||
private enum InnerTab: Int, CaseIterable {
|
||||
case character = 0
|
||||
case original = 1
|
||||
@@ -153,12 +155,15 @@ struct ChatTabView: View {
|
||||
AppState.shared.isShowErrorPopup = true
|
||||
isShowAuthView = false
|
||||
}
|
||||
.onDone { _ in
|
||||
auth = true
|
||||
isShowAuthView = false
|
||||
if let action = pendingAction {
|
||||
pendingAction = nil
|
||||
action()
|
||||
.onDone {
|
||||
DEBUG_LOG("onDone: \($0)")
|
||||
mypageViewModel.authVerify($0) {
|
||||
auth = true
|
||||
isShowAuthView = false
|
||||
if let action = pendingAction {
|
||||
pendingAction = nil
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
.onClose {
|
||||
|
||||
@@ -12,6 +12,7 @@ import BootpayUI
|
||||
struct HomeTabView: View {
|
||||
@StateObject var viewModel = HomeTabViewModel()
|
||||
@StateObject var liveViewModel = LiveViewModel()
|
||||
@StateObject var mypageViewModel = MyPageViewModel()
|
||||
|
||||
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
|
||||
@AppStorage("role") private var role: String = UserDefaults.string(forKey: UserDefaultsKey.role)
|
||||
@@ -460,12 +461,15 @@ struct HomeTabView: View {
|
||||
AppState.shared.isShowErrorPopup = true
|
||||
isShowAuthView = false
|
||||
}
|
||||
.onDone { _ in
|
||||
auth = true
|
||||
isShowAuthView = false
|
||||
if let action = pendingAction {
|
||||
pendingAction = nil
|
||||
action()
|
||||
.onDone {
|
||||
DEBUG_LOG("onDone: \($0)")
|
||||
mypageViewModel.authVerify($0) {
|
||||
auth = true
|
||||
isShowAuthView = false
|
||||
if let action = pendingAction {
|
||||
pendingAction = nil
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
.onClose {
|
||||
|
||||
@@ -72,7 +72,7 @@ final class MyPageViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func authVerify(_ data: [String: Any]) {
|
||||
func authVerify(_ data: [String: Any], onSuccess: (() -> Void)? = nil) {
|
||||
isLoading = true
|
||||
|
||||
let _data = data["data"] as? [String: Any]
|
||||
@@ -102,8 +102,13 @@ final class MyPageViewModel: ObservableObject {
|
||||
} else {
|
||||
UserDefaults.set(ContentType.MALE.rawValue, forKey: .contentPreference)
|
||||
}
|
||||
AppState.shared.isRestartApp = true
|
||||
AppState.shared.setAppStep(step: .splash)
|
||||
|
||||
if let onSuccess = onSuccess {
|
||||
onSuccess()
|
||||
} else {
|
||||
AppState.shared.isRestartApp = true
|
||||
AppState.shared.setAppStep(step: .splash)
|
||||
}
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
|
||||
Reference in New Issue
Block a user