From de0543c2e2825911f0fb34ea53484fc8c8a82f9f Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 17 Oct 2023 12:28:23 +0200 Subject: [PATCH] widget: Rename settings#id to widget_id --- bindings/matrix-sdk-ffi/src/widget.rs | 8 ++++---- crates/matrix-sdk/src/widget/settings/element_call.rs | 4 ++-- crates/matrix-sdk/src/widget/settings/mod.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/widget.rs b/bindings/matrix-sdk-ffi/src/widget.rs index d48aa1ec4..5e856faef 100644 --- a/bindings/matrix-sdk-ffi/src/widget.rs +++ b/bindings/matrix-sdk-ffi/src/widget.rs @@ -52,7 +52,7 @@ impl WidgetDriver { #[derive(uniffi::Record, Clone)] pub struct WidgetSettings { /// Widget's unique identifier. - pub id: String, + pub widget_id: String, /// Whether or not the widget should be initialized on load message /// (`ContentLoad` message), or upon creation/attaching of the widget to /// the SDK's state machine that drives the API. @@ -73,15 +73,15 @@ impl TryFrom for matrix_sdk::widget::WidgetSettings { type Error = ParseError; fn try_from(value: WidgetSettings) -> Result { - let WidgetSettings { id, init_after_content_load, raw_url } = value; - Ok(matrix_sdk::widget::WidgetSettings::new(id, init_after_content_load, &raw_url)?) + let WidgetSettings { widget_id, init_after_content_load, raw_url } = value; + Ok(matrix_sdk::widget::WidgetSettings::new(widget_id, init_after_content_load, &raw_url)?) } } impl From for WidgetSettings { fn from(value: matrix_sdk::widget::WidgetSettings) -> Self { WidgetSettings { - id: value.id().to_owned(), + widget_id: value.widget_id().to_owned(), init_after_content_load: value.init_on_content_load(), raw_url: value.raw_url().to_string(), } diff --git a/crates/matrix-sdk/src/widget/settings/element_call.rs b/crates/matrix-sdk/src/widget/settings/element_call.rs index e2609e3ea..ddd96d7be 100644 --- a/crates/matrix-sdk/src/widget/settings/element_call.rs +++ b/crates/matrix-sdk/src/widget/settings/element_call.rs @@ -166,7 +166,7 @@ impl WidgetSettings { raw_url.set_fragment(Some(&format!("?{}", query))); // for EC we always want init on content load to be true. - Ok(Self { id: props.widget_id, init_on_content_load: true, raw_url }) + Ok(Self { widget_id: props.widget_id, init_on_content_load: true, raw_url }) } } @@ -261,7 +261,7 @@ mod tests { #[test] fn new_virtual_element_call_widget_id() { - assert_eq!(get_widget_settings().id(), WIDGET_ID); + assert_eq!(get_widget_settings().widget_id(), WIDGET_ID); } #[test] diff --git a/crates/matrix-sdk/src/widget/settings/mod.rs b/crates/matrix-sdk/src/widget/settings/mod.rs index 21a7f2b9b..f2dcc8b13 100644 --- a/crates/matrix-sdk/src/widget/settings/mod.rs +++ b/crates/matrix-sdk/src/widget/settings/mod.rs @@ -26,7 +26,7 @@ pub use self::element_call::VirtualElementCallWidgetOptions; /// Settings of the widget. #[derive(Debug, Clone)] pub struct WidgetSettings { - id: String, + widget_id: String, init_on_content_load: bool, raw_url: Url, } @@ -38,12 +38,12 @@ impl WidgetSettings { init_on_content_load: bool, raw_url: &str, ) -> Result { - Ok(Self { id, init_on_content_load, raw_url: Url::parse(raw_url)? }) + Ok(Self { widget_id: id, init_on_content_load, raw_url: Url::parse(raw_url)? }) } /// Widget's unique identifier. - pub fn id(&self) -> &String { - &self.id + pub fn widget_id(&self) -> &str { + &self.widget_id } /// Whether or not the widget should be initialized on load message @@ -113,7 +113,7 @@ impl WidgetSettings { let avatar_url = profile.avatar_url.map(|url| url.to_string()).unwrap_or_default(); let query_props = url_params::QueryProperties { - widget_id: self.id.clone(), + widget_id: self.widget_id.clone(), avatar_url, display_name: profile.displayname.unwrap_or_default(), user_id: user_id.into(),