Skip to content

Commit

Permalink
Add a build-time feature flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Aug 16, 2024
1 parent a4ef271 commit 5748e3c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ final class AppSettings {

// MARK: - Element Call

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

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

@UserPreference(key: UserDefaultsKeys.timelineItemAuthenticityEnabled, defaultValue: false, storageType: .userDefaults(store))
var timelineItemAuthenticityEnabled

// Not user configurable as it depends on work in EC too.
let elementCallPictureInPictureEnabled = false

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
clientID: InfoPlistReader.main.bundleIdentifier,
elementCallBaseURL: appSettings.elementCallBaseURL,
elementCallBaseURLOverride: appSettings.elementCallBaseURLOverride,
elementCallPictureInPictureEnabled: appSettings.elementCallPictureInPictureEnabled,
colorScheme: colorScheme,
appHooks: appHooks))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct CallScreenCoordinatorParameters {
let clientID: String
let elementCallBaseURL: URL
let elementCallBaseURLOverride: URL?
let elementCallPictureInPictureEnabled: Bool
let colorScheme: ColorScheme
let appHooks: AppHooks
}
Expand Down Expand Up @@ -54,6 +55,7 @@ final class CallScreenCoordinator: CoordinatorProtocol {
clientID: parameters.clientID,
elementCallBaseURL: parameters.elementCallBaseURL,
elementCallBaseURLOverride: parameters.elementCallBaseURLOverride,
elementCallPictureInPictureEnabled: parameters.elementCallPictureInPictureEnabled,
colorScheme: parameters.colorScheme,
appHooks: parameters.appHooks)
}
Expand Down
7 changes: 5 additions & 2 deletions ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typealias CallScreenViewModelType = StateStoreViewModel<CallScreenViewState, Cal
class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol {
private let elementCallService: ElementCallServiceProtocol
private let roomProxy: RoomProxyProtocol
private let isPictureInPictureEnabled: Bool

private let widgetDriver: ElementCallWidgetDriverProtocol

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

self.elementCallService = elementCallService
self.roomProxy = roomProxy
isPictureInPictureEnabled = elementCallPictureInPictureEnabled

widgetDriver = roomProxy.elementCallWidgetDriver(deviceID: deviceID)

Expand Down Expand Up @@ -200,14 +203,14 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
}
#endif

guard state.url != nil else {
guard isPictureInPictureEnabled, state.url != nil else {
actionsSubject.send(.dismiss)
return
}

Task {
try await state.bindings.javaScriptEvaluator?("controls.enableCompatPip()")
// TODO: Enable this check when implemented on web.
// Enable this check when implemented on web.
// if result as? Bool != true {
// actionsSubject.send(.dismiss)
// }
Expand Down
1 change: 1 addition & 0 deletions ElementX/Sources/Screens/CallScreen/View/CallScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ struct CallScreen_Previews: PreviewProvider {
clientID: "io.element.elementx",
elementCallBaseURL: "https://call.element.io",
elementCallBaseURLOverride: nil,
elementCallPictureInPictureEnabled: false,
colorScheme: .light,
appHooks: AppHooks())
}()
Expand Down

0 comments on commit 5748e3c

Please sign in to comment.