Skip to content

Commit a38aa47

Browse files
author
Stream Bot
committed
Fix issue where call was rejoined if user tried to open a deeplink of the currently active call
1 parent 6b14ce1 commit a38aa47

3 files changed

Lines changed: 61 additions & 2 deletions

File tree

DemoApp/Sources/Components/Router.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ final class Router: ObservableObject {
7777
return
7878
}
7979

80+
let deeplinkCallCid = callCid(
81+
from: deeplinkInfo.callId,
82+
callType: deeplinkInfo.callType
83+
)
84+
85+
if
86+
deeplinkInfo.baseURL == AppEnvironment.baseURL,
87+
appState.activeCall?.cId == deeplinkCallCid {
88+
log.debug(
89+
"Request to handle deeplink \(url) ignored because the call is already active."
90+
)
91+
return
92+
}
93+
8094
if
8195
deeplinkInfo.baseURL != AppEnvironment.baseURL,
8296
let currentUser = appState.currentUser {

DemoApp/Sources/Extensions/DemoApp+Sentry.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import Foundation
66
import Sentry
77
import StreamVideo
88

9+
private let terminalLogsEnvironmentKey = "STREAM_VIDEO_TERMINAL_LOGS"
10+
911
func configureSentry() {
12+
let terminalDestinationTypes: [LogDestination.Type] =
13+
ProcessInfo.processInfo.environment[terminalLogsEnvironmentKey] == "1"
14+
? [ConsoleLogDestination.self]
15+
: []
16+
1017
if AppEnvironment.configuration.isRelease {
1118
// We're tracking Crash Reports / Issues from the Demo App to keep improving the SDK
1219
SentrySDK.start { options in
@@ -24,14 +31,14 @@ func configureSentry() {
2431
SentryLogDestination.self,
2532
MemoryLogDestination.self,
2633
OSLogDestination.self
27-
]
34+
] + terminalDestinationTypes
2835
} else {
2936
LogConfig.level = .debug
3037
LogConfig.webRTCLogsEnabled = true
3138
LogConfig.destinationTypes = [
3239
MemoryLogDestination.self,
3340
OSLogDestination.self
34-
]
41+
] + terminalDestinationTypes
3542
}
3643
}
3744

SwiftUIDemoAppUITests/Tests/DeeplinkTests.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ final class DeeplinkTests: StreamTestCase {
2525
static let deeplinkUrlWithCallIdInPath: URL = .init(string: "https://getstream.io/video/demos/join/test-call")!
2626
static let customScheme: URL = .init(string: "streamvideo://video/demos?id=test-call")!
2727
static let customSchemeWithCallIdInPath: URL = .init(string: "streamvideo://video/demos/join/test-call")!
28+
29+
static func customScheme(callId: String) -> URL {
30+
.init(string: "streamvideo://video/demos?id=\(callId)")!
31+
}
2832
}
2933

3034
func test_associationFile_validationWasSuccessful() throws {
@@ -96,4 +100,38 @@ final class DeeplinkTests: StreamTestCase {
96100
.assertParticipantsAreVisible(count: 1)
97101
}
98102
}
103+
104+
func test_customSchemeURL_forActiveCall_doesNotRejoinAfterLeaving() throws {
105+
let activeCallId = "test-call"
106+
107+
GIVEN("user starts the call referenced by the deeplink") {
108+
userRobot
109+
.waitForAutoLogin()
110+
.startCall(activeCallId)
111+
}
112+
WHEN("user opens a deeplink for the active call") {
113+
openURL(MockDeeplink.customScheme(callId: activeCallId))
114+
}
115+
AND("user leaves the call") {
116+
userRobot.endCall()
117+
}
118+
THEN("user stays out of the call") {
119+
userRobot.assertThereAreNoCallControls()
120+
XCTAssertTrue(
121+
CallDetailsPage.callIdInputField.wait().exists,
122+
"callIdInputField should appear"
123+
)
124+
125+
let rejoinExpectation = XCTNSPredicateExpectation(
126+
predicate: NSPredicate(format: "exists == true"),
127+
object: CallPage.hangUpButton
128+
)
129+
rejoinExpectation.isInverted = true
130+
131+
XCTAssertEqual(
132+
XCTWaiter.wait(for: [rejoinExpectation], timeout: 3),
133+
.completed
134+
)
135+
}
136+
}
99137
}

0 commit comments

Comments
 (0)