Skip to content
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

crypto: Sort IdentityStatusChanges when providing them via subscribe_to_identity_status_changes #4114

Merged
merged 1 commit into from
Oct 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn state_of(user_identity: &UserIdentity) -> IdentityState {
/// A change in the status of the identity of a member of the room. Returned by
/// [`RoomIdentityState::process_change`] to indicate that something changed in
/// this room and we should either show or hide a warning.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct IdentityStatusChange {
/// The user ID of the user whose identity status changed
pub user_id: OwnedUserId,
Expand All @@ -214,7 +214,7 @@ pub struct IdentityStatusChange {
}

/// The state of an identity - verified, pinned etc.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
pub enum IdentityState {
/// The user is verified with us
Expand Down
8 changes: 6 additions & 2 deletions crates/matrix-sdk/src/room/identity_status_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,21 @@ impl IdentityStatusChanges {
};

Ok(stream!({
let current_state =
let mut current_state =
andybalaam marked this conversation as resolved.
Show resolved Hide resolved
filter_non_self(state.room_identity_state.current_state(), &own_user_id);

if !current_state.is_empty() {
current_state.sort();
yield current_state;
}

while let Some(item) = unprocessed_stream.next().await {
let update = filter_non_self(
let mut update = filter_non_self(
state.room_identity_state.process_change(item).await,
&own_user_id,
);
if !update.is_empty() {
update.sort();
yield update;
}
}
Expand Down
Loading