Commit e289083eeb
Unsigned
Layout: unified · split
src/room/mod.rs +12 −13
| @@ -142,12 +142,12 @@ const HISTORY_PAGE_TAGS: [&str; 2] = | |||
| 142 | const RESTORED_HISTORY_BATCH_SIZE: u16 = 25; | 142 | const RESTORED_HISTORY_BATCH_SIZE: u16 = 25; |
| 143 | const INTERACTIVE_HISTORY_BATCH_SIZE: u16 = 25; | 143 | const INTERACTIVE_HISTORY_BATCH_SIZE: u16 = 25; |
| 144 | 144 | ||
| 145 | fn restored_prev_batch(prev_batch: Option<String>) -> Option<PrevBatch> { | 145 | fn restored_prev_batch(_prev_batch: Option<String>) -> Option<PrevBatch> { |
| 146 | // A restored SDK room does not always have a sync pagination token in its | 146 | // The SDK does not replay the stored sync timeline when a room is restored. |
| 147 | // store. Matrix permits a backward /messages request without `from`, which | 147 | // Its last_prev_batch token points before that timeline, so using it here |
| 148 | // starts at the newest visible event. Keep that request representable so a | 148 | // skips the newest messages entirely. Start at the current room end; the |
| 149 | // freshly restored room can still populate its WeeChat buffer. | 149 | // response's end token will drive older backward pagination afterwards. |
| 150 | Some(PrevBatch::Backwards(prev_batch)) | 150 | Some(PrevBatch::Backwards(None)) |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | fn has_history_page(prev_batch: &Option<PrevBatch>) -> bool { | 153 | fn has_history_page(prev_batch: &Option<PrevBatch>) -> bool { |
| @@ -2872,10 +2872,10 @@ mod tests { | |||
| 2872 | } | 2872 | } |
| 2873 | 2873 | ||
| 2874 | #[test] | 2874 | #[test] |
| 2875 | fn restored_rooms_fetch_history_backwards_from_prev_batch() { | 2875 | fn restored_rooms_fetch_newest_history_before_older_pages() { |
| 2876 | assert_eq!( | 2876 | assert_eq!( |
| 2877 | restored_prev_batch(Some("token".to_owned())), | 2877 | restored_prev_batch(Some("token".to_owned())), |
| 2878 | Some(PrevBatch::Backwards(Some("token".to_owned()))) | 2878 | Some(PrevBatch::Backwards(None)) |
| 2879 | ); | 2879 | ); |
| 2880 | } | 2880 | } |
| 2881 | 2881 | ||
| @@ -2996,8 +2996,8 @@ mod tests { | |||
| 2996 | 2996 | ||
| 2997 | #[test] | 2997 | #[test] |
| 2998 | fn reply_event_details_extract_sender_and_body() { | 2998 | fn reply_event_details_extract_sender_and_body() { |
| 2999 | let event: AnySyncTimelineEvent = serde_json::from_value( | 2999 | let event: AnySyncTimelineEvent = |
| 3000 | serde_json::json!({ | 3000 | serde_json::from_value(serde_json::json!({ |
| 3001 | "type": "m.room.message", | 3001 | "type": "m.room.message", |
| 3002 | "event_id": "$original:example.org", | 3002 | "event_id": "$original:example.org", |
| 3003 | "sender": "@alice:example.org", | 3003 | "sender": "@alice:example.org", |
| @@ -3007,9 +3007,8 @@ mod tests { | |||
| 3007 | "body": "original message" | 3007 | "body": "original message" |
| 3008 | }, | 3008 | }, |
| 3009 | "unsigned": {} | 3009 | "unsigned": {} |
| 3010 | }), | 3010 | })) |
| 3011 | ) | 3011 | .expect("valid Matrix event"); |
| 3012 | .expect("valid Matrix event"); | ||
| 3013 | 3012 | ||
| 3014 | assert_eq!( | 3013 | assert_eq!( |
| 3015 | reply_event_details(event), | 3014 | reply_event_details(event), |