Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bindings/matrix-sdk-ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ All notable changes to this project will be documented in this file.

### Refactor

- [**breaking**] `LiveLocationShares` has been renamed to `RoomLiveLocationService`.
([#6446](https://github.com/matrix-org/matrix-rust-sdk/pull/6446))
- [**breaking**] `Room::observe_live_location_shares` has been replaced by
`Room::live_location_shares`. Call [`LiveLocationShares::subscribe`] on it to
`Room::live_location_shares`. Call [`RoomLiveLocationService::subscribe`] on it to
receive an initial snapshot and a stream of incremental updates.The stream is seeded from the event cache
on creation and includes the own user's shares (previously excluded). `LiveLocationShare.is_live`
has been removed; instead `ts` (start timestamp) and `timeout` (duration in milliseconds) are now
Expand Down
18 changes: 9 additions & 9 deletions bindings/matrix-sdk-ffi/src/live_location_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{fmt::Debug, sync::Arc};
use eyeball_im::VectorDiff;
use futures_util::StreamExt as _;
use matrix_sdk::live_location_share::{
LiveLocationShare as SdkLiveLocationShare, LiveLocationShares as SdkLiveLocationShares,
LiveLocationShare as SdkLiveLocationShare, RoomLiveLocationService as SdkRoomLiveLocationService,
};
use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm};

Expand Down Expand Up @@ -76,22 +76,22 @@ pub trait LiveLocationShareListener: SendOutsideWasm + SyncOutsideWasm + Debug {

/// Tracks active live location shares in a room.
///
/// Holds the SDK [`SdkLiveLocationShares`] which keeps the beacon and
/// Holds the SDK [`SdkRoomLiveLocationService`] which keeps the beacon and
/// beacon_info event handlers registered for as long as this object is alive.
/// Call [`LiveLocationShares::subscribe`] to start receiving updates.
/// Call [`RoomLiveLocationService::subscribe`] to start receiving updates.
#[derive(uniffi::Object)]
pub struct LiveLocationShares {
inner: SdkLiveLocationShares,
pub struct RoomLiveLocationService {
inner: SdkRoomLiveLocationService,
}

impl LiveLocationShares {
pub fn new(inner: SdkLiveLocationShares) -> Self {
impl RoomLiveLocationService {
pub fn new(inner: SdkRoomLiveLocationService) -> Self {
Self { inner }
}
}

#[matrix_sdk_ffi_macros::export]
impl LiveLocationShares {
impl RoomLiveLocationService {
/// Subscribe to changes in the list of active live location shares.
///
/// Immediately calls `listener` with a `Reset` update containing the
Expand All @@ -100,7 +100,7 @@ impl LiveLocationShares {
///
/// Returns a [`TaskHandle`] that, when dropped, stops the listener.
/// The event handlers remain registered for as long as this
/// [`LiveLocationShares`] object is alive.
/// [`RoomLiveLocationService`] object is alive.
pub fn subscribe(&self, listener: Box<dyn LiveLocationShareListener>) -> Arc<TaskHandle> {
let (initial_values, mut stream) = self.inner.subscribe();

Expand Down
10 changes: 5 additions & 5 deletions bindings/matrix-sdk-ffi/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use crate::{
error::{ClientError, MediaInfoError, NotYetImplemented, QueueWedgeError, RoomError},
event::TimelineEvent,
identity_status_change::IdentityStatusChange,
live_location_share::LiveLocationShares,
live_location_share::RoomLiveLocationService,
room_member::{RoomMember, RoomMemberWithSenderInfo},
room_preview::RoomPreview,
ruma::{AudioInfo, FileInfo, ImageInfo, MediaSource, ThumbnailInfo, VideoInfo},
Expand Down Expand Up @@ -1138,14 +1138,14 @@ impl Room {

/// Returns the active live location shares for this room.
///
/// The returned [`LiveLocationShares`] object tracks which users are
/// The returned [`RoomLiveLocationService`] object tracks which users are
/// currently sharing their live location. It keeps the underlying event
/// handlers registered — and therefore the share list up-to-date — for as
/// long as it is alive. Call [`LiveLocationShares::subscribe`] on it to
/// long as it is alive. Call [`RoomLiveLocationService::subscribe`] on it to
/// receive an initial snapshot and a stream of incremental updates.
pub async fn live_location_shares(&self) -> Arc<LiveLocationShares> {
pub async fn live_location_shares(&self) -> Arc<RoomLiveLocationService> {
Comment thread
Velin92 marked this conversation as resolved.
Outdated
let inner = self.inner.live_location_shares().await;
Arc::new(LiveLocationShares::new(inner))
Arc::new(RoomLiveLocationService::new(inner))
}

/// Forget this room.
Expand Down
3 changes: 3 additions & 0 deletions crates/matrix-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ All notable changes to this project will be documented in this file.

### Breaking Changes

- [**breaking**] `LiveLocationShares` has been renamed to `RoomLiveLocationService`.
([#6446](https://github.com/matrix-org/matrix-rust-sdk/pull/6446))

- `Room::observe_live_location_shares` has been replaced by `Room::live_location_shares`.
The new API returns a `LiveLocationShares` struct with a `subscribe()` method that provides an initial
snapshot (`Vector<LiveLocationShare>`) and a batched stream of `VectorDiff` updates, instead of
Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk/src/live_location_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ pub struct LiveLocationShare {
///
/// Registers event handlers for beacon (location update) and beacon info
/// (share started/stopped) events and reflects changes into a vector that
/// callers can subscribe to via [`LiveLocationShares::subscribe`].
/// callers can subscribe to via [`RoomLiveLocationService::subscribe`].
///
/// Event handlers are automatically unregistered when this struct is dropped.
#[derive(Debug)]
pub struct LiveLocationShares {
pub struct RoomLiveLocationService {
shares: Arc<Mutex<ObservableVector<LiveLocationShare>>>,
_beacon_guard: EventHandlerDropGuard,
_beacon_info_guard: EventHandlerDropGuard,
}

impl LiveLocationShares {
/// Create a new [`LiveLocationShares`] for the given room.
impl RoomLiveLocationService {
/// Create a new [`RoomLiveLocationService`] for the given room.
///
/// Loads the current active shares from the event cache as initial state,
/// then begins listening for beacon events to keep the vector up-to-date.
Expand Down
10 changes: 5 additions & 5 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ use crate::{
error::{BeaconError, WrongRoomState},
event_cache::{self, EventCacheDropHandles, RoomEventCache},
event_handler::{EventHandler, EventHandlerDropGuard, EventHandlerHandle, SyncEvent},
live_location_share::LiveLocationShares,
live_location_share::RoomLiveLocationService,
media::{MediaFormat, MediaRequestParameters},
notification_settings::{IsEncrypted, IsOneToOne, RoomNotificationMode},
room::{
Expand Down Expand Up @@ -719,13 +719,13 @@ impl Room {

/// Subscribes to active live location shares in this room.
///
/// Returns a [`LiveLocationShares`] that holds the current state and
/// Returns a [`RoomLiveLocationService`] that holds the current state and
/// exposes a stream of incremental [`eyeball_im::VectorDiff`] updates via
/// [`LiveLocationShares::subscribe`].
/// [`RoomLiveLocationService::subscribe`].
///
/// Event handlers are active for as long as the returned struct is alive.
pub async fn live_location_shares(&self) -> LiveLocationShares {
LiveLocationShares::new(self.clone()).await
pub async fn live_location_shares(&self) -> RoomLiveLocationService {
RoomLiveLocationService::new(self.clone()).await
}

/// Returns a wrapping `TimelineEvent` for the input `AnyTimelineEvent`,
Expand Down
Loading