Skip to content

Commit 5748e3c

Browse files
committed
Add a build-time feature flag.
1 parent a4ef271 commit 5748e3c

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

ElementX/Sources/Application/AppSettings.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ final class AppSettings {
252252

253253
// MARK: - Element Call
254254

255-
#warning("Temporary base URL whilst PiP support is being added.")
256-
let elementCallBaseURL: URL = "https://pr2563--element-call.netlify.app/"
255+
let elementCallBaseURL: URL = "https://call.element.io"
257256

258257
@UserPreference(key: UserDefaultsKeys.elementCallBaseURLOverride, defaultValue: nil, storageType: .userDefaults(store))
259258
var elementCallBaseURLOverride: URL?
@@ -289,6 +288,9 @@ final class AppSettings {
289288

290289
@UserPreference(key: UserDefaultsKeys.timelineItemAuthenticityEnabled, defaultValue: false, storageType: .userDefaults(store))
291290
var timelineItemAuthenticityEnabled
291+
292+
// Not user configurable as it depends on work in EC too.
293+
let elementCallPictureInPictureEnabled = false
292294

293295
#endif
294296

ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift

+1
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
573573
clientID: InfoPlistReader.main.bundleIdentifier,
574574
elementCallBaseURL: appSettings.elementCallBaseURL,
575575
elementCallBaseURLOverride: appSettings.elementCallBaseURLOverride,
576+
elementCallPictureInPictureEnabled: appSettings.elementCallPictureInPictureEnabled,
576577
colorScheme: colorScheme,
577578
appHooks: appHooks))
578579

ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct CallScreenCoordinatorParameters {
2525
let clientID: String
2626
let elementCallBaseURL: URL
2727
let elementCallBaseURLOverride: URL?
28+
let elementCallPictureInPictureEnabled: Bool
2829
let colorScheme: ColorScheme
2930
let appHooks: AppHooks
3031
}
@@ -54,6 +55,7 @@ final class CallScreenCoordinator: CoordinatorProtocol {
5455
clientID: parameters.clientID,
5556
elementCallBaseURL: parameters.elementCallBaseURL,
5657
elementCallBaseURLOverride: parameters.elementCallBaseURLOverride,
58+
elementCallPictureInPictureEnabled: parameters.elementCallPictureInPictureEnabled,
5759
colorScheme: parameters.colorScheme,
5860
appHooks: parameters.appHooks)
5961
}

ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typealias CallScreenViewModelType = StateStoreViewModel<CallScreenViewState, Cal
2424
class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol {
2525
private let elementCallService: ElementCallServiceProtocol
2626
private let roomProxy: RoomProxyProtocol
27+
private let isPictureInPictureEnabled: Bool
2728

2829
private let widgetDriver: ElementCallWidgetDriverProtocol
2930

@@ -46,12 +47,14 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
4647
clientID: String,
4748
elementCallBaseURL: URL,
4849
elementCallBaseURLOverride: URL?,
50+
elementCallPictureInPictureEnabled: Bool,
4951
colorScheme: ColorScheme,
5052
appHooks: AppHooks) {
5153
guard let deviceID = clientProxy.deviceID else { fatalError("Missing device ID for the call.") }
5254

5355
self.elementCallService = elementCallService
5456
self.roomProxy = roomProxy
57+
isPictureInPictureEnabled = elementCallPictureInPictureEnabled
5558

5659
widgetDriver = roomProxy.elementCallWidgetDriver(deviceID: deviceID)
5760

@@ -200,14 +203,14 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
200203
}
201204
#endif
202205

203-
guard state.url != nil else {
206+
guard isPictureInPictureEnabled, state.url != nil else {
204207
actionsSubject.send(.dismiss)
205208
return
206209
}
207210

208211
Task {
209212
try await state.bindings.javaScriptEvaluator?("controls.enableCompatPip()")
210-
// TODO: Enable this check when implemented on web.
213+
// Enable this check when implemented on web.
211214
// if result as? Bool != true {
212215
// actionsSubject.send(.dismiss)
213216
// }

ElementX/Sources/Screens/CallScreen/View/CallScreen.swift

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ struct CallScreen_Previews: PreviewProvider {
226226
clientID: "io.element.elementx",
227227
elementCallBaseURL: "https://call.element.io",
228228
elementCallBaseURLOverride: nil,
229+
elementCallPictureInPictureEnabled: false,
229230
colorScheme: .light,
230231
appHooks: AppHooks())
231232
}()

0 commit comments

Comments
 (0)