mirror of
https://github.com/ProtonMail/protoncore_ios.git
synced 2026-01-16 23:00:24 +00:00
Fix: [CP-XX] TransactionObserver can be started infinite times
Refs: https://gitlab.protontech.ch/apple/shared/protoncore/-/merge_requests/2041
This commit is contained in:
commit
ed01c8e501
1 changed files with 15 additions and 11 deletions
|
|
@ -138,20 +138,24 @@ public final class TransactionsObserver: TransactionsObserverProviding, @uncheck
|
|||
|
||||
// MARK: Public methods
|
||||
public func start() async throws {
|
||||
if !isON {
|
||||
try initRequiredComponents()
|
||||
|
||||
try initRequiredComponents()
|
||||
guard let planComposer = planComposer, let _ = transactionHandler else {
|
||||
assertionFailure("TransactionsObserver: TransactionsObserverConfiguration required to start the observer")
|
||||
throw TransactionsObserverError.requiredSubComponentInitFailed
|
||||
}
|
||||
|
||||
guard let planComposer = planComposer, let _ = transactionHandler else {
|
||||
assertionFailure("TransactionsObserver: TransactionsObserverConfiguration required to start the observer")
|
||||
throw TransactionsObserverError.requiredSubComponentInitFailed
|
||||
if !planComposer.hasData {
|
||||
_ = try await planComposer.fetchAvailablePlans()
|
||||
}
|
||||
updates?.cancel()
|
||||
updates = newTransactionListenerTask()
|
||||
isON = true
|
||||
debugPrint("TransactionsObserver started: \(isON) ✅")
|
||||
} else {
|
||||
debugPrint("TransactionsObserver already running, nothing to start")
|
||||
}
|
||||
|
||||
if !planComposer.hasData {
|
||||
_ = try await planComposer.fetchAvailablePlans()
|
||||
}
|
||||
updates = newTransactionListenerTask()
|
||||
isON = true
|
||||
debugPrint("TransactionsObserver started: \(isON) ✅")
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue