mirror of
https://github.com/damus-io/notedeck.git
synced 2024-09-18 21:03:31 +00:00
Fix all warnings
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
4bd01682da
commit
6222a7db63
@ -1,9 +1,4 @@
|
||||
use crate::Error;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
use tracing::error;
|
||||
|
||||
use crate::{Error, Result};
|
||||
use ewebsock::{WsEvent, WsMessage};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
|
43
src/app.rs
43
src/app.rs
@ -12,23 +12,18 @@ use crate::ui::padding;
|
||||
use crate::widgets::note::NoteContents;
|
||||
use crate::Result;
|
||||
use egui::containers::scroll_area::ScrollBarVisibility;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use egui::widgets::Spinner;
|
||||
use egui::{
|
||||
CollapsingHeader, Color32, Context, Frame, Hyperlink, Image, Label, Margin, RichText, Sense,
|
||||
Style, TextureHandle, Vec2, Visuals,
|
||||
};
|
||||
use egui::{Color32, Context, Frame, Label, Margin, RichText, Sense, Style, TextureHandle, Vec2};
|
||||
|
||||
use enostr::{ClientMessage, Filter, Pubkey, RelayEvent, RelayMessage};
|
||||
use nostrdb::{
|
||||
Block, BlockType, Blocks, Config, Mention, Ndb, Note, NoteKey, ProfileRecord, Subscription,
|
||||
Transaction,
|
||||
BlockType, Config, Mention, Ndb, Note, NoteKey, ProfileRecord, Subscription, Transaction,
|
||||
};
|
||||
use poll_promise::Promise;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::hash::Hash;
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
use tracing::{debug, error, info, warn};
|
||||
@ -86,8 +81,7 @@ impl Timeline {
|
||||
/// We derive Deserialize/Serialize so we can persist app state on shutdown.
|
||||
pub struct Damus {
|
||||
state: DamusState,
|
||||
compose: String,
|
||||
|
||||
//compose: String,
|
||||
note_cache: HashMap<NoteKey, NoteCache>,
|
||||
pool: RelayPool,
|
||||
|
||||
@ -127,16 +121,6 @@ fn relay_setup(pool: &mut RelayPool, ctx: &egui::Context) {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_home_filter(limit: u16) -> Filter {
|
||||
Filter::new().limit(limit).kinds(vec![1, 42]).pubkeys(
|
||||
[
|
||||
Pubkey::from_hex("32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245")
|
||||
.unwrap(),
|
||||
]
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
fn send_initial_filters(damus: &mut Damus, relay_url: &str) {
|
||||
info!("Sending initial filters to {}", relay_url);
|
||||
let mut c: u32 = 1;
|
||||
@ -226,7 +210,7 @@ fn get_unknown_note_pubkeys<'a>(
|
||||
|
||||
let blocks = ndb.get_blocks_by_key(txn, note_key)?;
|
||||
for block in blocks.iter(note) {
|
||||
let blocktype = block.blocktype();
|
||||
let _blocktype = block.blocktype();
|
||||
match block.blocktype() {
|
||||
BlockType::MentionBech32 => match block.as_mention().unwrap() {
|
||||
Mention::Pubkey(npub) => {
|
||||
@ -445,7 +429,7 @@ impl Damus {
|
||||
setup_cc(cc);
|
||||
|
||||
let mut timelines: Vec<Timeline> = vec![];
|
||||
let initial_limit = 100;
|
||||
let _initial_limit = 100;
|
||||
if args.len() > 1 {
|
||||
for arg in &args[1..] {
|
||||
let filter = serde_json::from_str(&arg).unwrap();
|
||||
@ -454,11 +438,10 @@ impl Damus {
|
||||
} else {
|
||||
let filter = serde_json::from_str(&include_str!("../queries/global.json")).unwrap();
|
||||
timelines.push(Timeline::new(filter));
|
||||
//vec![get_home_filter(initial_limit)]
|
||||
};
|
||||
|
||||
let imgcache_dir = data_path.as_ref().join("cache/img");
|
||||
std::fs::create_dir_all(imgcache_dir.clone());
|
||||
let _ = std::fs::create_dir_all(imgcache_dir.clone());
|
||||
|
||||
let mut config = Config::new();
|
||||
config.set_ingester_threads(2);
|
||||
@ -469,7 +452,7 @@ impl Damus {
|
||||
note_cache: HashMap::new(),
|
||||
timelines,
|
||||
ndb: Ndb::new(data_path.as_ref().to_str().expect("db path ok"), &config).expect("ndb"),
|
||||
compose: "".to_string(),
|
||||
//compose: "".to_string(),
|
||||
frame_history: FrameHistory::default(),
|
||||
}
|
||||
}
|
||||
@ -585,6 +568,7 @@ fn no_pfp_url() -> &'static str {
|
||||
"https://damus.io/img/no-profile.svg"
|
||||
}
|
||||
|
||||
/*
|
||||
fn render_notes_in_viewport(
|
||||
ui: &mut egui::Ui,
|
||||
_damus: &mut Damus,
|
||||
@ -624,6 +608,7 @@ fn render_notes_in_viewport(
|
||||
|
||||
ui.allocate_rect(used_rect, egui::Sense::hover()); // make sure it is visible!
|
||||
}
|
||||
*/
|
||||
|
||||
fn render_reltime(ui: &mut egui::Ui, note_cache: &mut NoteCache) {
|
||||
#[cfg(feature = "profiling")]
|
||||
@ -638,12 +623,14 @@ fn render_reltime(ui: &mut egui::Ui, note_cache: &mut NoteCache) {
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
fn circle_icon(ui: &mut egui::Ui, openness: f32, response: &egui::Response) {
|
||||
let stroke = ui.style().interact(&response).fg_stroke;
|
||||
let radius = egui::lerp(2.0..=3.0, openness);
|
||||
ui.painter()
|
||||
.circle_filled(response.rect.center(), radius, stroke.color);
|
||||
}
|
||||
*/
|
||||
|
||||
#[derive(Hash, Clone, Copy)]
|
||||
struct NoteTimelineKey {
|
||||
@ -924,12 +911,12 @@ fn render_damus_desktop(ctx: &egui::Context, app: &mut Damus) {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
fn postbox(ui: &mut egui::Ui, app: &mut Damus) {
|
||||
let _output = egui::TextEdit::multiline(&mut app.compose)
|
||||
.hint_text("Type something!")
|
||||
.show(ui);
|
||||
|
||||
/*
|
||||
let width = ui.available_width();
|
||||
let height = 100.0;
|
||||
let shapes = [Shape::Rect(RectShape {
|
||||
@ -940,8 +927,8 @@ fn postbox(ui: &mut egui::Ui, app: &mut Damus) {
|
||||
})];
|
||||
|
||||
ui.painter().extend(shapes);
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
fn timeline_panel<R>(
|
||||
ui: &mut egui::Ui,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use egui::Color32;
|
||||
|
||||
pub const PURPLE: Color32 = Color32::from_rgb(0xCC, 0x43, 0xC5);
|
||||
pub const DARK_BG: Color32 = egui::Color32::from_rgb(40, 44, 52);
|
||||
//pub const DARK_BG: Color32 = egui::Color32::from_rgb(40, 44, 52);
|
||||
pub const GRAY_SECONDARY: Color32 = Color32::from_rgb(0x8A, 0x8A, 0x8A);
|
||||
pub const WHITE: Color32 = Color32::from_rgb(0xFF, 0xFF, 0xFF);
|
||||
pub const ALMOST_WHITE: Color32 = Color32::from_rgb(0xFA, 0xFA, 0xFA);
|
||||
|
@ -100,7 +100,7 @@ pub fn setup_fonts(ctx: &egui::Context) {
|
||||
),
|
||||
);
|
||||
|
||||
let mut proportional = vec![
|
||||
let proportional = vec![
|
||||
"Onest".to_owned(),
|
||||
"DejaVuSans".to_owned(),
|
||||
"NotoEmoji".to_owned(),
|
||||
|
@ -6,7 +6,7 @@ use image::imageops::FilterType;
|
||||
use poll_promise::Promise;
|
||||
use tokio::fs;
|
||||
use std::path;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
||||
//pub type ImageCacheKey = String;
|
||||
//pub type ImageCacheValue = Promise<Result<TextureHandle>>;
|
||||
|
@ -1,17 +1,13 @@
|
||||
use crate::{Error, Result};
|
||||
use crate::Result;
|
||||
use egui::TextureHandle;
|
||||
use poll_promise::Promise;
|
||||
|
||||
use egui::ColorImage;
|
||||
use hex;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::io;
|
||||
|
||||
use std::path;
|
||||
use tokio::fs;
|
||||
|
||||
pub type ImageCacheValue = Promise<Result<TextureHandle>>;
|
||||
pub type ImageCacheMap = HashMap<String, ImageCacheValue>;
|
||||
@ -33,12 +29,13 @@ impl ImageCache {
|
||||
let file_path = cache_dir.join(&Self::key(url));
|
||||
let file = File::options().write(true).create(true).open(file_path)?;
|
||||
let encoder = image::codecs::webp::WebPEncoder::new_lossless(file);
|
||||
|
||||
encoder.encode(
|
||||
data.as_raw(),
|
||||
data.size[0] as u32,
|
||||
data.size[1] as u32,
|
||||
image::ColorType::Rgba8,
|
||||
);
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ pub struct AccountLoginTest {
|
||||
}
|
||||
|
||||
impl EguiTestCase for AccountLoginTest {
|
||||
fn new(supr: EguiTestSetup) -> Self {
|
||||
fn new(_supr: EguiTestSetup) -> Self {
|
||||
AccountLoginTest {
|
||||
manager: LoginManager::new(),
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ fn render_note_contents(
|
||||
#[cfg(feature = "profiling")]
|
||||
puffin::profile_function!();
|
||||
|
||||
let mut images: Vec<String> = vec![];
|
||||
let images: Vec<String> = vec![];
|
||||
|
||||
let resp = ui.horizontal_wrapped(|ui| {
|
||||
let blocks = if let Ok(blocks) = damus.ndb.get_blocks_by_key(txn, note_key) {
|
||||
|
Loading…
Reference in New Issue
Block a user