Commit 86cbd7ae64

86cbd7ae6406d4fe0031fc63622a744554e844c8

parent: d91e1b28a3

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-07 09:40 UTC
committer: <strk@kbt.io>

fix: fetch restored backlog backwards

Layout: unified · split

src/room/mod.rs +24 −3
@@ -95,12 +95,34 @@ pub struct RoomHandle {
9595 inner: MatrixRoom,
9696}
9797
98#[derive(Debug, Clone)]
98#[derive(Debug, Clone, Eq, PartialEq)]
9999pub enum PrevBatch {
100100 Forward(String),
101101 Backwards(String),
102102}
103103
104fn restored_prev_batch(prev_batch: Option<String>) -> Option<PrevBatch> {
105 prev_batch.map(PrevBatch::Backwards)
106}
107
108#[cfg(test)]
109mod tests {
110 use super::{restored_prev_batch, PrevBatch};
111
112 #[test]
113 fn restored_rooms_fetch_history_backwards_from_prev_batch() {
114 assert_eq!(
115 restored_prev_batch(Some("token".to_owned())),
116 Some(PrevBatch::Backwards("token".to_owned()))
117 );
118 }
119
120 #[test]
121 fn restored_rooms_without_prev_batch_have_no_history_request() {
122 assert_eq!(restored_prev_batch(None), None);
123 }
124}
125
104126impl Deref for RoomHandle {
105127 type Target = MatrixRoom;
106128
@@ -366,8 +388,7 @@ impl RoomHandle {
366388 room_buffer.members.restore_member(user_id).await;
367389 }
368390
369 *room_buffer.prev_batch.borrow_mut() =
370 prev_batch.map(PrevBatch::Forward);
391 *room_buffer.prev_batch.borrow_mut() = restored_prev_batch(prev_batch);
371392
372393 room_buffer.buffer.update_buffer_name();
373394 room_buffer.buffer.set_topic();