Merge pull request 'Allow client to load history on newly joined rooms' (#111) from gnieto/conduit:fix/issue-39-history-load into master

Reviewed-by: Timo Kösters <timo@koesters.xyz>
next
Timo Kösters 2020-06-07 11:21:53 +02:00
commit 88d091fca1
1 changed files with 10 additions and 6 deletions

View File

@ -2149,13 +2149,13 @@ pub fn sync_route(
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let mut send_member_count = false; let mut send_member_count = false;
let mut send_full_state = false; let mut joined_since_last_sync = false;
let mut send_notification_counts = false; let mut send_notification_counts = false;
for pdu in &pdus { for pdu in &pdus {
send_notification_counts = true; send_notification_counts = true;
if pdu.kind == EventType::RoomMember { if pdu.kind == EventType::RoomMember {
send_member_count = true; send_member_count = true;
if !send_full_state && pdu.state_key == Some(user_id.to_string()) { if !joined_since_last_sync && pdu.state_key == Some(user_id.to_string()) {
let content = serde_json::from_value::< let content = serde_json::from_value::<
EventJson<ruma::events::room::member::MemberEventContent>, EventJson<ruma::events::room::member::MemberEventContent>,
>(pdu.content.clone()) >(pdu.content.clone())
@ -2163,8 +2163,8 @@ pub fn sync_route(
.deserialize() .deserialize()
.unwrap(); .unwrap();
if content.membership == ruma::events::room::member::MembershipState::Join { if content.membership == ruma::events::room::member::MembershipState::Join {
send_full_state = true; joined_since_last_sync = true;
// Both send_member_count and send_full_state are set. There's nothing more // Both send_member_count and joined_since_last_sync are set. There's nothing more
// to do // to do
break; break;
} }
@ -2338,13 +2338,17 @@ pub fn sync_route(
notification_count, notification_count,
}, },
timeline: sync_events::Timeline { timeline: sync_events::Timeline {
limited: if limited { Some(limited) } else { None }, limited: if limited || joined_since_last_sync {
Some(true)
} else {
None
},
prev_batch, prev_batch,
events: room_events, events: room_events,
}, },
// TODO: state before timeline // TODO: state before timeline
state: sync_events::State { state: sync_events::State {
events: if send_full_state { events: if joined_since_last_sync {
state state
.into_iter() .into_iter()
.map(|(_, pdu)| pdu.to_state_event()) .map(|(_, pdu)| pdu.to_state_event())