diff --git a/.gitignore b/.gitignore index 766cf12..42de706 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # will have compiled files and executables debug/ target/ +dist/ # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock index bb4a1e0..2f30c4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -693,9 +693,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" +checksum = "73848a43c5d63a1251d17adf6c2bf78aa94830e60a335a95eeea45d6ba9e1e4d" [[package]] name = "bumpalo" @@ -1063,7 +1063,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "indexmap", "rustc-hash 2.1.1", @@ -1345,9 +1345,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" [[package]] name = "data-url" @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "proc-macro2", "quote", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "anyhow", "as-raw-xcb-connection", @@ -2192,7 +2192,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "proc-macro2", "quote", @@ -2202,7 +2202,7 @@ dependencies = [ [[package]] name = "gpui_tokio" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "gpui", "tokio", @@ -2416,7 +2416,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "anyhow", "bytes", @@ -3074,7 +3074,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "anyhow", "bindgen", @@ -3259,7 +3259,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" [[package]] name = "nostr" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#6e790f0fdb5a11a463ace78e37c31c4818fe4199" +source = "git+https://github.com/rust-nostr/nostr#6caf231eca951f2c6909382c46f43edffbd6e730" dependencies = [ "aes", "base64", @@ -3287,7 +3287,7 @@ dependencies = [ [[package]] name = "nostr-connect" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#6e790f0fdb5a11a463ace78e37c31c4818fe4199" +source = "git+https://github.com/rust-nostr/nostr#6caf231eca951f2c6909382c46f43edffbd6e730" dependencies = [ "async-utility", "nostr", @@ -3299,7 +3299,7 @@ dependencies = [ [[package]] name = "nostr-database" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#6e790f0fdb5a11a463ace78e37c31c4818fe4199" +source = "git+https://github.com/rust-nostr/nostr#6caf231eca951f2c6909382c46f43edffbd6e730" dependencies = [ "flatbuffers", "lru", @@ -3310,18 +3310,20 @@ dependencies = [ [[package]] name = "nostr-lmdb" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#6e790f0fdb5a11a463ace78e37c31c4818fe4199" +source = "git+https://github.com/rust-nostr/nostr#6caf231eca951f2c6909382c46f43edffbd6e730" dependencies = [ "async-utility", "heed", "nostr", "nostr-database", + "tokio", + "tracing", ] [[package]] name = "nostr-relay-pool" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#6e790f0fdb5a11a463ace78e37c31c4818fe4199" +source = "git+https://github.com/rust-nostr/nostr#6caf231eca951f2c6909382c46f43edffbd6e730" dependencies = [ "async-utility", "async-wsocket", @@ -3338,7 +3340,7 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#6e790f0fdb5a11a463ace78e37c31c4818fe4199" +source = "git+https://github.com/rust-nostr/nostr#6caf231eca951f2c6909382c46f43edffbd6e730" dependencies = [ "async-utility", "nostr", @@ -4375,7 +4377,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "derive_refineable", ] @@ -4508,7 +4510,7 @@ dependencies = [ [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "anyhow", "bytes", @@ -4858,7 +4860,7 @@ checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" [[package]] name = "semantic_version" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "anyhow", "serde", @@ -5183,7 +5185,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "arrayvec", "log", @@ -5725,9 +5727,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -6053,7 +6055,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4207b194e35e87edc56a8d045aa5711b29ab8859" +source = "git+https://github.com/zed-industries/zed#c1f162abc6cb41a0c765aa76c3af3e83a994ce18" dependencies = [ "anyhow", "async-fs", @@ -6681,9 +6683,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] diff --git a/crates/app/Cargo.toml b/crates/app/Cargo.toml index 4e362d0..6f5655d 100644 --- a/crates/app/Cargo.toml +++ b/crates/app/Cargo.toml @@ -37,6 +37,8 @@ log = "0.4" before-packaging-command = "cargo build --release" product-name = "Coop" identifier = "su.reya.coop" +version = "0.1.0" +out-dir = "../../dist" resources = ["src", "icons/*", "Cargo.toml", "../../README.md"] icons = [ "icons/32x32.png", diff --git a/crates/app/icons/128x128.png b/crates/app/icons/128x128.png new file mode 100644 index 0000000..805fb86 Binary files /dev/null and b/crates/app/icons/128x128.png differ diff --git a/crates/app/icons/128x128@2x.png b/crates/app/icons/128x128@2x.png new file mode 100644 index 0000000..191279a Binary files /dev/null and b/crates/app/icons/128x128@2x.png differ diff --git a/crates/app/icons/32x32.png b/crates/app/icons/32x32.png new file mode 100644 index 0000000..57fa552 Binary files /dev/null and b/crates/app/icons/32x32.png differ diff --git a/crates/app/icons/icon.icns b/crates/app/icons/icon.icns new file mode 100644 index 0000000..9078639 Binary files /dev/null and b/crates/app/icons/icon.icns differ diff --git a/crates/app/icons/icon.ico b/crates/app/icons/icon.ico new file mode 100644 index 0000000..19adcf2 Binary files /dev/null and b/crates/app/icons/icon.ico differ diff --git a/crates/app/icons/icon.png b/crates/app/icons/icon.png new file mode 100644 index 0000000..ef9c461 Binary files /dev/null and b/crates/app/icons/icon.png differ diff --git a/crates/app/src/views/app.rs b/crates/app/src/views/app.rs index 22da5b4..e27ebf3 100644 --- a/crates/app/src/views/app.rs +++ b/crates/app/src/views/app.rs @@ -1,9 +1,14 @@ +use cargo_packager_updater::{check_update, semver::Version, url::Url}; use chat_state::registry::ChatRegistry; -use common::profile::NostrProfile; +use common::{ + constants::{UPDATER_PUBKEY, UPDATER_URL}, + profile::NostrProfile, +}; use gpui::{ actions, div, img, impl_internal_actions, px, App, AppContext, Axis, Context, Entity, InteractiveElement, IntoElement, ObjectFit, ParentElement, Render, Styled, StyledImage, Window, }; +use log::info; use nostr_sdk::prelude::*; use serde::Deserialize; use state::get_client; @@ -56,9 +61,14 @@ pub struct AppView { impl AppView { pub fn new(account: NostrProfile, window: &mut Window, cx: &mut App) -> Entity { + // Initialize dock layout let dock = cx.new(|cx| DockArea::new(window, cx)); let weak_dock = dock.downgrade(); + + // Initialize left dock let left_panel = DockItem::panel(Arc::new(sidebar::init(window, cx))); + + // Initial central dock let center_panel = DockItem::split_with_sizes( Axis::Vertical, vec![DockItem::tabs( @@ -74,7 +84,7 @@ impl AppView { cx, ); - // Set default dock layout + // Set default dock layout with left and central docks _ = weak_dock.update(cx, |view, cx| { view.set_left_dock(left_panel, Some(px(240.)), true, window, cx); view.set_center(center_panel, window, cx); @@ -83,7 +93,27 @@ impl AppView { let public_key = account.public_key(); let window_handle = window.window_handle(); - // Check user's inbox relays and determine user is ready for NIP17 or not. + // Check and auto update to the latest version + cx.background_spawn(async move { + // Set auto updater config + let config = cargo_packager_updater::Config { + endpoints: vec![Url::parse(UPDATER_URL).expect("Failed to parse UPDATER URL")], + pubkey: String::from(UPDATER_PUBKEY), + ..Default::default() + }; + + // Run auto updater + if let Ok(current_version) = Version::parse(env!("CARGO_PKG_VERSION")) { + if let Ok(Some(update)) = check_update(current_version, config) { + if update.download_and_install().is_ok() { + info!("Update installed") + } + } + } + }) + .detach(); + + // Check user's messaging relays and determine user is ready for NIP17 or not. // If not, show the setup modal and instruct user setup inbox relays cx.spawn(|mut cx| async move { let (tx, rx) = oneshot::channel::(); @@ -118,7 +148,7 @@ impl AppView { this.keyboard(false) .closable(false) .width(px(420.)) - .title("Your Inbox is not configured") + .title("Your Messaging Relays is not configured") .child(relays.clone()) .footer( div() diff --git a/crates/app/src/views/relays.rs b/crates/app/src/views/relays.rs index f2882b6..14dd472 100644 --- a/crates/app/src/views/relays.rs +++ b/crates/app/src/views/relays.rs @@ -136,7 +136,7 @@ impl Relays { impl Render for Relays { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - let msg = "In order to receive messages from others, you need to setup Inbox Relays. You can use the recommend relays or add more."; + let msg = "In order to receive messages from others, you need to setup Messaging Relays. You can use the recommend relays or add more."; div() .track_focus(&self.focus_handle) diff --git a/crates/chat_state/src/registry.rs b/crates/chat_state/src/registry.rs index 42e0494..854eb01 100644 --- a/crates/chat_state/src/registry.rs +++ b/crates/chat_state/src/registry.rs @@ -155,16 +155,14 @@ impl ChatRegistry { let this = room.downgrade(); cx.spawn(|mut cx| async move { - if let Err(e) = cx.update_window(window_handle, |_, _, cx| { + _ = cx.update_window(window_handle, |_, _, cx| { _ = this.update(cx, |this, cx| { this.last_seen.set(event.created_at); this.new_messages.push(event); cx.notify(); }); - }) { - println!("Error: {}", e) - } + }); }) .detach(); } else { diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 9cb4d8f..c0d85b2 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -13,3 +13,9 @@ pub const IMAGE_SERVICE: &str = "https://wsrv.nl"; /// NIP96 Media Server pub const NIP96_SERVER: &str = "https://nostrmedia.com"; + +/// Updater Public Key +pub const UPDATER_PUBKEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkxM0EzQTQyRTBBMENENTYKUldSV3phRGdRam82a1dtU0JqYll4VnBaVUpSWUxCWlVQbnRkUnNERS96MzFMWDhqNW5zOXplMEwK"; +/// Updater Server URL +pub const UPDATER_URL: &str = + "https://cdn.crabnebula.app/update/lume/coop/{{target}}-{{arch}}/{{current_version}}"; diff --git a/crates/ui/src/dock_area/stack_panel.rs b/crates/ui/src/dock_area/stack_panel.rs index f74487a..60e02eb 100644 --- a/crates/ui/src/dock_area/stack_panel.rs +++ b/crates/ui/src/dock_area/stack_panel.rs @@ -256,8 +256,6 @@ impl StackPanel { cx.emit(PanelEvent::LayoutChanged); self.remove_self_if_empty(window, cx); - } else { - println!("Panel not found in stack panel."); } } diff --git a/crates/ui/src/input/element.rs b/crates/ui/src/input/element.rs index 03a6af4..0860863 100644 --- a/crates/ui/src/input/element.rs +++ b/crates/ui/src/input/element.rs @@ -299,31 +299,6 @@ impl IntoElement for TextElement { } } -/// A debug function to print points as SVG path. -#[allow(unused)] -fn print_points_as_svg_path(line_corners: &Vec>>, points: &[Point]) { - for corners in line_corners { - println!( - "tl: ({}, {}), tr: ({}, {}), bl: ({}, {}), br: ({}, {})", - corners.top_left.x.0 as i32, - corners.top_left.y.0 as i32, - corners.top_right.x.0 as i32, - corners.top_right.y.0 as i32, - corners.bottom_left.x.0 as i32, - corners.bottom_left.y.0 as i32, - corners.bottom_right.x.0 as i32, - corners.bottom_right.y.0 as i32, - ); - } - - if !points.is_empty() { - println!("M{},{}", points[0].x.0 as i32, points[0].y.0 as i32); - for p in points.iter().skip(1) { - println!("L{},{}", p.x.0 as i32, p.y.0 as i32); - } - } -} - impl Element for TextElement { type RequestLayoutState = (); type PrepaintState = PrepaintState; diff --git a/crates/ui/src/notification.rs b/crates/ui/src/notification.rs index 488f5b7..b66deac 100644 --- a/crates/ui/src/notification.rs +++ b/crates/ui/src/notification.rs @@ -340,12 +340,9 @@ impl NotificationList { // Sleep for 3 seconds to autohide the notification cx.spawn_in(window, |_, mut cx| async move { Timer::after(Duration::from_secs(3)).await; - - if let Err(err) = notification.update_in(&mut cx, |note, window, cx| { + _ = notification.update_in(&mut cx, |note, window, cx| { note.dismiss(&ClickEvent::default(), window, cx) - }) { - println!("failed to auto hide notification: {:?}", err); - } + }); }) .detach(); }