Skip to content

Commit

Permalink
ffi: Use the SDK's (tested) logic for overriding the sliding sync proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jul 22, 2024
1 parent 5242f64 commit f37799d
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions bindings/matrix-sdk-ffi/src/client_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ impl ClientBuilder {

inner_builder = inner_builder.with_encryption_settings(builder.encryption_settings);

if let Some(sliding_sync_proxy) = builder.sliding_sync_proxy {
inner_builder = inner_builder.sliding_sync_proxy(sliding_sync_proxy);
}

inner_builder =
inner_builder.simplified_sliding_sync(builder.is_simplified_sliding_sync_enabled);

Expand All @@ -536,25 +540,6 @@ impl ClientBuilder {

let sdk_client = inner_builder.build().await?;

// At this point, `sdk_client` might contain a `sliding_sync_proxy` that has
// been configured by the homeserver (if it's a `ServerName` and the
// `.well-known` file is filled as expected).
//
// If `builder.sliding_sync_proxy` contains `Some(_)`, it means one wants to
// overwrite this value. It would be an error to call
// `sdk_client.set_sliding_sync_proxy()` with `None`, as it would erase the
// `sliding_sync_proxy` if any, and it's not the intended behavior.
//
// So let's call `sdk_client.set_sliding_sync_proxy()` if and only if there is
// `Some(_)` value in `builder.sliding_sync_proxy`. That's really important: It
// might not break an existing app session, but it is likely to break a new
// session, which not immediate to detect if there is no test.
if !builder.is_simplified_sliding_sync_enabled {
if let Some(sliding_sync_proxy) = builder.sliding_sync_proxy {
sdk_client.set_sliding_sync_proxy(Some(Url::parse(&sliding_sync_proxy)?));
}
}

Ok(Arc::new(
Client::new(
sdk_client,
Expand Down

0 comments on commit f37799d

Please sign in to comment.