Skip to content

Commit

Permalink
[Fix]Flakey tests (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Jun 18, 2024
1 parent 77b0a4d commit 6ca703f
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 80 deletions.
10 changes: 10 additions & 0 deletions Sources/StreamVideo/StreamVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,30 @@ public class StreamVideo: ObservableObject, @unchecked Sendable {
connectTask = Task {
if user.type == .guest {
do {
try Task.checkCancellation()
let guestInfo = try await loadGuestUserInfo(for: user, apiKey: apiKey)

self.state.user = guestInfo.user
self.token = guestInfo.token
self.tokenProvider = guestInfo.tokenProvider

try Task.checkCancellation()
try await self.connectUser(isInitial: true)
} catch {
log.error("Error connecting as guest", error: error)
}
} else {
try Task.checkCancellation()
try await self.connectUser(isInitial: true)
}
}
}

deinit {
connectTask?.cancel()
connectTask = nil
}

/// Connects the current user.
public func connect() async throws {
try await connectUser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ final class StreamPictureInPictureTrackStateAdapter {
}
}

deinit {
observerCancellable?.cancel()
isEnabled = false
activeTrack = nil
}

// MARK: - Private helpers

/// This property holds a reference to the observer cancellable.
Expand Down
Loading

0 comments on commit 6ca703f

Please sign in to comment.