Skip to content

Commit

Permalink
[BITAU-194] Fix issue with unit tests failing occasionally
Browse files Browse the repository at this point in the history
  • Loading branch information
brant-livefront committed Oct 31, 2024
1 parent 53cb87e commit e76c83f
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ actor DefaultAuthenticatorSyncService: NSObject, AuthenticatorSyncService {
/// The service used by the application to manage account state.
private let stateService: StateService

/// A Task to hold the subscription that waits for sync to be turned on/off.
private var syncSubscriber: Task<Void, Never>?

/// A Task to hold the subscription that waits for the vault to be locked/unlocked..
private var vaultSubscriber: Task<Void, Never>?

/// The service used by the application to manage vault access.
private let vaultTimeoutService: VaultTimeoutService

Expand Down Expand Up @@ -107,6 +113,11 @@ actor DefaultAuthenticatorSyncService: NSObject, AuthenticatorSyncService {
super.init()
}

deinit {
syncSubscriber?.cancel()
vaultSubscriber?.cancel()
}

// MARK: Public Methods

public func getTemporaryTotpItem() async -> AuthenticatorBridgeItemDataView? {
Expand All @@ -130,7 +141,7 @@ actor DefaultAuthenticatorSyncService: NSObject, AuthenticatorSyncService {
return
}

Task {
syncSubscriber = Task {
for await (userId, _) in await self.stateService.syncToAuthenticatorPublisher().values {
guard let userId else { continue }

Expand All @@ -141,7 +152,7 @@ actor DefaultAuthenticatorSyncService: NSObject, AuthenticatorSyncService {
}
}
}
Task {
vaultSubscriber = Task {
for await vaultStatus in await self.vaultTimeoutService.vaultLockStatusPublisher().values {
guard let vaultStatus else { continue }

Expand Down

0 comments on commit e76c83f

Please sign in to comment.