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