FIx rebase

This commit is contained in:
Benoit Martins 2023-11-09 13:54:57 +01:00
parent 19da1739f0
commit 3b625b9063
6 changed files with 39 additions and 26 deletions

View file

@ -183,25 +183,24 @@ final class ContactsManager: ObservableObject {
}
awaitDataWrite(data: data, name: name) { _, result in
let resultFriend = self.saveFriend(result: result, contact: contact, existingFriend: existingFriend)
if resultFriend != nil {
if linphoneFriend && existingFriend == nil {
_ = self.linphoneFriendList!.addLocalFriend(linphoneFriend: resultFriend!)
self.linphoneFriendList!.updateSubscriptions()
} else if existingFriend == nil {
_ = self.friendList!.addLocalFriend(linphoneFriend: resultFriend!)
self.friendList!.updateSubscriptions()
}
self.saveFriend(result: result, contact: contact, existingFriend: existingFriend) { resultFriend in
if resultFriend != nil {
if linphoneFriend && existingFriend == nil {
_ = self.linphoneFriendList!.addLocalFriend(linphoneFriend: resultFriend!)
self.linphoneFriendList!.updateSubscriptions()
} else if existingFriend == nil {
_ = self.friendList!.addLocalFriend(linphoneFriend: resultFriend!)
self.friendList!.updateSubscriptions()
}
}
}
}
}
func saveFriend(result: String, contact: Contact, existingFriend: Friend?) -> Friend? {
self.coreContext.doOnCoreQueue() { core in
func saveFriend(result: String, contact: Contact, existingFriend: Friend?, completion: @escaping (Friend?) -> Void) {
self.coreContext.doOnCoreQueue { core in
do {
let friend = (existingFriend != nil) ? existingFriend : try core.createFriend()
@ -257,14 +256,14 @@ final class ContactsManager: ObservableObject {
friend!.jobTitle = contact.jobTitle
friend!.done()
return friend
completion(friend)
}
} catch let error {
print("Failed to enumerate contact", error)
return nil
completion(nil)
}
}
return nil
completion(nil)
}
func getImagePath(friendPhotoPath: String) -> URL {

View file

@ -36,7 +36,7 @@ final class CoreContext: ObservableObject {
private init() {}
func doOnCoreQueue(synchronous : Bool = false, lambda: @escaping (Core) -> Void) {
func doOnCoreQueue(synchronous: Bool = false, lambda: @escaping (Core) -> Void) {
if synchronous {
coreQueue.sync {
lambda(self.mCore)
@ -77,7 +77,9 @@ final class CoreContext: ObservableObject {
}
}
self.mCore.publisher?.onAccountRegistrationStateChanged?.postOnMainQueue { (cbVal: (core: Core, account: Account, state: RegistrationState, message: String)) in
self.mCore.publisher?.onAccountRegistrationStateChanged?.postOnMainQueue {(cbVal:
(core: Core, account: Account, state: RegistrationState, message: String)
) in
// If account has been configured correctly, we will go through Progress and Ok states
// Otherwise, we will be Failed.
NSLog("New registration state is \(cbVal.state) for user id " +

View file

@ -52,7 +52,14 @@ class AccountLoginViewModel: ObservableObject {
// userID is set to null as it's the same as the username in our case
// ha1 is set to null as we are using the clear text password. Upon first register, the hash will be computed automatically.
// The realm will be determined automatically from the first register, as well as the algorithm
let authInfo = try Factory.Instance.createAuthInfo(username: self.username, userid: "", passwd: self.passwd, ha1: "", realm: "", domain: self.domain)
let authInfo = try Factory.Instance.createAuthInfo(
username: self.username,
userid: "",
passwd: self.passwd,
ha1: "",
realm: "",
domain: self.domain
)
// Account object replaces deprecated ProxyConfig object
// Account object is configured through an AccountParams object that we can obtain from the Core

View file

@ -192,7 +192,12 @@ struct ContactInnerActionsFragment: View {
&& !magicSearch.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.jobTitle!.isEmpty {
Text("**Job :** \(magicSearch.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.jobTitle!)")
.default_text_style(styleSize: 14)
.padding(.vertical, 15)
.padding(.top,
magicSearch.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.organization != nil
&& !magicSearch.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.organization!.isEmpty
? 0 : 15
)
.padding(.bottom, 15)
.padding(.horizontal, 20)
.frame(maxWidth: .infinity, alignment: .leading)
}

View file

@ -493,10 +493,10 @@ struct EditContactFragment: View {
if editContactViewModel.selectedEditFriend != nil && selectedImage == nil &&
!removedImage {
_ = ContactsManager.shared.saveFriend(
ContactsManager.shared.saveFriend(
result: String(editContactViewModel.selectedEditFriend!.photo!.dropFirst(6)),
contact: newContact,
existingFriend: editContactViewModel.selectedEditFriend
existingFriend: editContactViewModel.selectedEditFriend, completion: {_ in }
)
} else {
ContactsManager.shared.saveImage(

View file

@ -39,7 +39,7 @@ final class MagicSearchSingleton: ObservableObject {
private var domainDefaultAccount = ""
private init() {
coreContext.doOnCoreQueue{ core in
coreContext.doOnCoreQueue { core in
self.domainDefaultAccount = core.defaultAccount?.params?.domain ?? ""
self.magicSearch = try? core.createMagicSearch()
@ -53,7 +53,7 @@ final class MagicSearchSingleton: ObservableObject {
}
func searchForContacts(sourceFlags: Int) {
coreContext.doOnCoreQueue{ core in
coreContext.doOnCoreQueue { _ in
var needResetCache = false
DispatchQueue.main.sync {