Skip to content

Commit 90d6cbe

Browse files
committed
sdk-ui: Add EncryptionState to RemoteEventTimelineItem
1 parent f00ada6 commit 90d6cbe

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

crates/matrix-sdk-ui/src/timeline/day_dividers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ enum DayDividerInsertError {
609609
mod tests {
610610
use assert_matches2::assert_let;
611611
use eyeball_im::ObservableVector;
612+
use matrix_sdk::deserialized_responses::EncryptionState;
612613
use ruma::{owned_event_id, owned_user_id, uint, MilliSecondsSinceUnixEpoch};
613614

614615
use super::DayDividerAdjuster;
@@ -626,7 +627,7 @@ mod tests {
626627
read_receipts: Default::default(),
627628
is_own: false,
628629
is_highlighted: false,
629-
encryption_info: None,
630+
encryption_state: EncryptionState::Unencrypted,
630631
original_json: None,
631632
latest_edit_json: None,
632633
origin: crate::timeline::event_item::RemoteEventOrigin::Sync,

crates/matrix-sdk-ui/src/timeline/event_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
600600
if let EventTimelineItemKind::Remote(remote_event) = &item.kind {
601601
if let Flow::Remote { encryption_state, .. } = &self.ctx.flow {
602602
new_item = new_item.with_kind(EventTimelineItemKind::Remote(
603-
remote_event.with_encryption_info(encryption_state.as_encryption_info().cloned())
603+
remote_event.with_encryption_state(encryption_state.clone())
604604
));
605605
}
606606
}
@@ -950,7 +950,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
950950
read_receipts: self.ctx.read_receipts.clone(),
951951
is_own: self.ctx.is_own_event,
952952
is_highlighted: self.ctx.is_highlighted,
953-
encryption_info: encryption_state.as_encryption_info().cloned(),
953+
encryption_state: encryption_state.clone(),
954954
original_json: Some(raw_event.clone()),
955955
latest_edit_json: None,
956956
origin,

crates/matrix-sdk-ui/src/timeline/event_item/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl EventTimelineItem {
197197
read_receipts,
198198
is_own,
199199
is_highlighted,
200-
encryption_info: encryption_state.as_encryption_info().cloned(),
200+
encryption_state,
201201
original_json: Some(raw_sync_event),
202202
latest_edit_json,
203203
origin,
@@ -386,7 +386,9 @@ impl EventTimelineItem {
386386
pub fn encryption_info(&self) -> Option<&EncryptionInfo> {
387387
match &self.kind {
388388
EventTimelineItemKind::Local(_) => None,
389-
EventTimelineItemKind::Remote(remote_event) => remote_event.encryption_info.as_ref(),
389+
EventTimelineItemKind::Remote(remote_event) => {
390+
remote_event.encryption_state.as_encryption_info()
391+
}
390392
}
391393
}
392394

crates/matrix-sdk-ui/src/timeline/event_item/remote.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use std::fmt;
1616

1717
use indexmap::IndexMap;
18-
use matrix_sdk::deserialized_responses::EncryptionInfo;
18+
use matrix_sdk::deserialized_responses::EncryptionState;
1919
use ruma::{
2020
events::{receipt::Receipt, AnySyncTimelineEvent},
2121
serde::Raw,
@@ -46,7 +46,7 @@ pub(in crate::timeline) struct RemoteEventTimelineItem {
4646
pub is_highlighted: bool,
4747

4848
/// Encryption information.
49-
pub encryption_info: Option<EncryptionInfo>,
49+
pub encryption_state: EncryptionState,
5050

5151
/// JSON of the original event.
5252
///
@@ -68,9 +68,9 @@ pub(in crate::timeline) struct RemoteEventTimelineItem {
6868
}
6969

7070
impl RemoteEventTimelineItem {
71-
/// Clone the current event item, and update its `encryption_info`.
72-
pub fn with_encryption_info(&self, encryption_info: Option<EncryptionInfo>) -> Self {
73-
Self { encryption_info, ..self.clone() }
71+
/// Clone the current event item, and update its `encryption_state`.
72+
pub fn with_encryption_state(&self, encryption_state: EncryptionState) -> Self {
73+
Self { encryption_state, ..self.clone() }
7474
}
7575

7676
/// Clone the current event item, and redacts its fields.
@@ -101,7 +101,7 @@ impl fmt::Debug for RemoteEventTimelineItem {
101101
transaction_id,
102102
read_receipts,
103103
is_own,
104-
encryption_info,
104+
encryption_state,
105105
original_json: _,
106106
latest_edit_json: _,
107107
is_highlighted,
@@ -114,7 +114,7 @@ impl fmt::Debug for RemoteEventTimelineItem {
114114
.field("read_receipts", read_receipts)
115115
.field("is_own", is_own)
116116
.field("is_highlighted", is_highlighted)
117-
.field("encryption_info", encryption_info)
117+
.field("encryption_state", encryption_state)
118118
.field("origin", origin)
119119
.finish_non_exhaustive()
120120
}

0 commit comments

Comments
 (0)