mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
More person list pages work
This commit is contained in:
parent
358a04c612
commit
df7af04299
@ -12,22 +12,26 @@ pub(super) fn update(
|
||||
ui: &mut Ui,
|
||||
list: PersonList,
|
||||
) {
|
||||
let members = GLOBALS
|
||||
.storage
|
||||
.get_people_in_list(list)
|
||||
.unwrap_or_default();
|
||||
let people = {
|
||||
let members = GLOBALS
|
||||
.storage
|
||||
.get_people_in_list(list)
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut people: Vec<(Person, bool)> = Vec::new();
|
||||
for (pk, public) in &members {
|
||||
if let Ok(Some(person)) = GLOBALS.storage.read_person(pk) {
|
||||
people.push((person, *public));
|
||||
} else {
|
||||
let person = Person::new(pk.to_owned());
|
||||
let _ = GLOBALS.storage.write_person(&person, None);
|
||||
people.push((person, *public));
|
||||
let mut people: Vec<(Person, bool)> = Vec::new();
|
||||
|
||||
for (pk, public) in &members {
|
||||
if let Ok(Some(person)) = GLOBALS.storage.read_person(pk) {
|
||||
people.push((person, *public));
|
||||
} else {
|
||||
let person = Person::new(pk.to_owned());
|
||||
let _ = GLOBALS.storage.write_person(&person, None);
|
||||
people.push((person, *public));
|
||||
}
|
||||
}
|
||||
}
|
||||
people.sort_by(|a,b| a.0.cmp(&b.0));
|
||||
people.sort_by(|a,b| a.0.cmp(&b.0));
|
||||
people
|
||||
};
|
||||
|
||||
ui.add_space(12.0);
|
||||
|
||||
@ -193,11 +197,20 @@ pub(super) fn update(
|
||||
.color(app.theme.warning_marker_text_color()),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// FIXME indicate if public or not
|
||||
ui.horizontal(|ui| {
|
||||
if crate::ui::components::switch_simple(ui, *public).clicked() {
|
||||
let _ = GLOBALS.storage.add_person_to_list(&person.pubkey, list, !*public, None);
|
||||
}
|
||||
ui.label(if *public { "public" } else { "private" });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if ui.button("Remove").clicked() {
|
||||
let _ = GLOBALS.storage.remove_person_from_list(&person.pubkey, list, None);
|
||||
}
|
||||
|
||||
ui.add_space(4.0);
|
||||
ui.separator();
|
||||
}
|
||||
|
@ -27,17 +27,17 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
};
|
||||
if matches!(list, PersonList::Custom(_)) {
|
||||
if ui.button("DELETE").clicked() {
|
||||
// FIXME -- confirm with a popup, then call the delete() function (see below)
|
||||
GLOBALS
|
||||
.status_queue
|
||||
.write()
|
||||
.write("Person List Delete is NOT YET IMPLEMENTED".to_string());
|
||||
// FIXME -- confirm with a popup first!
|
||||
let _ = GLOBALS
|
||||
.to_overlord
|
||||
.send(ToOverlordMessage::DeletePersonList(list));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if ui.button("Create a new list").clicked() {
|
||||
// FIXME -- prompt for a name with a popup, then call the create() function (see below)
|
||||
// FIXME -- prompt for a name with a popup, then create with:
|
||||
// let _ = PersonList::allocate(name, None);
|
||||
GLOBALS
|
||||
.status_queue
|
||||
.write()
|
||||
@ -48,14 +48,3 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
ui.separator();
|
||||
ui.add_space(10.0);
|
||||
}
|
||||
|
||||
fn delete(list: PersonList) {
|
||||
let _ = GLOBALS
|
||||
.to_overlord
|
||||
.send(ToOverlordMessage::ClearPersonList(list));
|
||||
let _ = list.deallocate(None);
|
||||
}
|
||||
|
||||
fn create(name: &str) {
|
||||
let _ = PersonList::allocate(name, None);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user