widget: Rename settings#id to widget_id
This commit is contained in:
committed by
Jonas Platte
parent
4a1e4cd279
commit
de0543c2e2
@@ -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<WidgetSettings> for matrix_sdk::widget::WidgetSettings {
|
||||
type Error = ParseError;
|
||||
|
||||
fn try_from(value: WidgetSettings) -> Result<Self, Self::Error> {
|
||||
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<matrix_sdk::widget::WidgetSettings> 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(),
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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<Self, url::ParseError> {
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user