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

ffi: add previous power levels to OtherState::RoomPowerLevels #3199

Merged
Merged
Changes from 3 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
18 changes: 15 additions & 3 deletions bindings/matrix-sdk-ffi/src/timeline/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ pub enum OtherState {
RoomJoinRules,
RoomName { name: Option<String> },
RoomPinnedEvents,
RoomPowerLevels { users: HashMap<String, i64> },
RoomPowerLevels { users: HashMap<String, i64>, previous: Option<HashMap<String, i64>> },
RoomServerAcl,
RoomThirdPartyInvite { display_name: Option<String> },
RoomTombstone,
Expand Down Expand Up @@ -354,7 +354,19 @@ impl From<&matrix_sdk_ui::timeline::AnyOtherFullStateEventContent> for OtherStat
}
Content::RoomPinnedEvents(_) => Self::RoomPinnedEvents,
Content::RoomPowerLevels(c) => {
let changes = match c {
let previous: Option<HashMap<String, i64>> = match c {
FullContent::Original { prev_content, .. } => {
prev_content.as_ref().map(|prev_content| {
prev_content
.users
.iter()
.map(|(k, &v)| (k.to_string(), v.into()))
.collect()
})
}
FullContent::Redacted(_) => None,
};
let users: HashMap<String, i64> = match c {
FullContent::Original { content, prev_content } => {
power_level_user_changes(content, prev_content)
.iter()
Expand All @@ -363,7 +375,7 @@ impl From<&matrix_sdk_ui::timeline::AnyOtherFullStateEventContent> for OtherStat
}
FullContent::Redacted(_) => Default::default(),
};
Self::RoomPowerLevels { users: changes }
Self::RoomPowerLevels { users, previous }
}
Content::RoomServerAcl(_) => Self::RoomServerAcl,
Content::RoomThirdPartyInvite(c) => {
Expand Down
Loading