Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
182 changes: 0 additions & 182 deletions crates/matrix-sdk-ui/src/events.rs

This file was deleted.

5 changes: 1 addition & 4 deletions crates/matrix-sdk-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
#![cfg_attr(target_arch = "wasm32", allow(clippy::arc_with_non_send_sync))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

use ruma::html::HtmlSanitizerMode;

mod events;

pub use eyeball_im;
use ruma::html::HtmlSanitizerMode;

pub mod encryption_sync_service;
pub mod notification_client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ pub(crate) fn find_item_and_apply_aggregation(
items: &mut ObservableItemsTransaction<'_>,
target: &TimelineEventItemId,
aggregation: Aggregation,
) -> bool {
) {
let Some((idx, event_item)) = rfind_event_by_item_id(items, target) else {
trace!("couldn't find aggregation's target {target:?}");
return false;
return;
};

let mut new_content = event_item.content().clone();
Expand All @@ -414,15 +414,12 @@ pub(crate) fn find_item_and_apply_aggregation(
trace!("applied aggregation");
let new_item = event_item.with_content(new_content);
items.replace(idx, TimelineItem::new(new_item, event_item.internal_id.to_owned()));
true
}
ApplyAggregationResult::LeftItemIntact => {
trace!("applying the aggregation had no effect");
false
}
ApplyAggregationResult::Error(err) => {
warn!("error when applying aggregation: {err}");
false
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/matrix-sdk-ui/src/timeline/controller/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,9 @@ pub(in crate::timeline) struct EventMeta {
/// remote event, but if it moves, it has an impact on this mapping.
pub timeline_item_index: Option<usize>,
}

impl EventMeta {
pub fn new(event_id: OwnedEventId, visible: bool) -> Self {
Self { event_id, visible, timeline_item_index: None }
}
}
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(super) use self::{
AllRemoteEvents, ObservableItems, ObservableItemsEntry, ObservableItemsTransaction,
ObservableItemsTransactionEntry,
},
state::{FullEventMeta, PendingEdit, PendingEditKind, TimelineState},
state::{PendingEdit, PendingEditKind, TimelineState},
state_transaction::TimelineStateTransaction,
};
use super::{
Expand Down
15 changes: 9 additions & 6 deletions crates/matrix-sdk-ui/src/timeline/controller/read_receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ use futures_core::Stream;
use indexmap::IndexMap;
use ruma::{
events::receipt::{Receipt, ReceiptEventContent, ReceiptThread, ReceiptType},
EventId, OwnedEventId, OwnedUserId, UserId,
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, UserId,
};
use tokio::sync::watch;
use tokio_stream::wrappers::WatchStream;
use tracing::{debug, error, instrument, trace, warn};

use super::{
rfind_event_by_id, AllRemoteEvents, FullEventMeta, ObservableItemsTransaction,
RelativePosition, RoomDataProvider, TimelineMetadata, TimelineState,
rfind_event_by_id, AllRemoteEvents, ObservableItemsTransaction, RelativePosition,
RoomDataProvider, TimelineMetadata, TimelineState,
};
use crate::timeline::{controller::TimelineStateTransaction, TimelineItem};

Expand Down Expand Up @@ -555,9 +555,12 @@ impl TimelineStateTransaction<'_> {
/// count, so we need to handle them locally too. For that we create an
/// "implicit" read receipt, compared to the "explicit" ones sent by the
/// client.
pub(super) fn maybe_add_implicit_read_receipt(&mut self, event_meta: FullEventMeta<'_>) {
let FullEventMeta { event_id, sender, timestamp, .. } = event_meta;

pub(super) fn maybe_add_implicit_read_receipt(
&mut self,
event_id: &EventId,
sender: Option<&UserId>,
timestamp: Option<MilliSecondsSinceUnixEpoch>,
) {
let (Some(user_id), Some(timestamp)) = (sender, timestamp) else {
// We cannot add a read receipt if we do not know the user or the timestamp.
return;
Expand Down
33 changes: 4 additions & 29 deletions crates/matrix-sdk-ui/src/timeline/controller/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use ruma::{
},
serde::Raw,
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedTransactionId, OwnedUserId,
RoomVersionId, UserId,
RoomVersionId,
};
use tracing::{instrument, trace, warn};

Expand All @@ -40,7 +40,6 @@ use super::{
traits::RoomDataProvider,
Profile, TimelineItem,
},
metadata::EventMeta,
observable_items::ObservableItems,
DateDividerMode, TimelineFocusKind, TimelineMetadata, TimelineSettings,
TimelineStateTransaction,
Expand Down Expand Up @@ -204,7 +203,7 @@ impl TimelineState {
continue;
};

let handle_one_res = txn
let removed_item = txn
.handle_remote_event(
event,
TimelineItemPosition::UpdateAt { timeline_item_index: idx },
Expand All @@ -216,7 +215,7 @@ impl TimelineState {

// If the UTD was removed rather than updated, offset all
// subsequent loop iterations.
if handle_one_res.item_removed {
if removed_item {
offset += 1;
}
}
Expand All @@ -230,7 +229,7 @@ impl TimelineState {
pub(super) fn handle_read_receipts(
&mut self,
receipt_event_content: ReceiptEventContent,
own_user_id: &UserId,
own_user_id: &ruma::UserId,
) {
let mut txn = self.transaction();
txn.handle_explicit_read_receipts(receipt_event_content, own_user_id);
Expand Down Expand Up @@ -316,27 +315,3 @@ impl std::fmt::Debug for PendingEdit {
}
}
}

/// Full metadata about an event.
///
/// Only used to group function parameters.
pub(crate) struct FullEventMeta<'a> {
/// The ID of the event.
pub event_id: &'a EventId,
/// Whether the event is among the timeline items.
pub visible: bool,
/// The sender of the event.
pub sender: Option<&'a UserId>,
/// The timestamp of the event.
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
}

impl FullEventMeta<'_> {
pub(super) fn base_meta(&self) -> EventMeta {
EventMeta {
event_id: self.event_id.to_owned(),
visible: self.visible,
timeline_item_index: None,
}
}
}
Loading
Loading