Skip to content

Commit

Permalink
Log any failures when creating a call widget. (#3339)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave authored Sep 27, 2024
1 parent 4080ff1 commit 605337b
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,48 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv

let useEncryption = (try? room.isEncrypted()) ?? false

guard let widgetSettings = try? newVirtualElementCallWidget(props: .init(elementCallUrl: baseURL.absoluteString,
widgetId: widgetID,
parentUrl: nil,
hideHeader: nil,
preload: nil,
fontScale: nil,
appPrompt: false,
skipLobby: true,
confineToRoom: true,
font: nil,
analyticsId: nil,
encryption: useEncryption ? .perParticipantKeys : .unencrypted)) else {
let widgetSettings: WidgetSettings
do {
widgetSettings = try newVirtualElementCallWidget(props: .init(elementCallUrl: baseURL.absoluteString,
widgetId: widgetID,
parentUrl: nil,
hideHeader: nil,
preload: nil,
fontScale: nil,
appPrompt: false,
skipLobby: true,
confineToRoom: true,
font: nil,
analyticsId: nil,
encryption: useEncryption ? .perParticipantKeys : .unencrypted))
} catch {
MXLog.error("Failed to build widget settings: \(error)")
return .failure(.failedBuildingWidgetSettings)
}

let languageTag = "\(Locale.current.language.languageCode ?? "en")-\(Locale.current.language.region ?? "US")"
let theme = colorScheme == .light ? "light" : "dark"

guard let urlString = try? await generateWebviewUrl(widgetSettings: widgetSettings, room: room,
props: .init(clientId: clientID,
languageTag: languageTag,
theme: theme)) else {
let urlString: String
do {
urlString = try await generateWebviewUrl(widgetSettings: widgetSettings, room: room,
props: .init(clientId: clientID,
languageTag: languageTag,
theme: theme))
} catch {
MXLog.error("Failed to generate web view URL: \(error)")
return .failure(.failedBuildingCallURL)
}

guard let url = URL(string: urlString) else {
return .failure(.failedParsingCallURL)
}

guard let widgetDriver = try? makeWidgetDriver(settings: widgetSettings) else {
let widgetDriver: WidgetDriverAndHandle
do {
widgetDriver = try makeWidgetDriver(settings: widgetSettings)
} catch {
MXLog.error("Failed to build widget driver: \(error)")
return .failure(.failedBuildingWidgetDriver)
}

Expand Down

0 comments on commit 605337b

Please sign in to comment.