Skip to content

Commit

Permalink
Fix all warnings
Browse files Browse the repository at this point in the history
Signed-off-by: William Casarin <jb55@jb55.com>
  • Loading branch information
jb55 committed Apr 1, 2024
1 parent 4bd0168 commit 6222a7d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 47 deletions.
7 changes: 1 addition & 6 deletions enostr/src/relay/message.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
43 changes: 15 additions & 28 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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(),
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")]
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/colors.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
Expand Down
13 changes: 5 additions & 8 deletions src/imgcache.rs
Original file line number Diff line number Diff line change
@@ -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>;
Expand All @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests_ui/account_login_view_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/note/contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6222a7d

Please sign in to comment.