Basic people page - cannot follow or unfollow yet [plus cleanup]

This commit is contained in:
Mike Dilger 2022-12-23 20:36:17 +13:00
parent a6feac8d4f
commit 4008bea2bf
4 changed files with 58 additions and 18 deletions

View File

@ -294,7 +294,7 @@ impl Overlord {
// FIXME: Handle EventKind::ContactList
}
}
"minion_is_ready" => {},
"minion_is_ready" => {}
"save_settings" => {
let settings: Settings = serde_json::from_str(&bus_message.json_payload)?;
@ -305,7 +305,7 @@ impl Overlord {
*GLOBALS.settings.lock().await = settings;
debug!("Settings saved.");
},
}
_ => {}
},
_ => {}

View File

@ -111,7 +111,7 @@ impl GossipUi {
icon: icon_texture_handle,
placeholder_avatar: placeholder_avatar_texture_handle,
draft: "".to_owned(),
settings: settings,
settings,
}
}
}

View File

@ -1,7 +1,35 @@
use super::GossipUi;
use crate::globals::GLOBALS;
use eframe::egui;
use egui::{Context, Ui};
use egui::{Context, RichText, ScrollArea, TextStyle, Ui};
pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Frame, ui: &mut Ui) {
ui.label("PEOPLE PAGE - Coming Soon".to_string());
ui.add_space(8.0);
ui.heading("People Followed");
ui.add_space(18.0);
let people = GLOBALS.people.blocking_lock().clone();
ScrollArea::vertical().show(ui, |ui| {
for (_, person) in people.iter() {
if person.followed != 1 {
continue;
}
ui.label(&person.pubkey.0);
ui.label(
RichText::new(person.name.as_deref().unwrap_or(""))
.text_style(TextStyle::Name("Bold".into())),
);
ui.label(person.about.as_deref().unwrap_or(""));
ui.label(person.dns_id.as_deref().unwrap_or(""));
ui.add_space(12.0);
ui.separator();
}
});
}

View File

@ -1,9 +1,9 @@
use crate::GLOBALS;
use crate::comms::BusMessage;
use super::GossipUi;
use crate::comms::BusMessage;
use crate::GLOBALS;
use eframe::egui;
use egui::{Align, Context, Layout, Ui};
use egui::widgets::{Button, Slider};
use egui::{Align, Context, Layout, Ui};
pub(super) fn update(
app: &mut GossipUi,
@ -40,8 +40,13 @@ pub(super) fn update(
ui.add_space(24.0);
ui.heading("What Posts to Include");
ui.checkbox(&mut app.settings.view_posts_referred_to, "View posts referred to by people you follow (not yet implemented)")
.on_hover_text("Recommended, otherwise it's hard to understand what the person is talking about.");
ui.checkbox(
&mut app.settings.view_posts_referred_to,
"View posts referred to by people you follow (not yet implemented)",
)
.on_hover_text(
"Recommended, otherwise it's hard to understand what the person is talking about.",
);
ui.checkbox(&mut app.settings.view_posts_referring_to, "View posts referring to posts by people you follow (not yet implemented)")
.on_hover_text("Not recommended, as anyone can reply to them and you'll certainly encounter spam this way.");
@ -49,7 +54,10 @@ pub(super) fn update(
ui.add_space(24.0);
ui.heading("Miscellaneous");
ui.checkbox(&mut app.settings.autofollow, "Autofollow everybody (not yet implemented)")
ui.checkbox(
&mut app.settings.autofollow,
"Autofollow everybody (not yet implemented)",
)
.on_hover_text("Definately not recommended. In fact we may remove this soon.");
ui.add_space(24.0);
@ -85,15 +93,13 @@ pub(super) fn update(
let _ = tx.send(BusMessage {
target: "overlord".to_string(),
kind: "save_settings".to_string(),
json_payload: serde_json::to_string(&app.settings).unwrap()
json_payload: serde_json::to_string(&app.settings).unwrap(),
});
}
});
}
fn secs_to_string(secs: u64) -> String {
let days = secs / 86400;
let remainder = secs % 86400;
let hours = remainder / 3600;
@ -101,9 +107,15 @@ fn secs_to_string(secs: u64) -> String {
let minutes = remainder / 60;
let seconds = remainder % 60;
let mut output: String = String::new();
if days>0 { output.push_str(&format!(" {} days", days)); }
if hours>0 { output.push_str(&format!(" {} hours", hours)); }
if minutes>0 { output.push_str(&format!(" {} minutes", minutes)); }
if days > 0 {
output.push_str(&format!(" {} days", days));
}
if hours > 0 {
output.push_str(&format!(" {} hours", hours));
}
if minutes > 0 {
output.push_str(&format!(" {} minutes", minutes));
}
output.push_str(&format!(" {} seconds", seconds));
output
}