fix: random timeline reloads
This commit is contained in:
parent
f56b463278
commit
12b0efac8b
4 changed files with 53 additions and 24 deletions
|
@ -22,7 +22,10 @@ use ruma::{
|
|||
EventId, Raw, RoomId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
use state_res::StateEvent;
|
||||
use std::{collections::BTreeMap, collections::HashMap, collections::HashSet, convert::TryFrom, iter, sync::Arc};
|
||||
use std::{
|
||||
collections::BTreeMap, collections::HashMap, collections::HashSet, convert::TryFrom, iter,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
use rocket::{get, post};
|
||||
|
@ -642,9 +645,15 @@ async fn join_room_by_id_helper(
|
|||
.expect("Found event_id in sorted events that is not in resolved state");
|
||||
|
||||
// We do not rebuild the PDU in this case only insert to DB
|
||||
let pdu_id = db.rooms.append_pdu(
|
||||
let count = db.globals.next_count()?;
|
||||
let mut pdu_id = room_id.as_bytes().to_vec();
|
||||
pdu_id.push(0xff);
|
||||
pdu_id.extend_from_slice(&count.to_be_bytes());
|
||||
db.rooms.append_pdu(
|
||||
&PduEvent::from(&**pdu),
|
||||
&serde_json::to_value(&**pdu).expect("PDU is valid value"),
|
||||
count,
|
||||
pdu_id.clone().into(),
|
||||
&db.globals,
|
||||
&db.account_data,
|
||||
&db.sending,
|
||||
|
|
|
@ -110,11 +110,11 @@ pub async fn sync_events_route(
|
|||
// since and the current room state, meaning there should be no updates.
|
||||
// The inner Option is None when there is an event, but there is no state hash associated
|
||||
// with it. This can happen for the RoomCreate event, so all updates should arrive.
|
||||
let since_state_hash = db
|
||||
.rooms
|
||||
.pdus_after(sender_id, &room_id, since) // - 1 So we can get the event at since
|
||||
.next()
|
||||
.map(|pdu| db.rooms.pdu_state_hash(&pdu.ok()?.0).ok()?);
|
||||
let first_pdu_after_since = db.rooms.pdus_after(sender_id, &room_id, since).next();
|
||||
|
||||
let since_state_hash = first_pdu_after_since
|
||||
.as_ref()
|
||||
.map(|pdu| db.rooms.pdu_state_hash(&pdu.as_ref().ok()?.0).ok()?);
|
||||
|
||||
let since_members = since_state_hash.as_ref().map(|state_hash| {
|
||||
state_hash.as_ref().and_then(|state_hash| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue