fix: profile loading
This commit is contained in:
24
src/app.rs
24
src/app.rs
@ -2,14 +2,12 @@ use crate::route::Router;
|
||||
use eframe::{App, CreationContext, Frame};
|
||||
use egui::{Color32, Context};
|
||||
use nostr_sdk::database::MemoryDatabase;
|
||||
use nostr_sdk::{Client, RelayPoolNotification};
|
||||
use nostr_sdk::Client;
|
||||
use nostrdb::{Config, Ndb};
|
||||
use std::path::PathBuf;
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
pub struct ZapStreamApp {
|
||||
client: Client,
|
||||
notifications: broadcast::Receiver<RelayPoolNotification>,
|
||||
router: Router,
|
||||
}
|
||||
|
||||
@ -18,31 +16,35 @@ impl ZapStreamApp {
|
||||
let client = Client::builder()
|
||||
.database(MemoryDatabase::with_opts(Default::default()))
|
||||
.build();
|
||||
let notifications = client.notifications();
|
||||
|
||||
let ctx_clone = cc.egui_ctx.clone();
|
||||
let client_clone = client.clone();
|
||||
tokio::spawn(async move {
|
||||
client_clone
|
||||
.add_relay("wss://nos.lol")
|
||||
.await
|
||||
.expect("Failed to add relay");
|
||||
client_clone
|
||||
.add_relay("wss://relay.damus.io")
|
||||
.await
|
||||
.expect("Failed to add relay");
|
||||
client_clone
|
||||
.add_relay("wss://relay.snort.social")
|
||||
.await
|
||||
.expect("Failed to add relay");
|
||||
client_clone.connect().await;
|
||||
let mut notifications = client_clone.notifications();
|
||||
while let Ok(_) = notifications.recv().await {
|
||||
ctx_clone.request_repaint();
|
||||
}
|
||||
});
|
||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||
|
||||
let ndb_path = data_path.join("ndb");
|
||||
std::fs::create_dir_all(&ndb_path).expect("Failed to create ndb directory");
|
||||
|
||||
let ndb = Ndb::new(ndb_path.to_str().unwrap(), &Config::default()).unwrap();
|
||||
let mut ndb_config = Config::default();
|
||||
ndb_config.set_ingester_threads(4);
|
||||
|
||||
let ndb = Ndb::new(ndb_path.to_str().unwrap(), &ndb_config).unwrap();
|
||||
|
||||
Self {
|
||||
client: client.clone(),
|
||||
notifications,
|
||||
router: Router::new(data_path, cc.egui_ctx.clone(), client.clone(), ndb.clone()),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user