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>
This commit is contained in:
parent
aea9d5be85
commit
45939221bc
5 changed files with 14 additions and 15 deletions
|
@ -26,7 +26,7 @@ impl AppOp {
|
||||||
.rooms
|
.rooms
|
||||||
.get(&self.active_room.clone().unwrap_or_default())
|
.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;
|
return *level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,11 +441,11 @@ impl AppOp {
|
||||||
};
|
};
|
||||||
|
|
||||||
let uid = self.uid.clone().unwrap_or_default();
|
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,
|
Some(&pl) => pl,
|
||||||
None => 0,
|
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);
|
let is_last_viewed = msg.receipt.contains_key(&uid);
|
||||||
Some(create_ui_message(
|
Some(create_ui_message(
|
||||||
|
|
|
@ -18,13 +18,13 @@ pub struct MembersList {
|
||||||
search_entry: gtk::SearchEntry,
|
search_entry: gtk::SearchEntry,
|
||||||
error: gtk::Label,
|
error: gtk::Label,
|
||||||
members: Vec<Member>,
|
members: Vec<Member>,
|
||||||
power_levels: HashMap<String, i32>,
|
admins: HashMap<String, i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MembersList {
|
impl MembersList {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
m: Vec<Member>,
|
m: Vec<Member>,
|
||||||
power_levels: HashMap<String, i32>,
|
admins: HashMap<String, i32>,
|
||||||
entry: gtk::SearchEntry,
|
entry: gtk::SearchEntry,
|
||||||
) -> MembersList {
|
) -> MembersList {
|
||||||
MembersList {
|
MembersList {
|
||||||
|
@ -32,7 +32,7 @@ impl MembersList {
|
||||||
error: gtk::Label::new(None),
|
error: gtk::Label::new(None),
|
||||||
members: m,
|
members: m,
|
||||||
search_entry: entry,
|
search_entry: entry,
|
||||||
power_levels: power_levels,
|
admins: admins,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ impl MembersList {
|
||||||
add_rows(
|
add_rows(
|
||||||
self.container.clone(),
|
self.container.clone(),
|
||||||
self.members.clone(),
|
self.members.clone(),
|
||||||
self.power_levels.clone(),
|
self.admins.clone(),
|
||||||
);
|
);
|
||||||
self.error.get_style_context().add_class("no_member_search");
|
self.error.get_style_context().add_class("no_member_search");
|
||||||
self.error.set_text(&i18n("No matching members found"));
|
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(
|
fn add_rows(
|
||||||
container: gtk::ListBox,
|
container: gtk::ListBox,
|
||||||
members: Vec<Member>,
|
members: Vec<Member>,
|
||||||
power_levels: HashMap<String, i32>,
|
admins: HashMap<String, i32>,
|
||||||
) -> Option<usize> {
|
) -> Option<usize> {
|
||||||
/* Load just enough members to fill atleast the visible list */
|
/* Load just enough members to fill atleast the visible list */
|
||||||
for member in members.iter() {
|
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),
|
Some(pl) => Some(*pl),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
container.insert(&create_row(member.clone(), power_level)?, -1);
|
container.insert(&create_row(member.clone(), admin)?, -1);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ impl RoomSettings {
|
||||||
let mut is_room = true;
|
let mut is_room = true;
|
||||||
let mut is_group = false;
|
let mut is_group = false;
|
||||||
let members: Vec<Member> = self.room.members.values().cloned().collect();
|
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;
|
let edit = power >= 50 && !self.room.direct;
|
||||||
|
|
||||||
|
@ -630,8 +630,7 @@ impl RoomSettings {
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
let list =
|
let list = widgets::MembersList::new(members.clone(), self.room.admins.clone(), entry);
|
||||||
widgets::MembersList::new(members.clone(), self.room.power_levels.clone(), entry);
|
|
||||||
let w = list.create()?;
|
let w = list.create()?;
|
||||||
b.add(&w);
|
b.add(&w);
|
||||||
self.members_list = Some(list);
|
self.members_list = Some(list);
|
||||||
|
|
|
@ -97,7 +97,7 @@ pub struct Room {
|
||||||
|
|
||||||
/// Hashmap with the room users power levels
|
/// Hashmap with the room users power levels
|
||||||
/// the key will be the userid and the value will be the level
|
/// 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 {
|
impl Room {
|
||||||
|
@ -141,7 +141,7 @@ impl Room {
|
||||||
highlight: room.unread_notifications.highlight_count,
|
highlight: room.unread_notifications.highlight_count,
|
||||||
prev_batch: timeline.prev_batch.clone(),
|
prev_batch: timeline.prev_batch.clone(),
|
||||||
messages: Message::from_json_events_iter(&k, timeline.events.iter()),
|
messages: Message::from_json_events_iter(&k, timeline.events.iter()),
|
||||||
power_levels: get_admins(stevents),
|
admins: get_admins(stevents),
|
||||||
members: stevents
|
members: stevents
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| x["type"] == "m.room.member")
|
.filter(|x| x["type"] == "m.room.member")
|
||||||
|
|
Loading…
Reference in a new issue