notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit c76f322a484730eb60617f3b2328457c516b6c3b
parent ff5e5ed74a8402a5da33c5a7c044146df0e76e3d
Author: kernelkind <kernelkind@gmail.com>
Date:   Wed, 17 Apr 2024 13:36:19 -0400

Apply cargo fmt

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/account_login_view.rs | 16+++++++++-------
Msrc/bin/notedeck.rs | 3+--
Msrc/images.rs | 24+++++++++++++++---------
Msrc/lib.rs | 26+++++++++++++-------------
Msrc/login_manager.rs | 4++--
Msrc/ui_preview/account_login_preview.rs | 3+--
Msrc/ui_preview/main.rs | 11++++++-----
7 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/src/account_login_view.rs b/src/account_login_view.rs @@ -2,8 +2,8 @@ use crate::app_style::NotedeckTextStyle; use crate::key_parsing::{perform_key_retrieval, LoginError}; use crate::login_manager::LoginManager; use egui::{ - Align, Align2, Button, Color32, Frame, Id, LayerId, Margin, Pos2, Rect, - RichText, Rounding, Ui, Vec2, Window, + Align, Align2, Button, Color32, Frame, Id, LayerId, Margin, Pos2, Rect, RichText, Rounding, Ui, + Vec2, Window, }; use egui::{Image, TextBuffer, TextEdit}; @@ -149,9 +149,7 @@ impl<'a> DesktopAccountLoginView<'a> { ui.add_space(8f32); - ui.add( - login_textedit(&mut self.manager.login_key).min_size(Vec2::new(440.0, 40.0)), - ); + ui.add(login_textedit(&mut self.manager.login_key).min_size(Vec2::new(440.0, 40.0))); ui.add_space(8.0); @@ -193,7 +191,9 @@ impl<'a> DesktopAccountLoginView<'a> { fn generate_group(&mut self, ui: &mut egui::Ui) { ui.horizontal(|ui| { - ui.label(RichText::new("New in nostr?").text_style(NotedeckTextStyle::Heading3.text_style())); + ui.label( + RichText::new("New in nostr?").text_style(NotedeckTextStyle::Heading3.text_style()), + ); ui.label( RichText::new(" — we got you!") @@ -266,7 +266,9 @@ fn login_button() -> Button<'static> { fn login_textedit(text: &mut dyn TextBuffer) -> TextEdit { egui::TextEdit::singleline(text) - .hint_text(RichText::new("Your key here...").text_style(NotedeckTextStyle::Body.text_style())) + .hint_text( + RichText::new("Your key here...").text_style(NotedeckTextStyle::Body.text_style()), + ) .vertical_align(Align::Center) .min_size(Vec2::new(0.0, 40.0)) .margin(Margin::same(12.0)) diff --git a/src/bin/notedeck.rs b/src/bin/notedeck.rs @@ -1,8 +1,7 @@ #![warn(clippy::all, rust_2018_idioms)] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release -use notedeck::Damus; use notedeck::app_creation::generate_native_options; - +use notedeck::Damus; // Entry point for wasm //#[cfg(target_arch = "wasm32")] diff --git a/src/images.rs b/src/images.rs @@ -1,12 +1,11 @@ use crate::error::Error; -use crate::result::Result; use crate::imgcache::ImageCache; +use crate::result::Result; use egui::{Color32, ColorImage, SizeHint, TextureHandle}; use image::imageops::FilterType; use poll_promise::Promise; -use tokio::fs; use std::path; - +use tokio::fs; //pub type ImageCacheKey = String; //pub type ImageCacheValue = Promise<Result<TextureHandle>>; @@ -112,11 +111,15 @@ fn parse_img_response(response: ehttp::Response, size: u32) -> Result<ColorImage } } -fn fetch_img_from_disk(ctx: &egui::Context, url: &str, path: &path::Path) -> Promise<Result<TextureHandle>> { +fn fetch_img_from_disk( + ctx: &egui::Context, + url: &str, + path: &path::Path, +) -> Promise<Result<TextureHandle>> { let ctx = ctx.clone(); let url = url.to_owned(); let path = path.to_owned(); - Promise::spawn_async(async move { + Promise::spawn_async(async move { let data = fs::read(path).await?; let image_buffer = image::load_from_memory(&data)?; @@ -152,7 +155,12 @@ pub fn fetch_img( // TODO: fetch image from local cache } -fn fetch_img_from_net(cache_path: &path::Path, ctx: &egui::Context, url: &str, size: u32) -> Promise<Result<TextureHandle>> { +fn fetch_img_from_net( + cache_path: &path::Path, + ctx: &egui::Context, + url: &str, + size: u32, +) -> Promise<Result<TextureHandle>> { let (sender, promise) = Promise::new(); let request = ehttp::Request::get(url); let ctx = ctx.clone(); @@ -166,9 +174,7 @@ fn fetch_img_from_net(cache_path: &path::Path, ctx: &egui::Context, url: &str, s let texture_handle = ctx.load_texture(&cloned_url, img.clone(), Default::default()); // write to disk - std::thread::spawn(move || { - ImageCache::write(&cache_path, &cloned_url, img) - }); + std::thread::spawn(move || ImageCache::write(&cache_path, &cloned_url, img)); texture_handle }); diff --git a/src/lib.rs b/src/lib.rs @@ -4,24 +4,24 @@ mod error; //mod note; //mod block; mod abbrev; +pub mod account_login_view; +pub mod app_creation; +mod app_style; +mod colors; +mod filter; mod fonts; +mod frame_history; mod images; -mod result; mod imgcache; -mod filter; -mod ui; -mod timecache; -mod time; -mod notecache; -mod frame_history; -mod timeline; -mod colors; -mod profile; mod key_parsing; pub mod login_manager; -pub mod account_login_view; -pub mod app_creation; -mod app_style; +mod notecache; +mod profile; +mod result; +mod time; +mod timecache; +mod timeline; +mod ui; #[cfg(test)] #[macro_use] diff --git a/src/login_manager.rs b/src/login_manager.rs @@ -8,7 +8,7 @@ pub struct LoginManager { pub login_key: String, pub promise: Option<Promise<Result<Keys, LoginError>>>, pub error: Option<LoginError>, - pub key_on_error: Option<String> + pub key_on_error: Option<String>, } impl LoginManager { @@ -17,7 +17,7 @@ impl LoginManager { login_key: String::new(), promise: None, error: None, - key_on_error: None + key_on_error: None, } } } diff --git a/src/ui_preview/account_login_preview.rs b/src/ui_preview/account_login_preview.rs @@ -36,4 +36,4 @@ impl eframe::App for MobileAccountLoginPreview { fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) { MobileAccountLoginView::new(ctx, &mut self.manager).panel() } -}- \ No newline at end of file +} diff --git a/src/ui_preview/main.rs b/src/ui_preview/main.rs @@ -2,7 +2,7 @@ mod account_login_preview; mod egui_preview_setup; use account_login_preview::{DesktopAccountLoginPreview, MobileAccountLoginPreview}; use egui_preview_setup::{EguiPreviewCase, EguiPreviewSetup}; -use notedeck::app_creation::{generate_native_options, generate_mobile_emulator_native_options}; +use notedeck::app_creation::{generate_mobile_emulator_native_options, generate_native_options}; use std::env; fn run_test_app<F, T, O>(create_supr: F, create_child: O, is_mobile: bool) @@ -26,15 +26,16 @@ where ); } - fn main() { let args: Vec<String> = env::args().collect(); if args.len() > 1 { match args[1].as_str() { - "DesktopAccountLoginPreview" => { - run_test_app(EguiPreviewSetup::new, DesktopAccountLoginPreview::new, false) - } + "DesktopAccountLoginPreview" => run_test_app( + EguiPreviewSetup::new, + DesktopAccountLoginPreview::new, + false, + ), "MobileAccountLoginPreview" => { run_test_app(EguiPreviewSetup::new, MobileAccountLoginPreview::new, true) }