diff --git a/fractal-gtk/src/appop/member.rs b/fractal-gtk/src/appop/member.rs index c7edcc6b..0649f2f2 100644 --- a/fractal-gtk/src/appop/member.rs +++ b/fractal-gtk/src/appop/member.rs @@ -26,7 +26,7 @@ impl AppOp { .rooms .get(&self.active_room.clone().unwrap_or_default()) { - if let Some(level) = r.power_levels.get(&member.uid) { + if let Some(level) = r.admins.get(&member.uid) { return *level; } } diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs index 56ea6dc6..dd7fcbf3 100644 --- a/fractal-gtk/src/appop/message.rs +++ b/fractal-gtk/src/appop/message.rs @@ -441,11 +441,11 @@ impl AppOp { }; let uid = self.uid.clone().unwrap_or_default(); - let power_level = match self.uid.clone().and_then(|uid| room.power_levels.get(&uid)) { + let admin = match self.uid.clone().and_then(|uid| room.admins.get(&uid)) { Some(&pl) => pl, None => 0, }; - let redactable = power_level != 0 || uid == msg.sender; + let redactable = admin != 0 || uid == msg.sender; let is_last_viewed = msg.receipt.contains_key(&uid); Some(create_ui_message( diff --git a/fractal-gtk/src/widgets/members_list.rs b/fractal-gtk/src/widgets/members_list.rs index cbfaf295..ad34b703 100644 --- a/fractal-gtk/src/widgets/members_list.rs +++ b/fractal-gtk/src/widgets/members_list.rs @@ -18,13 +18,13 @@ pub struct MembersList { search_entry: gtk::SearchEntry, error: gtk::Label, members: Vec, - power_levels: HashMap, + admins: HashMap, } impl MembersList { pub fn new( m: Vec, - power_levels: HashMap, + admins: HashMap, entry: gtk::SearchEntry, ) -> MembersList { MembersList { @@ -32,7 +32,7 @@ impl MembersList { error: gtk::Label::new(None), members: m, search_entry: entry, - power_levels: power_levels, + admins: admins, } } @@ -45,7 +45,7 @@ impl MembersList { add_rows( self.container.clone(), self.members.clone(), - self.power_levels.clone(), + self.admins.clone(), ); self.error.get_style_context().add_class("no_member_search"); self.error.set_text(&i18n("No matching members found")); @@ -206,15 +206,15 @@ fn load_row_content(member: Member, power_level: Option) -> gtk::Box { fn add_rows( container: gtk::ListBox, members: Vec, - power_levels: HashMap, + admins: HashMap, ) -> Option { /* Load just enough members to fill atleast the visible list */ for member in members.iter() { - let power_level = match power_levels.get(&member.uid) { + let admin = match admins.get(&member.uid) { Some(pl) => Some(*pl), None => None, }; - container.insert(&create_row(member.clone(), power_level)?, -1); + container.insert(&create_row(member.clone(), admin)?, -1); } None } diff --git a/fractal-gtk/src/widgets/room_settings.rs b/fractal-gtk/src/widgets/room_settings.rs index 8e7b873d..466140d3 100644 --- a/fractal-gtk/src/widgets/room_settings.rs +++ b/fractal-gtk/src/widgets/room_settings.rs @@ -186,7 +186,7 @@ impl RoomSettings { let mut is_room = true; let mut is_group = false; let members: Vec = self.room.members.values().cloned().collect(); - let power = *self.room.power_levels.get(&self.uid.clone()?).unwrap_or(&0); + let power = *self.room.admins.get(&self.uid.clone()?).unwrap_or(&0); let edit = power >= 50 && !self.room.direct; @@ -630,8 +630,7 @@ impl RoomSettings { ) .as_str(), ); - let list = - widgets::MembersList::new(members.clone(), self.room.power_levels.clone(), entry); + let list = widgets::MembersList::new(members.clone(), self.room.admins.clone(), entry); let w = list.create()?; b.add(&w); self.members_list = Some(list); diff --git a/fractal-matrix-api/src/model/room.rs b/fractal-matrix-api/src/model/room.rs index 8405a187..1104e03b 100644 --- a/fractal-matrix-api/src/model/room.rs +++ b/fractal-matrix-api/src/model/room.rs @@ -97,7 +97,7 @@ pub struct Room { /// Hashmap with the room users power levels /// the key will be the userid and the value will be the level - pub power_levels: HashMap, + pub admins: HashMap, } impl Room { @@ -141,7 +141,7 @@ impl Room { highlight: room.unread_notifications.highlight_count, prev_batch: timeline.prev_batch.clone(), messages: Message::from_json_events_iter(&k, timeline.events.iter()), - power_levels: get_admins(stevents), + admins: get_admins(stevents), members: stevents .iter() .filter(|x| x["type"] == "m.room.member")