Skip to content

refactor(timeline): replace TimelineEventKind with TimelineAction #4655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
273f07c
refactor(timeline): remove spurious `FullEventMeta::is_own_event`
bnjbvr Feb 11, 2025
9a42360
refactor(timeline): remove another spurious `is_own_event`
bnjbvr Feb 11, 2025
8530c51
refactor(timeline): bury one use of `TimelineEventKind`
bnjbvr Feb 11, 2025
db63d14
refactor(timeline): introduce a new `TimelineEventKind::AddItem` variant
bnjbvr Feb 11, 2025
bc2ec8c
refactor(timeline): use `TimelineEventKind::AddItem` to insert failed…
bnjbvr Feb 11, 2025
db5ec99
refactor(timeline): use `TimelineEventKind::AddItem` for UTDs
bnjbvr Feb 11, 2025
12c9a39
refactor(timeline): use `TimelineEventKind::AddItem` for redacted mes…
bnjbvr Feb 11, 2025
1401f38
refactor(timeline): use `TimelineEventKind::AddItem` for room member …
bnjbvr Feb 11, 2025
68863e4
refactor(timeline): add a small helper function to create `TimelineEv…
bnjbvr Feb 11, 2025
abdee20
refactor(timeline): introduce `TimelineEventKind::HandleAggregation` …
bnjbvr May 12, 2025
c99d96f
refactor(timeline): use `TimelineEventKind::HandleAggregation` for re…
bnjbvr May 12, 2025
9b2ef90
refactor(timeline): use `TimelineEventKind::HandleAggregation` for edits
bnjbvr May 12, 2025
308ae0a
refactor(timeline): use `TimelineEventKind::HandleAggregation` for po…
bnjbvr May 12, 2025
c13ac35
refactor(timeline): use `TimelineEventKind::AddItem` for call invite/…
bnjbvr May 12, 2025
ac05a6f
refactor(timeline): use `TimelineEventKind::AddItem` for poll starts
bnjbvr May 12, 2025
0200fd6
refactor(timeline): use `TimelineEventKind::AddItem` for most room me…
bnjbvr May 12, 2025
4d74299
refactor(timeline): get rid of `TimelineEventKind::Message`
bnjbvr May 12, 2025
c1c16e5
refactor(timeline): rename `TimelineEventKind` into `TimelineAction` …
bnjbvr May 12, 2025
802049f
refactor(timeline): simplify lightly computation of should_add_new_it…
bnjbvr May 12, 2025
b8469a4
doc(timeline): add extra documentation for `HandleAggregationKind`
bnjbvr May 13, 2025
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
97 changes: 52 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/controller/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(in crate::timeline) struct TimelineMetadata {
pub room_version: RoomVersionId,

/// The own [`OwnedUserId`] of the client who opened the timeline.
own_user_id: OwnedUserId,
pub(crate) own_user_id: OwnedUserId,

// **** DYNAMIC FIELDS ****
/// The next internal identifier for timeline items, used for both local and
Expand Down
24 changes: 4 additions & 20 deletions crates/matrix-sdk-ui/src/timeline/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub(super) use self::{
};
use super::{
algorithms::{rfind_event_by_id, rfind_event_item},
event_handler::TimelineEventKind,
event_item::{ReactionStatus, RemoteEventOrigin},
item::TimelineUniqueId,
subscriber::TimelineSubscriber,
Expand Down Expand Up @@ -781,28 +780,17 @@ impl<P: RoomDataProvider, D: Decryptor> TimelineController<P, D> {
pub(super) async fn handle_local_event(
&self,
txn_id: OwnedTransactionId,
content: TimelineEventKind,
content: AnyMessageLikeEventContent,
send_handle: Option<SendHandle>,
) {
let sender = self.room_data_provider.own_user_id().to_owned();
let profile = self.room_data_provider.profile_from_user_id(&sender).await;

// Only add new items if the timeline is live.
let should_add_new_items = self.is_live().await;

let date_divider_mode = self.settings.date_divider_mode.clone();

let mut state = self.state.write().await;
state
.handle_local_event(
sender,
profile,
should_add_new_items,
date_divider_mode,
txn_id,
send_handle,
content,
)
.handle_local_event(sender, profile, date_divider_mode, txn_id, send_handle, content)
.await;
}

Expand Down Expand Up @@ -1204,12 +1192,8 @@ impl<P: RoomDataProvider, D: Decryptor> TimelineController<P, D> {
}
};

self.handle_local_event(
echo.transaction_id.clone(),
TimelineEventKind::Message { content, relations: Default::default() },
Some(send_handle),
)
.await;
self.handle_local_event(echo.transaction_id.clone(), content, Some(send_handle))
.await;

if let Some(send_error) = send_error {
self.update_event_send_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl TimelineStateTransaction<'_> {
/// "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, is_own_event, timestamp, .. } = event_meta;
let FullEventMeta { event_id, sender, timestamp, .. } = event_meta;

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.
Expand All @@ -569,6 +569,7 @@ impl TimelineStateTransaction<'_> {
let full_receipt =
FullReceipt { event_id, user_id, receipt_type: ReceiptType::Read, receipt: &receipt };

let is_own_event = sender.is_some_and(|sender| sender == self.meta.own_user_id);
self.meta.read_receipts.maybe_update_read_receipt(
full_receipt,
is_own_event,
Expand Down
Loading
Loading