ios: fix showing init view (#2477)

* ios: fix showing init view

* init with delay

---------

Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
This commit is contained in:
Evgeny Poberezkin
2023-05-22 15:49:46 +02:00
committed by GitHub
parent 579af09816
commit 9a2efd0ef0
2 changed files with 13 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ struct ContentView: View {
@Binding var userAuthorized: Bool?
@Binding var canConnectCall: Bool
@Binding var lastSuccessfulUnlock: TimeInterval?
@Binding var showInitializationView: Bool
@AppStorage(DEFAULT_SHOW_LA_NOTICE) private var prefShowLANotice = false
@AppStorage(DEFAULT_LA_NOTICE_SHOWN) private var prefLANoticeShown = false
@AppStorage(DEFAULT_PERFORM_LA) private var prefPerformLA = false
@@ -27,7 +28,6 @@ struct ContentView: View {
@State private var showWhatsNew = false
@State private var showChooseLAMode = false
@State private var showSetPasscode = false
@State private var showInitializationView = false
var body: some View {
ZStack {
@@ -53,9 +53,6 @@ struct ContentView: View {
.onAppear {
if prefPerformLA { requestNtfAuthorization() }
initAuthenticate()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
showInitializationView = true
}
}
.onChange(of: doAuthenticate) { _ in
initAuthenticate()

View File

@@ -23,6 +23,7 @@ struct SimpleXApp: App {
@State private var enteredBackground: TimeInterval? = nil
@State private var canConnectCall = false
@State private var lastSuccessfulUnlock: TimeInterval? = nil
@State private var showInitializationView = false
init() {
hs_init(0, nil)
@@ -36,14 +37,23 @@ struct SimpleXApp: App {
var body: some Scene {
return WindowGroup {
ContentView(doAuthenticate: $doAuthenticate, userAuthorized: $userAuthorized, canConnectCall: $canConnectCall, lastSuccessfulUnlock: $lastSuccessfulUnlock)
ContentView(
doAuthenticate: $doAuthenticate,
userAuthorized: $userAuthorized,
canConnectCall: $canConnectCall,
lastSuccessfulUnlock: $lastSuccessfulUnlock,
showInitializationView: $showInitializationView
)
.environmentObject(chatModel)
.onOpenURL { url in
logger.debug("ContentView.onOpenURL: \(url)")
chatModel.appOpenUrl = url
}
.onAppear() {
initChatAndMigrate()
showInitializationView = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
initChatAndMigrate()
}
}
.onChange(of: scenePhase) { phase in
logger.debug("scenePhase was \(String(describing: scenePhase)), now \(String(describing: phase))")