From 616fbe94065ec86edad2c07b19c096635036dc10 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 7 Jan 2025 20:03:38 +0100 Subject: [PATCH] refactor: Make experimental-sliding-sync compile on WASM Unfortunately the matrix_sdk::Client is not Send on WASM, which is probably not going to be easy to fix. Since PreviousEventsProvider is never used as a trait object, there should be no harm in relaxing its supertraits (on WASM). --- crates/matrix-sdk-base/src/read_receipts.rs | 7 +++++-- crates/matrix-sdk/src/sliding_sync/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/matrix-sdk-base/src/read_receipts.rs b/crates/matrix-sdk-base/src/read_receipts.rs index 5b640658cb6..5ededbfb192 100644 --- a/crates/matrix-sdk-base/src/read_receipts.rs +++ b/crates/matrix-sdk-base/src/read_receipts.rs @@ -123,7 +123,10 @@ use std::{ }; use eyeball_im::Vector; -use matrix_sdk_common::{deserialized_responses::SyncTimelineEvent, ring_buffer::RingBuffer}; +use matrix_sdk_common::{ + deserialized_responses::SyncTimelineEvent, ring_buffer::RingBuffer, SendOutsideWasm, + SyncOutsideWasm, +}; use ruma::{ events::{ poll::{start::PollStartEventContent, unstable_start::UnstablePollStartEventContent}, @@ -266,7 +269,7 @@ impl RoomReadReceipts { } /// Provider for timeline events prior to the current sync. -pub trait PreviousEventsProvider: Send + Sync { +pub trait PreviousEventsProvider: SendOutsideWasm + SyncOutsideWasm { /// Returns the list of known timeline events, in sync order, for the given /// room. fn for_room(&self, room_id: &RoomId) -> Vector; diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 9e6494b155d..13933b69789 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -36,14 +36,14 @@ use async_stream::stream; pub use client::{Version, VersionBuilder}; use futures_core::stream::Stream; pub use matrix_sdk_base::sliding_sync::http; -use matrix_sdk_common::{deserialized_responses::SyncTimelineEvent, timer}; +use matrix_sdk_common::{deserialized_responses::SyncTimelineEvent, executor::spawn, timer}; use ruma::{ api::{client::error::ErrorKind, OutgoingRequest}, assign, OwnedEventId, OwnedRoomId, RoomId, }; use serde::{Deserialize, Serialize}; use tokio::{ - select, spawn, + select, sync::{broadcast::Sender, Mutex as AsyncMutex, OwnedMutexGuard, RwLock as AsyncRwLock}, }; use tracing::{debug, error, info, instrument, trace, warn, Instrument, Span};