More person list pages work

This commit is contained in:
Mike Dilger 2023-11-29 12:06:47 +13:00
parent 358a04c612
commit df7af04299
2 changed files with 35 additions and 33 deletions

View File

@ -12,12 +12,14 @@ pub(super) fn update(
ui: &mut Ui, ui: &mut Ui,
list: PersonList, list: PersonList,
) { ) {
let people = {
let members = GLOBALS let members = GLOBALS
.storage .storage
.get_people_in_list(list) .get_people_in_list(list)
.unwrap_or_default(); .unwrap_or_default();
let mut people: Vec<(Person, bool)> = Vec::new(); let mut people: Vec<(Person, bool)> = Vec::new();
for (pk, public) in &members { for (pk, public) in &members {
if let Ok(Some(person)) = GLOBALS.storage.read_person(pk) { if let Ok(Some(person)) = GLOBALS.storage.read_person(pk) {
people.push((person, *public)); people.push((person, *public));
@ -28,6 +30,8 @@ pub(super) fn update(
} }
} }
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); ui.add_space(12.0);
@ -193,10 +197,19 @@ pub(super) fn update(
.color(app.theme.warning_marker_text_color()), .color(app.theme.warning_marker_text_color()),
); );
} }
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" });
});
});
}); });
// FIXME indicate if public or not if ui.button("Remove").clicked() {
}); let _ = GLOBALS.storage.remove_person_from_list(&person.pubkey, list, None);
}
ui.add_space(4.0); ui.add_space(4.0);
ui.separator(); ui.separator();

View File

@ -27,17 +27,17 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
}; };
if matches!(list, PersonList::Custom(_)) { if matches!(list, PersonList::Custom(_)) {
if ui.button("DELETE").clicked() { if ui.button("DELETE").clicked() {
// FIXME -- confirm with a popup, then call the delete() function (see below) // FIXME -- confirm with a popup first!
GLOBALS let _ = GLOBALS
.status_queue .to_overlord
.write() .send(ToOverlordMessage::DeletePersonList(list));
.write("Person List Delete is NOT YET IMPLEMENTED".to_string());
} }
} }
}); });
} }
if ui.button("Create a new list").clicked() { 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 GLOBALS
.status_queue .status_queue
.write() .write()
@ -48,14 +48,3 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
ui.separator(); ui.separator();
ui.add_space(10.0); 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);
}