mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-18 03:03:45 +00:00
relays: Add more default relays; added ability to add your own; status bar
This commit is contained in:
parent
8d4d944f4a
commit
997e6474df
@ -109,6 +109,7 @@ fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
|
||||
apply_sql!(db, version, 4, "schema4.sql");
|
||||
apply_sql!(db, version, 5, "schema5.sql");
|
||||
apply_sql!(db, version, 6, "schema6.sql");
|
||||
apply_sql!(db, version, 7, "schema7.sql");
|
||||
info!("Database is at version {}", version);
|
||||
Ok(())
|
||||
}
|
||||
|
7
src/db/schema7.sql
Normal file
7
src/db/schema7.sql
Normal file
@ -0,0 +1,7 @@
|
||||
INSERT OR IGNORE INTO relay (url) values
|
||||
('wss://nostr.fmt.wiz.biz'),
|
||||
('wss://nostr.v0l.io'),
|
||||
('wss://nostr.zebedee.cloud'),
|
||||
('wss://nostr-2.zebedee.cloud'),
|
||||
('wss://nostr.orangepill.dev'),
|
||||
('wss://relay.nostr.bg');
|
@ -514,6 +514,12 @@ impl Overlord {
|
||||
}
|
||||
});
|
||||
}
|
||||
"add_relay" => {
|
||||
let relay_str: String = serde_json::from_str(&bus_message.json_payload)?;
|
||||
if let Ok(dbrelay) = DbRelay::new(relay_str) {
|
||||
DbRelay::insert(dbrelay).await?;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
|
@ -69,6 +69,7 @@ enum Page {
|
||||
struct GossipUi {
|
||||
next_frame: Instant,
|
||||
page: Page,
|
||||
status: String,
|
||||
about: About,
|
||||
icon: TextureHandle,
|
||||
placeholder_avatar: TextureHandle,
|
||||
@ -88,6 +89,7 @@ struct GossipUi {
|
||||
person_view_name: Option<String>,
|
||||
avatars: HashMap<PublicKeyHex, TextureHandle>,
|
||||
failed_avatars: HashSet<PublicKeyHex>,
|
||||
new_relay_url: String,
|
||||
}
|
||||
|
||||
impl Drop for GossipUi {
|
||||
@ -141,6 +143,9 @@ impl GossipUi {
|
||||
GossipUi {
|
||||
next_frame: Instant::now(),
|
||||
page: Page::Feed,
|
||||
status:
|
||||
"Welcome to Gossip. Status messages will appear here, clobbering previous ones."
|
||||
.to_owned(),
|
||||
about: crate::about::about(),
|
||||
icon: icon_texture_handle,
|
||||
placeholder_avatar: placeholder_avatar_texture_handle,
|
||||
@ -160,6 +165,7 @@ impl GossipUi {
|
||||
person_view_name: None,
|
||||
avatars: HashMap::new(),
|
||||
failed_avatars: HashSet::new(),
|
||||
new_relay_url: "".to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -215,6 +221,12 @@ impl eframe::App for GossipUi {
|
||||
Page::HelpHelp => help::update(self, ctx, frame, ui),
|
||||
Page::HelpAbout => help::update(self, ctx, frame, ui),
|
||||
});
|
||||
|
||||
egui::TopBottomPanel::bottom("status").show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(&self.status);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,21 +3,48 @@ use crate::comms::BusMessage;
|
||||
use crate::db::DbRelay;
|
||||
use crate::globals::GLOBALS;
|
||||
use eframe::egui;
|
||||
use egui::{Align, Context, Layout, RichText, ScrollArea, TextStyle, Ui};
|
||||
use egui::{Align, Context, Layout, RichText, ScrollArea, TextEdit, TextStyle, Ui};
|
||||
use nostr_types::Url;
|
||||
|
||||
pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
ui.add_space(8.0);
|
||||
ui.heading("Relays known");
|
||||
ui.heading("Relays");
|
||||
ui.add_space(18.0);
|
||||
|
||||
ui.label(
|
||||
RichText::new(
|
||||
"Relays on this list have been automatically discovered in various kinds of events.",
|
||||
"Relays on this list were selected by the developer, but more relays will show up as they are automatically discovered in various kinds of events.",
|
||||
)
|
||||
.text_style(TextStyle::Body),
|
||||
);
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Enter a new relay URL:");
|
||||
ui.add(TextEdit::singleline(&mut app.new_relay_url));
|
||||
if ui.button("Add").clicked() {
|
||||
let test_url = Url::new(&app.new_relay_url);
|
||||
if test_url.is_valid_relay_url() {
|
||||
let tx = GLOBALS.to_overlord.clone();
|
||||
let _ = tx.send(BusMessage {
|
||||
target: "overlord".to_string(),
|
||||
kind: "add_relay".to_string(),
|
||||
json_payload: serde_json::to_string(&app.new_relay_url).unwrap(),
|
||||
});
|
||||
app.new_relay_url = "".to_owned();
|
||||
app.status = format!(
|
||||
"I asked the overlord to add relay {}. Check for it below.",
|
||||
&app.new_relay_url
|
||||
);
|
||||
} else {
|
||||
app.status = "That's not a valid relay URL.".to_owned();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ui.add_space(10.0);
|
||||
ui.separator();
|
||||
ui.add_space(10.0);
|
||||
|
||||
// TBD time how long this takes. We don't want expensive code in the UI
|
||||
let mut relays = GLOBALS.relays.blocking_read().clone();
|
||||
let mut relays: Vec<DbRelay> = relays.drain().map(|(_, relay)| relay).collect();
|
||||
|
Loading…
Reference in New Issue
Block a user