fix: profile loading
This commit is contained in:
parent
948276eb65
commit
5bed3fa86f
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
/ndb
|
/.data
|
||||||
/.idea
|
/.idea
|
||||||
/cache
|
|
||||||
/ffmpeg-kit
|
/ffmpeg-kit
|
24
src/app.rs
24
src/app.rs
@ -2,14 +2,12 @@ use crate::route::Router;
|
|||||||
use eframe::{App, CreationContext, Frame};
|
use eframe::{App, CreationContext, Frame};
|
||||||
use egui::{Color32, Context};
|
use egui::{Color32, Context};
|
||||||
use nostr_sdk::database::MemoryDatabase;
|
use nostr_sdk::database::MemoryDatabase;
|
||||||
use nostr_sdk::{Client, RelayPoolNotification};
|
use nostr_sdk::Client;
|
||||||
use nostrdb::{Config, Ndb};
|
use nostrdb::{Config, Ndb};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tokio::sync::broadcast;
|
|
||||||
|
|
||||||
pub struct ZapStreamApp {
|
pub struct ZapStreamApp {
|
||||||
client: Client,
|
client: Client,
|
||||||
notifications: broadcast::Receiver<RelayPoolNotification>,
|
|
||||||
router: Router,
|
router: Router,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,31 +16,35 @@ impl ZapStreamApp {
|
|||||||
let client = Client::builder()
|
let client = Client::builder()
|
||||||
.database(MemoryDatabase::with_opts(Default::default()))
|
.database(MemoryDatabase::with_opts(Default::default()))
|
||||||
.build();
|
.build();
|
||||||
let notifications = client.notifications();
|
|
||||||
|
|
||||||
let ctx_clone = cc.egui_ctx.clone();
|
|
||||||
let client_clone = client.clone();
|
let client_clone = client.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
client_clone
|
client_clone
|
||||||
.add_relay("wss://nos.lol")
|
.add_relay("wss://nos.lol")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to add relay");
|
.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;
|
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);
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||||
|
|
||||||
let ndb_path = data_path.join("ndb");
|
let ndb_path = data_path.join("ndb");
|
||||||
std::fs::create_dir_all(&ndb_path).expect("Failed to create ndb directory");
|
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 {
|
Self {
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
notifications,
|
|
||||||
router: Router::new(data_path, cc.egui_ctx.clone(), client.clone(), ndb.clone()),
|
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.renderer = Renderer::Glow;
|
||||||
options.viewport = options.viewport.with_inner_size(Vec2::new(360., 720.));
|
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(
|
let _res = eframe::run_native(
|
||||||
"zap.stream",
|
"zap.stream",
|
||||||
options,
|
options,
|
||||||
|
@ -25,7 +25,7 @@ pub async fn android_main(app: AndroidApp) {
|
|||||||
|
|
||||||
let mut options = eframe::NativeOptions::default();
|
let mut options = eframe::NativeOptions::default();
|
||||||
options.renderer = Renderer::Glow;
|
options.renderer = Renderer::Glow;
|
||||||
options.viewport = options.viewport.with_inner_size(Vec2::new(360., 720.));
|
|
||||||
let app_clone_for_event_loop = app.clone();
|
let app_clone_for_event_loop = app.clone();
|
||||||
options.event_loop_builder = Some(Box::new(move |builder| {
|
options.event_loop_builder = Some(Box::new(move |builder| {
|
||||||
builder.with_android_app(app_clone_for_event_loop);
|
builder.with_android_app(app_clone_for_event_loop);
|
||||||
|
@ -45,7 +45,7 @@ impl ImageCache {
|
|||||||
{
|
{
|
||||||
let u = url.into();
|
let u = url.into();
|
||||||
let path = self.find(&u);
|
let path = self.find(&u);
|
||||||
if !path.exists() {
|
if !path.exists() && u.len() > 0 {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
let fl = self.fetch_lock.clone();
|
let fl = self.fetch_lock.clone();
|
||||||
let ctx = self.ctx.clone();
|
let ctx = self.ctx.clone();
|
||||||
|
@ -79,7 +79,7 @@ impl Query {
|
|||||||
// remove filters already sent
|
// remove filters already sent
|
||||||
next = next
|
next = next
|
||||||
.into_iter()
|
.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();
|
.collect();
|
||||||
|
|
||||||
if next.len() == 0 {
|
if next.len() == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user