summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2023-07-10 16:25:33 +0200
committerTimo Kösters <timo@koesters.xyz>2023-07-10 16:25:33 +0200
commit78e7b711df213559150b5c6e7e7da1967d353e23 (patch)
tree755af27ab0bfc92a7f91235bc495abfbe6c13825 /src
parent4b7d3e24dd0f8d1d9db2f7ba3ea2103a880a215c (diff)
downloadconduit-78e7b711df213559150b5c6e7e7da1967d353e23.zip
fix: better sliding sync
Diffstat (limited to 'src')
-rw-r--r--src/api/client_server/sync.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/api/client_server/sync.rs b/src/api/client_server/sync.rs
index bc89a4c..fed4fb7 100644
--- a/src/api/client_server/sync.rs
+++ b/src/api/client_server/sync.rs
@@ -23,7 +23,7 @@ use ruma::{
uint, DeviceId, OwnedDeviceId, OwnedUserId, RoomId, UInt, UserId,
};
use std::{
- collections::{hash_map::Entry, BTreeMap, BTreeSet, HashMap, HashSet},
+ collections::{hash_map::Entry, BTreeMap, HashMap, HashSet},
sync::Arc,
time::Duration,
};
@@ -1246,6 +1246,18 @@ pub async fn sync_events_v4_route(
let (timeline_pdus, limited) =
load_timeline(&sender_user, &room_id, sincecount, timeline_limit)?;
+ let prev_batch = timeline_pdus
+ .first()
+ .map_or(Ok::<_, Error>(None), |(pdu_count, _)| {
+ Ok(Some(match pdu_count {
+ PduCount::Backfilled(_) => {
+ error!("timeline in backfill state?!");
+ "0".to_owned()
+ }
+ PduCount::Normal(c) => c.to_string(),
+ }))
+ })?;
+
let room_events: Vec<_> = timeline_pdus
.iter()
.map(|(_, pdu)| pdu.to_sync_room_event())
@@ -1277,7 +1289,7 @@ pub async fn sync_events_v4_route(
},
timeline: room_events,
required_state,
- prev_batch: None,
+ prev_batch,
limited,
joined_count: Some(
(services()