wip
This commit is contained in:
parent
e2002057db
commit
17f310dd6a
|
@ -33,7 +33,7 @@ enum UserSettings {
|
|||
@Storage(key: kOmemoDevicesIds, defaultValue: [:])
|
||||
private static var omemoDevicesIds: [String: UInt32]
|
||||
|
||||
@Storage(key: kSecureChatsByDefault, defaultValue: false)
|
||||
@Storage(key: kSecureChatsByDefault, defaultValue: true)
|
||||
private static var vSecureChatsByDefault: Bool
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ enum UserSettings {
|
|||
extension UserSettings {
|
||||
static func reset() {
|
||||
omemoDevicesIds = [:]
|
||||
vSecureChatsByDefault = false
|
||||
vSecureChatsByDefault = true
|
||||
}
|
||||
|
||||
static func set(omemoDeviceId: UInt32, for account: String) {
|
||||
|
|
|
@ -76,14 +76,13 @@ extension ClientsStore {
|
|||
if let client = clients.first(where: { $0.credentials.bareJid == jidStr }) {
|
||||
// check if credentials already exist and enable it
|
||||
// this change will invoke reconnect automatically
|
||||
try? await client.credentials.setActive(flag: true)
|
||||
await client.updActivity(true)
|
||||
} else {
|
||||
// new client login with fake timeout
|
||||
async let sleep: Void? = try? await Task.sleep(nanoseconds: 1 * NSEC_PER_SEC)
|
||||
async let request = try await Client.tryLogin(with: .init(bareJid: jidStr, pass: pass, isActive: true))
|
||||
let client = try await(request, sleep).0
|
||||
|
||||
clients.append(client)
|
||||
try? await client.credentials.save()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,17 +13,8 @@ struct LoginScreen: View {
|
|||
|
||||
@FocusState private var focus: Field?
|
||||
|
||||
#if DEBUG
|
||||
@State private var jidStr: String = "grouptest1@test.anal.company"
|
||||
@State private var pass: String = "12345"
|
||||
// @State private var jidStr: String = "nartest1@conversations.im"
|
||||
// @State private var pass: String = "nartest12345"
|
||||
// @State private var jidStr: String = "test1@test.anal.company"
|
||||
// @State private var pass: String = "12345"
|
||||
#else
|
||||
@State private var jidStr: String = ""
|
||||
@State private var pass: String = ""
|
||||
#endif
|
||||
@State private var jidStr: String = ""
|
||||
@State private var pass: String = ""
|
||||
|
||||
public var body: some View {
|
||||
ZStack {
|
||||
|
@ -107,19 +98,18 @@ struct LoginScreen: View {
|
|||
}
|
||||
|
||||
private func tryLogin() async {
|
||||
defer {
|
||||
router.dismissScreen()
|
||||
}
|
||||
|
||||
do {
|
||||
try await clientsStore.tryLogin(jidStr, pass)
|
||||
router.dismissScreen()
|
||||
} catch {
|
||||
router.showAlert(
|
||||
.alert,
|
||||
title: L10n.Global.Error.title,
|
||||
subtitle: L10n.Login.error
|
||||
) {
|
||||
Button(L10n.Global.ok, role: .cancel) {}
|
||||
Button(L10n.Global.ok, role: .cancel) {
|
||||
router.dismissModal()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue