mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-07 23:44:53 -04:00
refactor(sdk): Add private method to get the fully-read event for a timeline.
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Jonas Platte
parent
4041c875d1
commit
1c9aa7c907
@@ -20,10 +20,7 @@ use matrix_sdk_base::{
|
||||
locks::Mutex,
|
||||
};
|
||||
use ruma::{
|
||||
events::{
|
||||
fully_read::FullyReadEventContent,
|
||||
receipt::{ReceiptThread, ReceiptType, SyncReceiptEvent},
|
||||
},
|
||||
events::receipt::{ReceiptThread, ReceiptType, SyncReceiptEvent},
|
||||
push::Action,
|
||||
};
|
||||
use tracing::error;
|
||||
@@ -155,20 +152,7 @@ impl TimelineBuilder {
|
||||
];
|
||||
|
||||
if track_read_marker_and_receipts {
|
||||
match room.account_data_static::<FullyReadEventContent>().await {
|
||||
Ok(Some(fully_read)) => match fully_read.deserialize() {
|
||||
Ok(fully_read) => {
|
||||
inner.set_fully_read_event(fully_read.content.event_id).await;
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to deserialize fully-read account data: {e}");
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Failed to get fully-read account data from the store: {e}");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
inner.load_fully_read_event().await;
|
||||
|
||||
let fully_read_handle = room.add_event_handler({
|
||||
let inner = inner.clone();
|
||||
|
||||
@@ -504,6 +504,31 @@ impl TimelineInner {
|
||||
&self.room_data_provider
|
||||
}
|
||||
|
||||
/// Get the current fully-read event.
|
||||
pub(super) async fn fully_read_event(&self) -> Option<FullyReadEvent> {
|
||||
match self.room().account_data_static().await {
|
||||
Ok(Some(fully_read)) => match fully_read.deserialize() {
|
||||
Ok(fully_read) => Some(fully_read),
|
||||
Err(e) => {
|
||||
error!("Failed to deserialize fully-read account data: {e}");
|
||||
None
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Failed to get fully-read account data from the store: {e}");
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Load the current fully-read event in this inner timeline.
|
||||
pub(super) async fn load_fully_read_event(&self) {
|
||||
if let Some(fully_read) = self.fully_read_event().await {
|
||||
self.set_fully_read_event(fully_read.content.event_id).await;
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn fetch_in_reply_to_details(
|
||||
&self,
|
||||
event_id: &EventId,
|
||||
|
||||
Reference in New Issue
Block a user