diff --git a/Cargo.lock b/Cargo.lock index a23d9bb6e..df81781c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ab_glyph" @@ -191,6 +191,28 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +[[package]] +name = "alsa" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" +dependencies = [ + "alsa-sys", + "bitflags 2.6.0", + "cfg-if", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "android-activity" version = "0.5.2" @@ -487,6 +509,15 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "atomic" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -630,6 +661,26 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools 0.10.5", + "lazy_static", + "lazycell", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.87", +] + [[package]] name = "bindgen" version = "0.70.1" @@ -1075,6 +1126,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clang" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c044c781163c001b913cd018fc95a628c50d0d2dfea8bca77dad71edb16e37" +dependencies = [ + "clang-sys", + "libc", +] + [[package]] name = "clang-sys" version = "1.8.1" @@ -1267,6 +1328,49 @@ dependencies = [ "libm", ] +[[package]] +name = "coreaudio-rs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] + +[[package]] +name = "coreaudio-sys" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ce857aa0b77d77287acc1ac3e37a05a8c95a2af3647d23b15f263bdaeb7562b" +dependencies = [ + "bindgen 0.70.1", +] + +[[package]] +name = "cpal" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +dependencies = [ + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni", + "js-sys", + "libc", + "mach2", + "ndk", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.54.0", +] + [[package]] name = "cpufeatures" version = "0.2.15" @@ -1356,6 +1460,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + [[package]] name = "data-encoding" version = "2.6.0" @@ -1582,19 +1692,20 @@ dependencies = [ [[package]] name = "egui-video" -version = "0.1.0" -source = "git+https://github.com/mikedilger/egui-video?rev=8ff342e20a3806bfa6c8dd7a9cd44305210695c7#8ff342e20a3806bfa6c8dd7a9cd44305210695c7" +version = "0.8.0" +source = "git+https://github.com/v0l/egui-video.git?rev=cf880dd14b1451e08f2cd3877d27b4914ad6e6ac#cf880dd14b1451e08f2cd3877d27b4914ad6e6ac" dependencies = [ "anyhow", - "chrono", + "atomic", + "cpal", "egui", - "ffmpeg-next", - "itertools 0.10.5", - "parking_lot", - "ringbuf", - "sdl2", - "tempfile", - "timer", + "ffmpeg-rs-raw", + "itertools 0.13.0", + "log", + "m3u8-rs", + "nom", + "ureq", + "url", ] [[package]] @@ -1866,25 +1977,26 @@ dependencies = [ ] [[package]] -name = "ffmpeg-next" -version = "7.1.0" -source = "git+https://github.com/mikedilger/rust-ffmpeg.git?rev=2f5d8a3714247243b892d7927bad36e98c1aeb06#2f5d8a3714247243b892d7927bad36e98c1aeb06" +name = "ffmpeg-rs-raw" +version = "0.1.0" +source = "git+https://git.v0l.io/Kieran/ffmpeg-rs-raw.git?rev=a2c0e3374ba5130588adcbeda18439b69bb2cb12#a2c0e3374ba5130588adcbeda18439b69bb2cb12" dependencies = [ - "bitflags 2.6.0", - "ffmpeg-sys-next", + "anyhow", + "ffmpeg-sys-the-third", "libc", + "log", + "slimbox", ] [[package]] -name = "ffmpeg-sys-next" -version = "7.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc3234d0a4b2f7d083699d0860c6c9dd83713908771b60f94a96f8704adfe45" +name = "ffmpeg-sys-the-third" +version = "2.1.0+ffmpeg-7.1" +source = "git+https://git.v0l.io/Kieran/ffmpeg-the-third.git?rev=e5f8e077b04b10d5887bce4df1eb1a71738a6c66#e5f8e077b04b10d5887bce4df1eb1a71738a6c66" dependencies = [ - "bindgen", + "bindgen 0.69.5", "cc", + "clang", "libc", - "num_cpus", "pkg-config", "vcpkg", ] @@ -2318,7 +2430,6 @@ dependencies = [ "qrcode", "resvg 0.35.0", "rpassword", - "sdl2", "serde", "serde_json", "time", @@ -3152,6 +3263,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "lebe" version = "0.5.2" @@ -3316,6 +3433,25 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "m3u8-rs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f03cd3335fb5f2447755d45cda9c70f76013626a9db44374973791b0926a86c3" +dependencies = [ + "chrono", + "nom", +] + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "malloc_buf" version = "0.0.6" @@ -3928,6 +4064,29 @@ dependencies = [ "memchr", ] +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni", + "ndk", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -4846,15 +5005,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ringbuf" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79abed428d1fd2a128201cec72c5f6938e2da607c6f3745f769fabea399d950a" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "ron" version = "0.8.1" @@ -4963,6 +5113,7 @@ version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ + "log", "once_cell", "ring", "rustls-pki-types", @@ -5381,6 +5532,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slimbox" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26dfcf7e4fe830e4b9245b9e0def30d3df9ea194aca707e9a78b079d2b646b1a" + [[package]] name = "slotmap" version = "1.0.7" @@ -5823,15 +5980,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "timer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d42176308937165701f50638db1c31586f183f1aab416268216577aec7306b" -dependencies = [ - "chrono", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -6303,6 +6451,22 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "ureq" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" +dependencies = [ + "base64 0.22.1", + "flate2", + "log", + "once_cell", + "rustls", + "rustls-pki-types", + "url", + "webpki-roots", +] + [[package]] name = "url" version = "2.5.3" @@ -6855,7 +7019,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.5", + "libloading 0.7.4", "log", "metal", "naga", @@ -6944,6 +7108,16 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core 0.54.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.57.0" @@ -6963,6 +7137,16 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.57.0" diff --git a/gossip-bin/Cargo.toml b/gossip-bin/Cargo.toml index c4252f159..bad96618e 100644 --- a/gossip-bin/Cargo.toml +++ b/gossip-bin/Cargo.toml @@ -10,9 +10,9 @@ default-run = "gossip" edition = "2021" [features] -default = [ "rustls-tls-native" ] +default = [ "rustls-tls-native", "video-ffmpeg" ] lang-cjk = [ "gossip-lib/lang-cjk" ] -video-ffmpeg = [ "egui-video", "sdl2" ] +video-ffmpeg = [ "egui-video" ] native-tls = [ "gossip-lib/native-tls" ] rustls-tls = [ "gossip-lib/rustls-tls" ] rustls-tls-native = [ "gossip-lib/rustls-tls-native" ] @@ -26,7 +26,7 @@ egui-winit = { git = "https://github.com/bu5hm4nn/egui", rev = "f40370c48ae2e07d egui_extras = { git = "https://github.com/bu5hm4nn/egui", rev = "f40370c48ae2e07d2bc1d7ec33d094d29dc34e70", features = [ "syntect" ] } egui-file-dialog = { git = "https://github.com/mikedilger/egui-file-dialog", rev = "537561cdc805c97d480fde82f6a647abc6eee1af" } ## egui = { git = "https://github.com/bu5hm4nn/egui", rev = "f40370c48ae2e07d2bc1d7ec33d094d29dc34e70", features = [ "deadlock_detection" ] } -egui-video = { git = "https://github.com/mikedilger/egui-video", rev = "8ff342e20a3806bfa6c8dd7a9cd44305210695c7", features = [ "from_bytes" ], optional = true } +egui-video = { git = "https://github.com/v0l/egui-video.git", rev = "cf880dd14b1451e08f2cd3877d27b4914ad6e6ac", optional = true } gossip-lib = { path = "../gossip-lib" } humansize = "2.1" image = { version = "0.25", features = [ "png", "jpeg" ] } @@ -37,7 +37,6 @@ paste = "1.0" qrcode = "0.14" resvg = "0.35.0" rpassword = "7.3" -sdl2 = { version = "0.37", features = ["bundled"], optional = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" time = { version = "0.3", features = [ "formatting", "macros" ] } diff --git a/gossip-bin/src/notedata.rs b/gossip-bin/src/notedata.rs index 56fccec87..6073fcc3f 100644 --- a/gossip-bin/src/notedata.rs +++ b/gossip-bin/src/notedata.rs @@ -273,10 +273,10 @@ impl NoteData { _ => Person::new(author_pubkey), }; - let lists = match GLOBALS.db().read_person_lists(&author_pubkey) { - Ok(lists) => lists, - _ => HashMap::new(), - }; + let lists = GLOBALS + .db() + .read_person_lists(&author_pubkey) + .unwrap_or_default(); let seen_on = GLOBALS .db() diff --git a/gossip-bin/src/ui/feed/note/content/media.rs b/gossip-bin/src/ui/feed/note/content/media.rs index 3be40d27b..aefd030c5 100644 --- a/gossip-bin/src/ui/feed/note/content/media.rs +++ b/gossip-bin/src/ui/feed/note/content/media.rs @@ -1,6 +1,8 @@ use crate::ui::GossipUi; +use eframe::egui::vec2; use eframe::{egui, epaint}; use egui::{Image, Response, RichText, Ui}; +use egui_video::PlayerControls; use epaint::Vec2; use gossip_lib::{MediaLoadingResult, GLOBALS}; use nostr_types::{FileMetadata, Url}; @@ -292,22 +294,9 @@ fn try_render_video( } MediaLoadingResult::Ready(player_ref) => { if let Ok(mut player) = player_ref.try_borrow_mut() { - let size = media_scale( - show_full_width, - ui, - Vec2 { - x: player.width as f32, - y: player.height as f32, - }, - ); + let size = media_scale(show_full_width, ui, vec2(1280.0, 720.0)); - // show the player - if !show_full_width { - player.stop(); - } - let response = player.ui(ui, [size.x, size.y]); - - // stop the player when it scrolls out of view + let response = ui.allocate_ui(size, |ui| player.render(ui)).response; if !ui.is_rect_visible(response.rect) { player.stop(); } diff --git a/gossip-bin/src/ui/feed/note/content/mod.rs b/gossip-bin/src/ui/feed/note/content/mod.rs index f06b7dcdf..d789ecc7c 100644 --- a/gossip-bin/src/ui/feed/note/content/mod.rs +++ b/gossip-bin/src/ui/feed/note/content/mod.rs @@ -234,7 +234,8 @@ pub(super) fn render_hyperlink( if let Some(mimetype) = gossip_lib::media_url_mimetype(url.path()) { if mimetype.starts_with("image/") { media::show_image(app, ui, nurl, privacy_issue, note.volatile, file_metadata); - } else if mimetype.starts_with("video/") { + } else if mimetype.starts_with("video/") || mimetype == "application/vnd.apple.mpegurl" + { media::show_video(app, ui, nurl, privacy_issue, note.volatile, file_metadata); } } else { diff --git a/gossip-bin/src/ui/feed/note/mod.rs b/gossip-bin/src/ui/feed/note/mod.rs index 60a6af408..323ccf750 100644 --- a/gossip-bin/src/ui/feed/note/mod.rs +++ b/gossip-bin/src/ui/feed/note/mod.rs @@ -224,10 +224,10 @@ pub fn render_dm_note(app: &mut GossipUi, ui: &mut Ui, feed_note_params: FeedNot if let Some(note_ref) = app.notecache.try_update_and_get(&id) { if let Ok(note_data) = note_ref.try_borrow() { - let viewed = match GLOBALS.db().is_event_viewed(note_data.event.id) { - Ok(answer) => answer, - _ => false, - }; + let viewed = GLOBALS + .db() + .is_event_viewed(note_data.event.id) + .unwrap_or_default(); if let Ok(mut note_data) = note_ref.try_borrow_mut() { note_data.repost = Some(RepostType::GenericRepost); diff --git a/gossip-bin/src/ui/feed/post.rs b/gossip-bin/src/ui/feed/post.rs index 5348036df..48100d558 100644 --- a/gossip-bin/src/ui/feed/post.rs +++ b/gossip-bin/src/ui/feed/post.rs @@ -992,7 +992,7 @@ fn do_replacements(draft: &str, replacements: &HashMap) fn offer_attachment(app: &mut GossipUi, ctx: &Context, ui: &mut Ui, dm: bool) { // Skip if no blossom servers configured: let blossom_servers = GLOBALS.db().read_setting_blossom_servers(); - if blossom_servers.split_whitespace().next() == None { + if blossom_servers.split_whitespace().next().is_none() { return; } diff --git a/gossip-bin/src/ui/mod.rs b/gossip-bin/src/ui/mod.rs index 982a7be6c..e7e296ce8 100644 --- a/gossip-bin/src/ui/mod.rs +++ b/gossip-bin/src/ui/mod.rs @@ -63,7 +63,7 @@ use egui::{ }; use egui_file_dialog::FileDialog; #[cfg(feature = "video-ffmpeg")] -use egui_video::{AudioDevice, Player}; +use egui_video::Player; use egui_winit::egui::Rect; use egui_winit::egui::Response; use egui_winit::egui::ViewportBuilder; @@ -414,14 +414,8 @@ impl DraftData { } struct GossipUi { - #[cfg(feature = "video-ffmpeg")] - audio_device: Option, #[cfg(feature = "video-ffmpeg")] video_players: HashMap>>, - // dismissed libsdl2 warning - #[cfg(feature = "video-ffmpeg")] - warn_no_libsdl2_dismissed: bool, - initializing: bool, // Rendering @@ -631,19 +625,6 @@ impl GossipUi { ) }; - #[cfg(feature = "video-ffmpeg")] - let audio_device = { - let mut device = None; - if let Ok(init) = sdl2::init() { - if let Ok(audio) = init.audio() { - if let Ok(dev) = egui_video::init_audio_device(&audio) { - device = Some(dev); - } - } - } - device - }; - // start with a fallback DPI here, unless we are overriding anyways // we won't know the native DPI until the `Viewport` has been created let (override_dpi, override_dpi_value): (bool, u32) = match read_setting!(override_dpi) { @@ -706,12 +687,8 @@ impl GossipUi { } GossipUi { - #[cfg(feature = "video-ffmpeg")] - audio_device, #[cfg(feature = "video-ffmpeg")] video_players: HashMap::new(), - #[cfg(feature = "video-ffmpeg")] - warn_no_libsdl2_dismissed: false, initializing: true, next_frame: Instant::now(), override_dpi, @@ -1706,38 +1683,10 @@ impl GossipUi { return MediaLoadingResult::Ready(player.to_owned()); } - match GLOBALS.media.get_data(&url, volatile, file_metadata) { - MediaLoadingResult::Disabled => MediaLoadingResult::Disabled, - MediaLoadingResult::Loading => MediaLoadingResult::Loading, - MediaLoadingResult::Ready(bytes) => { - if let Ok(player) = Player::new_from_bytes(ctx, &bytes) { - if let Some(audio) = &mut self.audio_device { - if let Ok(player) = player.with_audio(audio) { - let player_ref = Rc::new(RefCell::new(player)); - self.video_players.insert(url.clone(), player_ref.clone()); - MediaLoadingResult::Ready(player_ref) - } else { - let failure = "Player setup with audio failed".to_owned(); - GLOBALS - .media - .set_has_failed(&url.to_unchecked_url(), failure.clone()); - MediaLoadingResult::Failed(failure) - } - } else { - let player_ref = Rc::new(RefCell::new(player)); - self.video_players.insert(url.clone(), player_ref.clone()); - MediaLoadingResult::Ready(player_ref) - } - } else { - let failure = "Player setup failed".to_owned(); - GLOBALS - .media - .set_has_failed(&url.to_unchecked_url(), failure.clone()); - MediaLoadingResult::Failed(failure) - } - } - MediaLoadingResult::Failed(s) => MediaLoadingResult::Failed(s), - } + let player = Player::new(ctx, &url.to_string()); + let player_ref = Rc::new(RefCell::new(player)); + self.video_players.insert(url.clone(), player_ref.clone()); + MediaLoadingResult::Ready(player_ref) } pub fn show_qr(&mut self, ui: &mut Ui, key: &str) { @@ -2236,17 +2185,6 @@ impl eframe::App for GossipUi { (false, false) }; - let has_warning = { - #[cfg(feature = "video-ffmpeg")] - { - !self.warn_no_libsdl2_dismissed && self.audio_device.is_none() - } - #[cfg(not(feature = "video-ffmpeg"))] - { - false - } - }; - egui::TopBottomPanel::top("top-panel") .frame( egui::Frame::side_top_panel(&self.theme.get_style()).inner_margin(egui::Margin { @@ -2257,32 +2195,12 @@ impl eframe::App for GossipUi { }), ) .resizable(true) - .show_animated( - ctx, - show_top_post_area || has_warning, - |ui| { - self.begin_ui(ui); - #[cfg(feature = "video-ffmpeg")] - { - if has_warning { - widgets::warning_frame(ui, self, |ui, app| { - ui.label("You have compiled gossip with 'video-ffmpeg' option but no audio device was found on your system. Make sure you have followed the instructions at "); - ui.hyperlink("https://github.com/Rust-SDL2/rust-sdl2"); - ui.label("and installed 'libsdl2-dev' package for your system."); - ui.end_row(); - ui.with_layout(egui::Layout::right_to_left(egui::Align::default()), |ui| { - if ui.link("Dismiss message").clicked() { - app.warn_no_libsdl2_dismissed = true; - } - }); - }); - } - } - if show_top_post_area { - feed::post::posting_area(self, ctx, frame, ui); - } - }, - ); + .show_animated(ctx, show_top_post_area, |ui| { + self.begin_ui(ui); + if show_top_post_area { + feed::post::posting_area(self, ctx, frame, ui); + } + }); let resizable = true; diff --git a/gossip-bin/src/ui/relays/active.rs b/gossip-bin/src/ui/relays/active.rs index b66aaaa36..3c1795b2b 100644 --- a/gossip-bin/src/ui/relays/active.rs +++ b/gossip-bin/src/ui/relays/active.rs @@ -29,7 +29,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr widgets::page_header( ui, - &format!( + format!( "{} ({} relays)", Page::RelaysActivityMonitor.name(), relays.len() diff --git a/gossip-bin/src/ui/relays/known.rs b/gossip-bin/src/ui/relays/known.rs index 817b8bfc6..dbc60cea6 100644 --- a/gossip-bin/src/ui/relays/known.rs +++ b/gossip-bin/src/ui/relays/known.rs @@ -27,7 +27,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr widgets::page_header( ui, - &format!( + format!( "{} ({} relays)", Page::RelaysKnownNetwork(None).name(), relays.len() diff --git a/gossip-bin/src/ui/relays/mine.rs b/gossip-bin/src/ui/relays/mine.rs index b8d3119bf..1eb368cac 100644 --- a/gossip-bin/src/ui/relays/mine.rs +++ b/gossip-bin/src/ui/relays/mine.rs @@ -25,7 +25,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr widgets::page_header( ui, - &format!("{} ({} relays)", Page::RelaysMine.name(), relays.len()), + format!("{} ({} relays)", Page::RelaysMine.name(), relays.len()), |ui| { if is_editing { ui.disable(); diff --git a/gossip-bin/src/ui/settings/posting.rs b/gossip-bin/src/ui/settings/posting.rs index 6196002c4..b606daf7b 100644 --- a/gossip-bin/src/ui/settings/posting.rs +++ b/gossip-bin/src/ui/settings/posting.rs @@ -23,7 +23,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr ui.checkbox( &mut app.unsaved_settings.set_user_agent, - &format!( + format!( "Send User-Agent Header to Relays: gossip/{}", app.about.version ), diff --git a/gossip-bin/src/ui/widgets/switch.rs b/gossip-bin/src/ui/widgets/switch.rs index df0e22c66..e22b9b381 100644 --- a/gossip-bin/src/ui/widgets/switch.rs +++ b/gossip-bin/src/ui/widgets/switch.rs @@ -130,7 +130,7 @@ impl<'a> Switch<'a> { // } } -impl<'a> Widget for Switch<'a> { +impl Widget for Switch<'_> { fn ui(self, ui: &mut Ui) -> Response { self.show(ui) } diff --git a/gossip-bin/src/ui/widgets/textedit.rs b/gossip-bin/src/ui/widgets/textedit.rs index 257ad83d1..90c0c60e9 100644 --- a/gossip-bin/src/ui/widgets/textedit.rs +++ b/gossip-bin/src/ui/widgets/textedit.rs @@ -294,7 +294,7 @@ impl<'t> TextEdit<'t> { } } -impl<'t> Widget for TextEdit<'t> { +impl Widget for TextEdit<'_> { fn ui(self, ui: &mut egui_winit::egui::Ui) -> egui_winit::egui::Response { let output = self.show(ui); output.response diff --git a/gossip-bin/src/ui/you/metadata.rs b/gossip-bin/src/ui/you/metadata.rs index 11c6ba890..7a76726a5 100644 --- a/gossip-bin/src/ui/you/metadata.rs +++ b/gossip-bin/src/ui/you/metadata.rs @@ -150,7 +150,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra fn view_line(ui: &mut Ui, field: &str, data: Option<&String>) { ui.horizontal(|ui| { - ui.label(&format!("{}: ", field)); + ui.label(format!("{}: ", field)); if let Some(value) = data { ui.label(value); } else { @@ -161,7 +161,7 @@ fn view_line(ui: &mut Ui, field: &str, data: Option<&String>) { fn edit_line(ui: &mut Ui, field: &str, data: &mut Option, edit_color: Color32) { ui.horizontal(|ui| { - ui.label(&format!("{}: ", field)); + ui.label(format!("{}: ", field)); ui.with_layout(Layout::right_to_left(Align::TOP), |ui| { if data.is_some() { if ui.button("Remove").clicked() { @@ -189,7 +189,7 @@ fn edit_line(ui: &mut Ui, field: &str, data: &mut Option, edit_color: Co fn view_lines_other(ui: &mut Ui, other: &Map) { for (field, jsonvalue) in other.iter() { ui.horizontal(|ui| { - ui.label(&format!("{}: ", field)); + ui.label(format!("{}: ", field)); if let Value::String(s) = jsonvalue { ui.label(s.to_owned()); } else if let Ok(s) = serde_json::to_string(&jsonvalue) { @@ -206,7 +206,7 @@ fn edit_lines_other(ui: &mut Ui, other: &mut Map, edit_color: Col let mut to_remove: Vec = Vec::new(); for (field, jsonvalue) in other.iter_mut() { ui.horizontal(|ui| { - ui.label(&format!("{}: ", field)); + ui.label(format!("{}: ", field)); if let Value::String(s) = jsonvalue { ui.with_layout(Layout::right_to_left(Align::TOP), |ui| { if ui.button("Remove").clicked() { diff --git a/gossip-bin/src/ui/you/mod.rs b/gossip-bin/src/ui/you/mod.rs index e55f549d0..8b6c64fb1 100644 --- a/gossip-bin/src/ui/you/mod.rs +++ b/gossip-bin/src/ui/you/mod.rs @@ -130,7 +130,7 @@ fn show_pub_key_detail(app: &mut GossipUi, ui: &mut Ui) { let pkhex: PublicKeyHex = public_key.into(); ui.horizontal_wrapped(|ui| { - ui.label(&format!("Public Key (Hex): {}", pkhex.as_str())); + ui.label(format!("Public Key (Hex): {}", pkhex.as_str())); if ui.add(CopyButton::new()).clicked() { ui.output_mut(|o| o.copied_text = pkhex.into_string()); } @@ -138,7 +138,7 @@ fn show_pub_key_detail(app: &mut GossipUi, ui: &mut Ui) { let bech32 = public_key.as_bech32_string(); ui.horizontal_wrapped(|ui| { - ui.label(&format!("Public Key (bech32): {}", bech32)); + ui.label(format!("Public Key (bech32): {}", bech32)); if ui.add(CopyButton::new()).clicked() { ui.output_mut(|o| o.copied_text = bech32.clone()); } @@ -156,7 +156,7 @@ fn show_pub_key_detail(app: &mut GossipUi, ui: &mut Ui) { let nprofile = profile.as_bech32_string(); ui.horizontal_wrapped(|ui| { - ui.label(&format!("Your Profile: {}", &nprofile)); + ui.label(format!("Your Profile: {}", &nprofile)); if ui.add(CopyButton::new()).clicked() { ui.output_mut(|o| o.copied_text = nprofile.clone()); } @@ -382,7 +382,7 @@ fn offer_delete_or_import_pub_key(app: &mut GossipUi, ui: &mut Ui) { let pkhex: PublicKeyHex = pk.into(); ui.horizontal(|ui| { - ui.label(&format!("Public Key (Hex): {}", pkhex.as_str())); + ui.label(format!("Public Key (Hex): {}", pkhex.as_str())); if ui.add(CopyButton::new()).clicked() { ui.output_mut(|o| o.copied_text = pkhex.into_string()); } @@ -390,7 +390,7 @@ fn offer_delete_or_import_pub_key(app: &mut GossipUi, ui: &mut Ui) { let bech32 = pk.as_bech32_string(); ui.horizontal(|ui| { - ui.label(&format!("Public Key (bech32): {}", bech32)); + ui.label(format!("Public Key (bech32): {}", bech32)); if ui.add(CopyButton::new()).clicked() { ui.output_mut(|o| o.copied_text = bech32); } diff --git a/gossip-lib/src/blossom.rs b/gossip-lib/src/blossom.rs index 43df1e63e..1ea704477 100644 --- a/gossip-lib/src/blossom.rs +++ b/gossip-lib/src/blossom.rs @@ -211,7 +211,7 @@ impl Blossom { Err(e) => { let text = String::from_utf8_lossy(&full); tracing::error!("Failed to deserialize Blossom Blob Descriptor: {}", text); - return Err(e.into()); + Err(e.into()) } } } else { diff --git a/gossip-lib/src/feed/mod.rs b/gossip-lib/src/feed/mod.rs index e391038bc..748c7121b 100644 --- a/gossip-lib/src/feed/mod.rs +++ b/gossip-lib/src/feed/mod.rs @@ -352,7 +352,7 @@ impl Feed { .db() .get_people_in_list(list)? .drain(..) - .map(|(pk, _)| pk.into()) + .map(|(pk, _)| pk) .collect(); filter.kinds = feed_displayable_event_kinds(false); filter @@ -439,7 +439,7 @@ impl Feed { FeedKind::Person(person_pubkey) => { let filter = { let mut filter = Filter::new(); - filter.authors = vec![person_pubkey.into()]; + filter.authors = vec![person_pubkey]; filter.kinds = feed_displayable_event_kinds(false); filter }; diff --git a/gossip-lib/src/media.rs b/gossip-lib/src/media.rs index 77ed2bb7a..763a5539f 100644 --- a/gossip-lib/src/media.rs +++ b/gossip-lib/src/media.rs @@ -380,6 +380,8 @@ pub fn media_url_mimetype(s: &str) -> Option<&'static str> { Some("video/x-ms-wmv") } else if lower.ends_with(".3gp") { Some("video/3gpp") + } else if lower.ends_with(".m3u8") { + Some("application/vnd.apple.mpegurl") } else { None } diff --git a/gossip-lib/src/minion/handle_websocket.rs b/gossip-lib/src/minion/handle_websocket.rs index 12e182d03..2d434962c 100644 --- a/gossip-lib/src/minion/handle_websocket.rs +++ b/gossip-lib/src/minion/handle_websocket.rs @@ -368,8 +368,10 @@ impl Minion { let _ = self.subscription_map.remove(&handle); } RelayMessage::Count(_subid, _count_result) => { - tracing::info!("{} Relay returned count results that we do not yet support", - &self.url); + tracing::info!( + "{} Relay returned count results that we do not yet support", + &self.url + ); } } diff --git a/gossip-lib/src/overlord.rs b/gossip-lib/src/overlord.rs index 4b2e3c0a7..dac29ace2 100644 --- a/gossip-lib/src/overlord.rs +++ b/gossip-lib/src/overlord.rs @@ -2036,7 +2036,7 @@ impl Overlord { let mut tags: Vec = Vec::new(); let blossom_servers = GLOBALS.db().read_setting_blossom_servers(); for server in blossom_servers.split_whitespace() { - tags.push(Tag::new(&["server", &server])); + tags.push(Tag::new(&["server", server])); } let pre_event = PreEvent { @@ -2706,7 +2706,7 @@ impl Overlord { // Subscribe to replies to root if let Some(ref root_eref) = ancestors.root { let filter_set = match root_eref { - EventReference::Id { id, .. } => FilterSet::RepliesToId((*id).into()), + EventReference::Id { id, .. } => FilterSet::RepliesToId(*id), EventReference::Addr(naddr) => FilterSet::RepliesToAddr(naddr.clone()), }; let relays = root_eref.copy_relays(); @@ -2761,7 +2761,7 @@ impl Overlord { reason: RelayConnectionReason::ReadThread, payload: ToMinionPayload { job_id: rand::random::(), - detail: ToMinionPayloadDetail::Subscribe(FilterSet::RepliesToId(id.into())), + detail: ToMinionPayloadDetail::Subscribe(FilterSet::RepliesToId(id)), }, }]; diff --git a/gossip-lib/src/post.rs b/gossip-lib/src/post.rs index c336d629a..85ac1a92b 100644 --- a/gossip-lib/src/post.rs +++ b/gossip-lib/src/post.rs @@ -215,7 +215,7 @@ async fn add_tags_mirroring_content(content: &str, tags: &mut Vec, direct_m // do nothing } ContentSegment::Hyperlink(span) => { - if let Some(slice) = shattered_content.slice(&span) { + if let Some(slice) = shattered_content.slice(span) { if let Some(mimetype) = crate::media_url_mimetype(slice) { add_imeta_tag(slice, mimetype, tags).await; } diff --git a/gossip-lib/src/spam_filter.rs b/gossip-lib/src/spam_filter.rs index d836d531f..e6ad5491a 100644 --- a/gossip-lib/src/spam_filter.rs +++ b/gossip-lib/src/spam_filter.rs @@ -121,10 +121,7 @@ fn inner_filter(event_params: EventParams) -> EventFilterAction { return EventFilterAction::Allow; } - let author = match PersonTable::read_record(pubkey, None) { - Ok(a) => a, - Err(_) => None, - }; + let author = PersonTable::read_record(pubkey, None).unwrap_or_default(); let muted = GLOBALS.people.is_person_in_list(&pubkey, PersonList::Muted); diff --git a/gossip-lib/src/storage/mod.rs b/gossip-lib/src/storage/mod.rs index b268d0831..27272818f 100644 --- a/gossip-lib/src/storage/mod.rs +++ b/gossip-lib/src/storage/mod.rs @@ -1519,7 +1519,7 @@ impl Storage { // Use events table directly, we have specific ids for idhex in filter.ids.iter() { - let id: Id = idhex.clone().into(); + let id: Id = *idhex; if output.len() >= limit { break; } @@ -1918,7 +1918,7 @@ impl Storage { if !output.is_empty() { use std::cmp::Ordering; let mut filter = Filter::new(); - filter.ids = output.iter().map(|id| (*id).into()).collect(); + filter.ids = output.to_vec(); let mut events = self.find_events_by_filter(&filter, |_| true)?; events.sort_by( |a, b| match (a.pubkey == event.pubkey, b.pubkey == event.pubkey) { diff --git a/gossip-lib/src/storage/prune.rs b/gossip-lib/src/storage/prune.rs index ed190f17d..1303412f3 100644 --- a/gossip-lib/src/storage/prune.rs +++ b/gossip-lib/src/storage/prune.rs @@ -147,7 +147,7 @@ impl Storage { } // Load up to 6 of their events - filter.authors = vec![person.pubkey.into()]; + filter.authors = vec![person.pubkey]; let events = match self.find_events_by_filter(&filter, |_| true) { Ok(events) => events, Err(_) => continue, // some error we can't handle right now diff --git a/gossip-lib/src/storage/table.rs b/gossip-lib/src/storage/table.rs index fa789a2cc..72e089838 100644 --- a/gossip-lib/src/storage/table.rs +++ b/gossip-lib/src/storage/table.rs @@ -296,7 +296,7 @@ pub struct TableIterator<'a, I: Record> { phantom: std::marker::PhantomData, } -impl<'a, I: Record> Iterator for TableIterator<'a, I> { +impl Iterator for TableIterator<'_, I> { type Item = (I::Key, I); fn next(&mut self) -> Option {