mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-02 20:16:25 +00:00
Replace publisher with delegate in RegisterViewModel
This commit is contained in:
parent
8af6977085
commit
17e3633cb6
1 changed files with 6 additions and 7 deletions
|
|
@ -54,8 +54,7 @@ class RegisterViewModel: ObservableObject {
|
||||||
private var accountCreated: Account?
|
private var accountCreated: Account?
|
||||||
private var normalizedPhoneNumber: String?
|
private var normalizedPhoneNumber: String?
|
||||||
|
|
||||||
private var accountManagerServicesSuscriptions = Set<AnyCancellable?>()
|
private var requestDelegate: AccountManagerServicesRequestDelegate?
|
||||||
private var mCoreSuscriptions = Set<AnyCancellable?>()
|
|
||||||
|
|
||||||
@Published var isLinkActive: Bool = false
|
@Published var isLinkActive: Bool = false
|
||||||
@Published var createInProgress: Bool = false
|
@Published var createInProgress: Bool = false
|
||||||
|
|
@ -121,7 +120,7 @@ class RegisterViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
func addDelegate(request: AccountManagerServicesRequest) {
|
func addDelegate(request: AccountManagerServicesRequest) {
|
||||||
coreContext.doOnCoreQueue { core in
|
coreContext.doOnCoreQueue { core in
|
||||||
self.accountManagerServicesSuscriptions.insert(request.publisher?.onRequestSuccessful?.postOnCoreQueue { (request: AccountManagerServicesRequest, data: String) in
|
self.requestDelegate = AccountManagerServicesRequestDelegateStub(onRequestSuccessful: { (request: AccountManagerServicesRequest, data: String) in
|
||||||
Log.info("\(RegisterViewModel.TAG) Request \(request) was successful, data is \(data)")
|
Log.info("\(RegisterViewModel.TAG) Request \(request) was successful, data is \(data)")
|
||||||
switch request.type {
|
switch request.type {
|
||||||
case .CreateAccountUsingToken:
|
case .CreateAccountUsingToken:
|
||||||
|
|
@ -156,16 +155,15 @@ class RegisterViewModel: ObservableObject {
|
||||||
do {
|
do {
|
||||||
try core.addAccount(account: account!)
|
try core.addAccount(account: account!)
|
||||||
core.defaultAccount = account
|
core.defaultAccount = account
|
||||||
self.accountManagerServicesSuscriptions.removeAll()
|
request.removeDelegate(delegate: self.requestDelegate!)
|
||||||
|
self.requestDelegate = nil
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default: break
|
default: break
|
||||||
}
|
}
|
||||||
})
|
}, onRequestError: { (request: AccountManagerServicesRequest, statusCode: Int, errorMessage: String, parameterErrors: Dictionary?) in
|
||||||
|
|
||||||
self.accountManagerServicesSuscriptions.insert(request.publisher?.onRequestError?.postOnCoreQueue { (request: AccountManagerServicesRequest, statusCode: Int, errorMessage: String, parameterErrors: Dictionary?) in
|
|
||||||
Log.error(
|
Log.error(
|
||||||
"\(RegisterViewModel.TAG) Request \(request) returned an error with status code \(statusCode) and message \(errorMessage)"
|
"\(RegisterViewModel.TAG) Request \(request) returned an error with status code \(statusCode) and message \(errorMessage)"
|
||||||
)
|
)
|
||||||
|
|
@ -202,6 +200,7 @@ class RegisterViewModel: ObservableObject {
|
||||||
self.createInProgress = false
|
self.createInProgress = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
request.addDelegate(delegate: self.requestDelegate!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue