Skip to content

Commit

Permalink
client-api: Use JsOption for avatar field in sliding sync response
Browse files Browse the repository at this point in the history
The `avatar` field has different semantics whether it's `undefined` (hasn't
changed since previous time) vs `null` (it's now unset). Let's reflect
this in the API of the `SlidingSyncRoom` response. While a public breaking API
change, sliding sync is still considered experimental, so we're not bumping
the main version here.
  • Loading branch information
bnjbvr authored Nov 20, 2023
1 parent 5446ea9 commit 9728f97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/ruma-client-api/src/sync/sync_events/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::{collections::BTreeMap, time::Duration};

use js_int::UInt;
use js_option::JsOption;
use ruma_common::{
api::{request, response, Metadata},
metadata,
Expand Down Expand Up @@ -421,8 +422,8 @@ pub struct SlidingSyncRoom {
pub name: Option<String>,

/// The avatar of the room.
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<OwnedMxcUri>,
#[serde(default, skip_serializing_if = "JsOption::is_undefined")]
pub avatar: JsOption<OwnedMxcUri>,

/// Was this an initial response.
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down

0 comments on commit 9728f97

Please sign in to comment.