mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-27 22:34:51 +00:00
mobile: onboarding (#618)
* mobile: onboarding * ios onboarding: create profile and make connection * how SimpleX works * connect via link * remove separate view for connecting via link, fix bugs * remove unused files * fix help on small screens, update how it works page * layout * add About to settings, tidy up * rename function * update layout * translations * translation corrections Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * correction Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * corrections Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * fix translations/layout Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com>
This commit is contained in:
co-authored by
JRoberts
parent
3d2315a117
commit
dcaefd6566
@@ -10,6 +10,7 @@ import Foundation
|
||||
import UIKit
|
||||
import Dispatch
|
||||
import BackgroundTasks
|
||||
import SwiftUI
|
||||
|
||||
private var chatController: chat_ctrl?
|
||||
|
||||
@@ -261,6 +262,16 @@ func apiConnect(connReq: String) async throws -> ConnReqType? {
|
||||
message: "Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.\nTo connect, please ask your contact to create another connection link and check that you have a stable network connection."
|
||||
)
|
||||
return nil
|
||||
case let .chatCmdError(.errorAgent(.INTERNAL(internalErr))):
|
||||
if internalErr == "SEUniqueID" {
|
||||
am.showAlertMsg(
|
||||
title: "Already connected?",
|
||||
message: "It seems like you are already connected via this link. If it is not the case, there was an error (\(responseError(r)))."
|
||||
)
|
||||
return nil
|
||||
} else {
|
||||
throw r
|
||||
}
|
||||
default: throw r
|
||||
}
|
||||
}
|
||||
@@ -424,13 +435,40 @@ private func sendCommandOkResp(_ cmd: ChatCommand) async throws {
|
||||
}
|
||||
|
||||
func initializeChat() {
|
||||
logger.debug("initializeChat")
|
||||
do {
|
||||
ChatModel.shared.currentUser = try apiGetActiveUser()
|
||||
let m = ChatModel.shared
|
||||
m.currentUser = try apiGetActiveUser()
|
||||
if m.currentUser == nil {
|
||||
m.onboardingStage = .step1_SimpleXInfo
|
||||
} else {
|
||||
startChat()
|
||||
}
|
||||
} catch {
|
||||
fatalError("Failed to initialize chat controller or database: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func startChat() {
|
||||
logger.debug("startChat")
|
||||
do {
|
||||
let m = ChatModel.shared
|
||||
try apiStartChat()
|
||||
try apiSetFilesFolder(filesFolder: getAppFilesDirectory().path)
|
||||
m.userAddress = try apiGetUserAddress()
|
||||
m.userSMPServers = try getUserSMPServers()
|
||||
m.chats = try apiGetChats()
|
||||
withAnimation {
|
||||
m.onboardingStage = m.chats.isEmpty
|
||||
? .step3_MakeConnection
|
||||
: .onboardingComplete
|
||||
}
|
||||
ChatReceiver.shared.start()
|
||||
} catch {
|
||||
fatalError("Failed to start or load chats: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
class ChatReceiver {
|
||||
private var receiveLoop: Task<Void, Never>?
|
||||
private var receiveMessages = true
|
||||
|
||||
Reference in New Issue
Block a user