fix: profile loading
This commit is contained in:
parent
948276eb65
commit
5bed3fa86f
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
/target
|
||||
/ndb
|
||||
/.data
|
||||
/.idea
|
||||
/cache
|
||||
/ffmpeg-kit
|
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()),
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ async fn main() {
|
||||
options.renderer = Renderer::Glow;
|
||||
options.viewport = options.viewport.with_inner_size(Vec2::new(360., 720.));
|
||||
|
||||
let data_path = PathBuf::from(".");
|
||||
let data_path = PathBuf::from("./.data");
|
||||
let _res = eframe::run_native(
|
||||
"zap.stream",
|
||||
options,
|
||||
|
@ -25,7 +25,7 @@ pub async fn android_main(app: AndroidApp) {
|
||||
|
||||
let mut options = eframe::NativeOptions::default();
|
||||
options.renderer = Renderer::Glow;
|
||||
options.viewport = options.viewport.with_inner_size(Vec2::new(360., 720.));
|
||||
|
||||
let app_clone_for_event_loop = app.clone();
|
||||
options.event_loop_builder = Some(Box::new(move |builder| {
|
||||
builder.with_android_app(app_clone_for_event_loop);
|
||||
|
@ -45,7 +45,7 @@ impl ImageCache {
|
||||
{
|
||||
let u = url.into();
|
||||
let path = self.find(&u);
|
||||
if !path.exists() {
|
||||
if !path.exists() && u.len() > 0 {
|
||||
let path = path.clone();
|
||||
let fl = self.fetch_lock.clone();
|
||||
let ctx = self.ctx.clone();
|
||||
|
@ -79,7 +79,7 @@ impl Query {
|
||||
// remove filters already sent
|
||||
next = next
|
||||
.into_iter()
|
||||
.filter(|f| !self.traces.iter().all(|y| y.filters.iter().any(|z| z.eq(f))))
|
||||
.filter(|f| !self.traces.iter().any(|y| y.filters.iter().any(|z| z.eq(f))))
|
||||
.collect();
|
||||
|
||||
if next.len() == 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user