[fractal] fractal-gtk: Rename power_levels to admins
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-gtk: Rename power_levels to admins
- Date: Fri, 23 Aug 2019 18:46:11 +0000 (UTC)
commit 45939221bc7a80c7135885693c2887b04e44bcf9
Author: Alistair Francis <alistair alistair23 me>
Date: Sun Jul 7 22:02:56 2019 -0700
fractal-gtk: Rename power_levels to admins
The current power_levels variable really only describes the admins
(hence the call to get_admins()) so let's rename it to be more accurate.
Signed-off-by: Alistair Francis <alistair alistair23 me>
fractal-gtk/src/appop/member.rs | 2 +-
fractal-gtk/src/appop/message.rs | 4 ++--
fractal-gtk/src/widgets/members_list.rs | 14 +++++++-------
fractal-gtk/src/widgets/room_settings.rs | 5 ++---
fractal-matrix-api/src/model/room.rs | 4 ++--
5 files changed, 14 insertions(+), 15 deletions(-)
---
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<Member>,
- power_levels: HashMap<String, i32>,
+ admins: HashMap<String, i32>,
}
impl MembersList {
pub fn new(
m: Vec<Member>,
- power_levels: HashMap<String, i32>,
+ admins: HashMap<String, i32>,
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<i32>) -> gtk::Box {
fn add_rows(
container: gtk::ListBox,
members: Vec<Member>,
- power_levels: HashMap<String, i32>,
+ admins: HashMap<String, i32>,
) -> Option<usize> {
/* 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<Member> = 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<String, i32>,
+ pub admins: HashMap<String, i32>,
}
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")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]