mirror of
https://github.com/damus-io/notedeck.git
synced 2024-09-16 11:53:30 +00:00
wip fedimint recommendations
This commit is contained in:
parent
3221537c70
commit
6b647d216c
4
.cargo/config.toml
Normal file
4
.cargo/config.toml
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
[build]
|
||||
rustflags = ["--cfg", "tokio_unstable"]
|
||||
rustdocflags = ["--cfg", "tokio_unstable"]
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ src/camera.rs
|
||||
*.txt
|
||||
/tags
|
||||
*.mdb
|
||||
multimint
|
||||
|
@ -14,8 +14,8 @@ crate-type = ["lib", "cdylib"]
|
||||
[dependencies]
|
||||
#egui-android = { git = "https://github.com/jb55/egui-android.git" }
|
||||
egui = "0.27.2"
|
||||
eframe = { version = "0.27.2", default-features = false, features = [ "glow", "wgpu", "android-native-activity" ] }
|
||||
#eframe = { version = "0.26.0", default-features = false, features = [ "glow", "android-native-activity" ] }
|
||||
#eframe = { version = "0.27.2", default-features = false, features = [ "glow", "wgpu", "android-native-activity" ] }
|
||||
eframe = { version = "0.27.2", default-features = false, features = [ "glow", "android-native-activity" ] }
|
||||
#eframe = "0.22.0"
|
||||
egui_extras = { version = "0.27.2", features = ["all_loaders"] }
|
||||
ehttp = "0.2.0"
|
||||
@ -41,6 +41,8 @@ strum = "0.26"
|
||||
strum_macros = "0.26"
|
||||
bitflags = "2.5.0"
|
||||
egui_virtual_list = "0.3.0"
|
||||
multimint = "0.3.4"
|
||||
anyhow = "1.0.82"
|
||||
|
||||
|
||||
[features]
|
||||
|
@ -22,7 +22,8 @@ let
|
||||
|
||||
in
|
||||
mkShell ({
|
||||
buildInputs = [] ++ pkgs.lib.optional use_android [
|
||||
buildInputs = [rustPlatform.bindgenHook rocksdb] ++ pkgs.lib.optional use_android [
|
||||
|
||||
android-sdk
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
@ -33,6 +34,7 @@ mkShell ({
|
||||
rustfmt
|
||||
libiconv
|
||||
pkg-config
|
||||
gdb
|
||||
#cmake
|
||||
fontconfig
|
||||
openssl
|
||||
@ -52,6 +54,7 @@ mkShell ({
|
||||
darwin.apple_sdk.frameworks.AppKit
|
||||
];
|
||||
|
||||
LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
ANDROID_NDK_ROOT = android-ndk-path;
|
||||
} // (if !stdenv.isDarwin then {
|
||||
LD_LIBRARY_PATH="${x11libs}";
|
||||
|
46
src/app.rs
46
src/app.rs
@ -8,12 +8,19 @@ use crate::timeline;
|
||||
use crate::timeline::{NoteRef, Timeline};
|
||||
use crate::ui::is_mobile;
|
||||
use crate::Result;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use multimint::fedimint_core::api::InviteCode;
|
||||
use multimint::fedimint_core::config::FederationId;
|
||||
use multimint::MultiMint;
|
||||
|
||||
use egui::{Context, Frame, Margin, Style};
|
||||
use egui_extras::{Size, StripBuilder};
|
||||
|
||||
use enostr::{ClientMessage, Filter, Pubkey, RelayEvent, RelayMessage};
|
||||
use nostrdb::{BlockType, Config, Mention, Ndb, Note, NoteKey, Transaction};
|
||||
use nostrdb::{BlockType, Config, Mention, Ndb, Note, NoteKey, ProfileKey, Transaction};
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::hash::Hash;
|
||||
@ -42,6 +49,9 @@ pub struct Damus {
|
||||
pub img_cache: ImageCache,
|
||||
pub ndb: Ndb,
|
||||
|
||||
mint: MultiMint,
|
||||
mint_recs: HashMap<FederationId, HashSet<[u8; 32]>>,
|
||||
|
||||
frame_history: crate::frame_history::FrameHistory,
|
||||
}
|
||||
|
||||
@ -298,6 +308,35 @@ fn setup_initial_nostrdb_subs(damus: &mut Damus) -> Result<()> {
|
||||
filters,
|
||||
timeline.filter[0].limit.unwrap_or(200) as i32,
|
||||
)?;
|
||||
|
||||
for result in &res {
|
||||
if result.note.kind() == 38000 {
|
||||
for tag in result.note.tags() {
|
||||
if tag.count() < 2 {
|
||||
continue;
|
||||
}
|
||||
if tag.get_unchecked(0).variant().str() == Some("u") {
|
||||
let inv_str = if let Some(s) = tag.get_unchecked(1).variant().str() {
|
||||
s
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if let Ok(code) = InviteCode::from_str(inv_str) {
|
||||
let fed_id = code.federation_id();
|
||||
damus
|
||||
.mint_recs
|
||||
.entry(fed_id)
|
||||
.or_insert_with(|| HashSet::new())
|
||||
.insert(result.note.pubkey().to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("{:?}", damus.mint_recs);
|
||||
|
||||
timeline.notes = res
|
||||
.iter()
|
||||
.map(|qr| NoteRef {
|
||||
@ -430,6 +469,7 @@ impl Damus {
|
||||
pub fn new<P: AsRef<Path>>(
|
||||
cc: &eframe::CreationContext<'_>,
|
||||
data_path: P,
|
||||
mint: MultiMint,
|
||||
args: Vec<String>,
|
||||
) -> Self {
|
||||
// This is also where you can customized the look at feel of egui using
|
||||
@ -461,6 +501,8 @@ impl Damus {
|
||||
|
||||
let mut config = Config::new();
|
||||
config.set_ingester_threads(2);
|
||||
let mint_recs = HashMap::new();
|
||||
|
||||
Self {
|
||||
state: DamusState::Initializing,
|
||||
pool: RelayPool::new(),
|
||||
@ -468,6 +510,8 @@ impl Damus {
|
||||
note_cache: HashMap::new(),
|
||||
timelines,
|
||||
textmode: false,
|
||||
mint,
|
||||
mint_recs,
|
||||
ndb: Ndb::new(data_path.as_ref().to_str().expect("db path ok"), &config).expect("ndb"),
|
||||
//compose: "".to_string(),
|
||||
frame_history: FrameHistory::default(),
|
||||
|
@ -184,7 +184,7 @@ pub fn create_themed_visuals(theme: ColorTheme, default: Visuals) -> Visuals {
|
||||
},
|
||||
extreme_bg_color: theme.extreme_bg_color,
|
||||
error_fg_color: theme.err_fg_color,
|
||||
window_rounding: Rounding::same(32.0),
|
||||
window_rounding: Rounding::same(8.0),
|
||||
window_fill: theme.window_fill,
|
||||
window_shadow: Shadow {
|
||||
offset: [0.0, 8.0].into(),
|
||||
|
@ -2,6 +2,10 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
use notedeck::app_creation::generate_native_options;
|
||||
use notedeck::Damus;
|
||||
use multimint::MultiMint;
|
||||
use notedeck::Error;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
// Entry point for wasm
|
||||
//#[cfg(target_arch = "wasm32")]
|
||||
@ -10,15 +14,16 @@ use notedeck::Damus;
|
||||
// Desktop
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
async fn main() -> Result<(), Error> {
|
||||
// Log to stdout (if you run with `RUST_LOG=debug`).
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let _res = eframe::run_native(
|
||||
let mint = MultiMint::new("multimint".into()).await?;
|
||||
eframe::run_native(
|
||||
"Damus NoteDeck",
|
||||
generate_native_options(),
|
||||
Box::new(|cc| Box::new(Damus::new(cc, ".", std::env::args().collect()))),
|
||||
);
|
||||
Box::new(|cc| Box::new(Damus::new(cc, ".", mint, std::env::args().collect()))),
|
||||
).map_err(|e| Error::Generic(format!("{:?}", e)))
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
17
src/error.rs
17
src/error.rs
@ -8,6 +8,8 @@ pub enum Error {
|
||||
Nostr(enostr::Error),
|
||||
Ndb(nostrdb::Error),
|
||||
Image(image::error::ImageError),
|
||||
Anyhow(anyhow::Error),
|
||||
//Eframe(eframe::Error),
|
||||
Generic(String),
|
||||
}
|
||||
|
||||
@ -25,6 +27,7 @@ impl fmt::Display for Error {
|
||||
Self::Image(e) => write!(f, "{e}"),
|
||||
Self::Generic(e) => write!(f, "{e}"),
|
||||
Self::Io(e) => write!(f, "{e}"),
|
||||
Self::Anyhow(e) => write!(f, "{e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,12 +50,26 @@ impl From<image::error::ImageError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<anyhow::Error> for Error {
|
||||
fn from(err: anyhow::Error) -> Self {
|
||||
Error::Anyhow(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<enostr::Error> for Error {
|
||||
fn from(err: enostr::Error) -> Self {
|
||||
Error::Nostr(err)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
impl From<eframe::Error> for Error {
|
||||
fn from(err: eframe::Error) -> Self {
|
||||
Error::Eframe(err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
impl From<io::Error> for Error {
|
||||
fn from(err: io::Error) -> Self {
|
||||
Error::Io(err)
|
||||
|
Loading…
Reference in New Issue
Block a user