From fd26cbcfcbbc13b4d56ea86ed7e61451c0e5a113 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 30 Jan 2024 14:54:24 +0100 Subject: [PATCH] ffi: get rid of `Room::poll_history` as it's slow and likely unused It's super slow (as it recreates and backpaginates from the start again) and unused in both EX apps, which are our main FFI embedders. --- bindings/matrix-sdk-ffi/src/room.rs | 4 --- crates/matrix-sdk-ui/src/timeline/traits.rs | 28 +++------------------ 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index 4228c7695..865f78039 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -150,10 +150,6 @@ impl Room { } } - pub async fn poll_history(&self) -> Result, ClientError> { - Ok(Timeline::new(self.inner.poll_history().await?)) - } - pub fn display_name(&self) -> Result { let r = self.inner.clone(); RUNTIME.block_on(async move { Ok(r.display_name().await?.to_string()) }) diff --git a/crates/matrix-sdk-ui/src/timeline/traits.rs b/crates/matrix-sdk-ui/src/timeline/traits.rs index a2a4a39ec..d772bdc9d 100644 --- a/crates/matrix-sdk-ui/src/timeline/traits.rs +++ b/crates/matrix-sdk-ui/src/timeline/traits.rs @@ -18,16 +18,13 @@ use matrix_sdk::Room; #[cfg(feature = "e2e-encryption")] use matrix_sdk::{deserialized_responses::TimelineEvent, Result}; use matrix_sdk_base::latest_event::LatestEvent; -#[cfg(feature = "e2e-encryption")] -use ruma::{events::AnySyncTimelineEvent, serde::Raw}; use ruma::{ - events::{ - receipt::{Receipt, ReceiptThread, ReceiptType}, - AnySyncMessageLikeEvent, - }, + events::receipt::{Receipt, ReceiptThread, ReceiptType}, push::{PushConditionRoomCtx, Ruleset}, EventId, OwnedEventId, OwnedUserId, RoomVersionId, UserId, }; +#[cfg(feature = "e2e-encryption")] +use ruma::{events::AnySyncTimelineEvent, serde::Raw}; use tracing::{debug, error, warn}; use super::{Profile, TimelineBuilder}; @@ -53,9 +50,6 @@ pub trait RoomExt { /// This allows to customize settings of the [`Timeline`] before /// constructing it. fn timeline_builder(&self) -> TimelineBuilder; - - /// Get a [`Timeline`] for this room, filtered to only include poll events. - async fn poll_history(&self) -> crate::event_graph::Result; } #[async_trait] @@ -67,22 +61,6 @@ impl RoomExt for Room { fn timeline_builder(&self) -> TimelineBuilder { Timeline::builder(self).track_read_marker_and_receipts() } - - async fn poll_history(&self) -> crate::event_graph::Result { - self.timeline_builder() - .event_filter(|e, _| { - matches!( - e, - AnySyncTimelineEvent::MessageLike( - AnySyncMessageLikeEvent::UnstablePollStart(_) - | AnySyncMessageLikeEvent::UnstablePollResponse(_) - | AnySyncMessageLikeEvent::UnstablePollEnd(_) - ) - ) - }) - .build() - .await - } } #[async_trait]