mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-04-24 09:08:23 -04:00
sliding sync: fix unsetting the avatar in a sliding sync room
The meaning of "null" and "undefined" were conflated by Ruma, previously. This updates to the latest Ruma, which changed the `avatar` type from `Option` to `JsOption` and thus allowed us to distinguish both cases: `null` means the avatar has been unset, `undefined` means it's not changed since the previous request.
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -4676,9 +4676,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.17.3"
|
||||
version = "0.17.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2428ee1488551cbc2bc4ef936c9452ac35ccd5c7e4e4df12c54b67afa6b262fb"
|
||||
checksum = "641837258fa214a70823477514954ef0f5d3bc6ae8e1d5d85081856a33103386"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"bytes",
|
||||
|
||||
@@ -78,7 +78,7 @@ impl SlidingSyncRoom {
|
||||
pub fn avatar_url(&self) -> Option<OwnedMxcUri> {
|
||||
let inner = self.inner.inner.read().unwrap();
|
||||
|
||||
inner.avatar.clone()
|
||||
inner.avatar.clone().into_option()
|
||||
}
|
||||
|
||||
/// Is this a direct message?
|
||||
@@ -167,7 +167,10 @@ impl SlidingSyncRoom {
|
||||
inner.name = name;
|
||||
}
|
||||
|
||||
if avatar.is_some() {
|
||||
// Note: in the server specification, the avatar is undefined when it hasn't
|
||||
// changed, and it's set to null when it's been unset, so we
|
||||
// distinguish the two here.
|
||||
if !avatar.is_undefined() {
|
||||
inner.avatar = avatar;
|
||||
}
|
||||
|
||||
@@ -321,7 +324,7 @@ mod tests {
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{
|
||||
api::client::sync::sync_events::v4, assign, events::room::message::RoomMessageEventContent,
|
||||
mxc_uri, room_id, serde::Raw, uint, RoomId,
|
||||
mxc_uri, room_id, serde::Raw, uint, JsOption, RoomId,
|
||||
};
|
||||
use serde_json::json;
|
||||
use wiremock::MockServer;
|
||||
@@ -906,7 +909,7 @@ mod tests {
|
||||
v4::SlidingSyncRoom::default(),
|
||||
{
|
||||
name: Some("foobar".to_owned()),
|
||||
avatar: Some(mxc_uri!("mxc://homeserver/media").to_owned()),
|
||||
avatar: JsOption::Some(mxc_uri!("mxc://homeserver/media").to_owned()),
|
||||
}
|
||||
),
|
||||
timeline_queue: vector![TimelineEvent::new(
|
||||
|
||||
Reference in New Issue
Block a user