Skip to content

Commit 3b9ae3e

Browse files
toger5BillCarsonFr
andauthored
feat(widgets, element-call) Update the widget url generation (#4802)
Fixes: #4793 Co-authored-by: Valere <[email protected]>
1 parent a539518 commit 3b9ae3e

File tree

5 files changed

+214
-55
lines changed

5 files changed

+214
-55
lines changed

bindings/matrix-sdk-ffi/src/widget.rs

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,31 @@ impl From<EncryptionSystem> for matrix_sdk::widget::EncryptionSystem {
141141
}
142142
}
143143

144+
/// Defines the intent of showing the call.
145+
///
146+
/// This controls whether to show or skip the lobby.
147+
#[derive(uniffi::Enum, Clone)]
148+
pub enum Intent {
149+
/// The user wants to start a call.
150+
StartCall,
151+
/// The user wants to join an existing call.
152+
JoinExisting,
153+
}
154+
impl From<Intent> for matrix_sdk::widget::Intent {
155+
fn from(value: Intent) -> Self {
156+
match value {
157+
Intent::StartCall => Self::StartCall,
158+
Intent::JoinExisting => Self::JoinExisting,
159+
}
160+
}
161+
}
162+
144163
/// Properties to create a new virtual Element Call widget.
145164
#[derive(uniffi::Record, Clone)]
146165
pub struct VirtualElementCallWidgetOptions {
147166
/// The url to the app.
148167
///
149-
/// E.g. <https://call.element.io>, <https://call.element.dev>
168+
/// E.g. <https://call.element.io>, <https://call.element.dev>, <https://call.element.dev/room>
150169
pub element_call_url: String,
151170

152171
/// The widget id.
@@ -189,11 +208,6 @@ pub struct VirtualElementCallWidgetOptions {
189208
/// Default: `false`
190209
pub app_prompt: Option<bool>,
191210

192-
/// Don't show the lobby and join the call immediately.
193-
///
194-
/// Default: `false`
195-
pub skip_lobby: Option<bool>,
196-
197211
/// Make it not possible to get to the calls list in the webview.
198212
///
199213
/// Default: `true`
@@ -202,13 +216,33 @@ pub struct VirtualElementCallWidgetOptions {
202216
/// The font to use, to adapt to the system font.
203217
pub font: Option<String>,
204218

205-
/// Can be used to pass a PostHog id to element call.
206-
pub analytics_id: Option<String>,
207-
208219
/// The encryption system to use.
209220
///
210221
/// Use `EncryptionSystem::Unencrypted` to disable encryption.
211222
pub encryption: EncryptionSystem,
223+
224+
/// The intent of showing the call.
225+
/// If the user wants to start a call or join an existing one.
226+
/// Controls if the lobby is skipped or not.
227+
pub intent: Option<Intent>,
228+
229+
/// Do not show the screenshare button.
230+
pub hide_screensharing: bool,
231+
232+
/// Can be used to pass a PostHog id to element call.
233+
pub posthog_user_id: Option<String>,
234+
/// The host of the posthog api.
235+
pub posthog_api_host: Option<String>,
236+
/// The key for the posthog api.
237+
pub posthog_api_key: Option<String>,
238+
239+
/// The url to use for submitting rageshakes.
240+
pub rageshake_submit_url: Option<String>,
241+
242+
/// Sentry [DSN](https://docs.sentry.io/concepts/key-terms/dsn-explainer/)
243+
pub sentry_dsn: Option<String>,
244+
/// Sentry [environment](https://docs.sentry.io/concepts/key-terms/key-terms/)
245+
pub sentry_environment: Option<String>,
212246
}
213247

214248
impl From<VirtualElementCallWidgetOptions> for matrix_sdk::widget::VirtualElementCallWidgetOptions {
@@ -221,11 +255,17 @@ impl From<VirtualElementCallWidgetOptions> for matrix_sdk::widget::VirtualElemen
221255
preload: value.preload,
222256
font_scale: value.font_scale,
223257
app_prompt: value.app_prompt,
224-
skip_lobby: value.skip_lobby,
225258
confine_to_room: value.confine_to_room,
226259
font: value.font,
227-
analytics_id: value.analytics_id,
260+
posthog_user_id: value.posthog_user_id,
228261
encryption: value.encryption.into(),
262+
intent: value.intent.map(Into::into),
263+
hide_screensharing: value.hide_screensharing,
264+
posthog_api_host: value.posthog_api_host,
265+
posthog_api_key: value.posthog_api_key,
266+
rageshake_submit_url: value.rageshake_submit_url,
267+
sentry_dsn: value.sentry_dsn,
268+
sentry_environment: value.sentry_environment,
229269
}
230270
}
231271
}

crates/matrix-sdk/CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@ All notable changes to this project will be documented in this file.
88

99
### Features
1010

11-
- [**breaking**]: The `RoomPagination::run_backwards` method has been removed, and replaced by two
11+
- [**breaking**]: The element call widget URL configuration struct (`VirtualElementCallWidgetOptions`) and URL generation
12+
have changed.
13+
- It supports the new fields: `hide_screensharing`, `posthog_api_host`, `posthog_api_key`,
14+
`rageshake_submit_url`, `sentry_dsn`, `sentry_environment`.
15+
- The widget URL will no longer automatically add `/room` to the base domain. For backward compatibility
16+
the app itself would need to add `/room` to the `element_call_url`.
17+
- And replaced:
18+
- `analytics_id` -> `posthog_user_id` (The widget URL query parameters will include `analytics_id` & `posthog_user_id`
19+
for backward compatibility)
20+
- `skip_lobby` -> `intent` (`Intent.StartCall`, `Intent.JoinCall`)
21+
- `VirtualElementCallWidgetOptions` now implements `Default`.
22+
- [**breaking**]: The `RoomPagination::run_backwards` method has been removed and replaced by two
1223
simpler methods:
1324
- `RoomPagination::run_backwards_until()`, which will retrigger back-paginations until a certain
1425
number of events have been received (and retry if the timeline has been reset in the background).

crates/matrix-sdk/src/widget/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub use self::{
4141
capabilities::{Capabilities, CapabilitiesProvider},
4242
filter::{EventFilter, MessageLikeEventFilter, StateEventFilter},
4343
settings::{
44-
ClientProperties, EncryptionSystem, VirtualElementCallWidgetOptions, WidgetSettings,
44+
ClientProperties, EncryptionSystem, Intent, VirtualElementCallWidgetOptions, WidgetSettings,
4545
},
4646
};
4747

0 commit comments

Comments
 (0)