diff --git a/Cargo.lock b/Cargo.lock
index 5770aab..f10f628 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1189,7 +1189,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"indexmap",
"rustc-hash 2.1.1",
@@ -1646,7 +1646,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"proc-macro2",
"quote",
@@ -2587,7 +2587,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.2.2"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"async-channel 2.5.0",
@@ -2666,7 +2666,7 @@ dependencies = [
[[package]]
name = "gpui_linux"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"as-raw-xcb-connection",
@@ -2714,7 +2714,7 @@ dependencies = [
[[package]]
name = "gpui_macos"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"async-task",
@@ -2755,7 +2755,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@@ -2766,7 +2766,7 @@ dependencies = [
[[package]]
name = "gpui_platform"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"console_error_panic_hook",
"gpui",
@@ -2779,7 +2779,7 @@ dependencies = [
[[package]]
name = "gpui_tokio"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"gpui",
@@ -2790,7 +2790,7 @@ dependencies = [
[[package]]
name = "gpui_util"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"log",
@@ -2799,7 +2799,7 @@ dependencies = [
[[package]]
name = "gpui_web"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"console_error_panic_hook",
@@ -2822,7 +2822,7 @@ dependencies = [
[[package]]
name = "gpui_wgpu"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"bytemuck",
@@ -2850,7 +2850,7 @@ dependencies = [
[[package]]
name = "gpui_windows"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"collections",
@@ -3094,7 +3094,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"async-compression",
@@ -3119,7 +3119,7 @@ dependencies = [
[[package]]
name = "http_client_tls"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"rustls",
"rustls-platform-verifier",
@@ -3543,9 +3543,9 @@ dependencies = [
[[package]]
name = "js-sys"
-version = "0.3.90"
+version = "0.3.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6"
+checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -3661,7 +3661,7 @@ checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616"
dependencies = [
"bitflags 2.11.0",
"libc",
- "redox_syscall 0.7.2",
+ "redox_syscall 0.7.3",
]
[[package]]
@@ -3880,7 +3880,7 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"bindgen",
@@ -4107,7 +4107,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
[[package]]
name = "nostr"
version = "0.44.1"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"aes",
"base64",
@@ -4131,7 +4131,7 @@ dependencies = [
[[package]]
name = "nostr-blossom"
version = "0.44.0"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"base64",
"nostr",
@@ -4142,7 +4142,7 @@ dependencies = [
[[package]]
name = "nostr-connect"
version = "0.44.0"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"async-utility",
"futures-core",
@@ -4155,7 +4155,7 @@ dependencies = [
[[package]]
name = "nostr-database"
version = "0.44.0"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"btreecap",
"flatbuffers",
@@ -4165,7 +4165,7 @@ dependencies = [
[[package]]
name = "nostr-gossip"
version = "0.44.0"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"nostr",
]
@@ -4173,7 +4173,7 @@ dependencies = [
[[package]]
name = "nostr-lmdb"
version = "0.44.0"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"async-utility",
"flume",
@@ -4187,7 +4187,7 @@ dependencies = [
[[package]]
name = "nostr-sdk"
version = "0.44.1"
-source = "git+https://github.com/rust-nostr/nostr#30cf8ee4e9c95c8c6bfcaacfbd93aeb9849b7e2d"
+source = "git+https://github.com/rust-nostr/nostr#860e239ff894b8471b37c84dcac12b9572b8f064"
dependencies = [
"async-utility",
"async-wsocket",
@@ -4624,7 +4624,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "perf"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"collections",
"serde",
@@ -4710,18 +4710,18 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
[[package]]
name = "pin-project"
-version = "1.1.10"
+version = "1.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a"
+checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
-version = "1.1.10"
+version = "1.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
+checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6"
dependencies = [
"proc-macro2",
"quote",
@@ -4730,9 +4730,9 @@ dependencies = [
[[package]]
name = "pin-project-lite"
-version = "0.2.16"
+version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "pin-utils"
@@ -5137,9 +5137,9 @@ dependencies = [
[[package]]
name = "range-alloc"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde"
+checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08"
[[package]]
name = "rangemap"
@@ -5264,9 +5264,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
-version = "0.7.2"
+version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d94dd2f7cd932d4dc02cc8b2b50dfd38bd079a4e5d79198b99743d7fcf9a4b4"
+checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16"
dependencies = [
"bitflags 2.11.0",
]
@@ -5305,7 +5305,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"derive_refineable",
]
@@ -5404,7 +5404,7 @@ dependencies = [
[[package]]
name = "reqwest_client"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"bytes",
@@ -5459,7 +5459,7 @@ dependencies = [
[[package]]
name = "rope"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"arrayvec",
"log",
@@ -5721,7 +5721,7 @@ dependencies = [
[[package]]
name = "scheduler"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"async-task",
"backtrace",
@@ -6315,7 +6315,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"arrayvec",
"log",
@@ -7258,7 +7258,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "util"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"async-fs",
@@ -7297,7 +7297,7 @@ dependencies = [
[[package]]
name = "util_macros"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"perf",
"quote",
@@ -7453,9 +7453,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
[[package]]
name = "wasm-bindgen"
-version = "0.2.113"
+version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2"
+checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
dependencies = [
"cfg-if",
"once_cell",
@@ -7466,9 +7466,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.63"
+version = "0.4.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a89f4650b770e4521aa6573724e2aed4704372151bd0de9d16a3bbabb87441a"
+checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8"
dependencies = [
"cfg-if",
"futures-util",
@@ -7480,9 +7480,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.113"
+version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950"
+checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -7490,9 +7490,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.113"
+version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60"
+checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
dependencies = [
"bumpalo",
"proc-macro2",
@@ -7503,9 +7503,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.113"
+version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5"
+checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
dependencies = [
"unicode-ident",
]
@@ -7669,9 +7669,9 @@ dependencies = [
[[package]]
name = "web-sys"
-version = "0.3.90"
+version = "0.3.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "705eceb4ce901230f8625bd1d665128056ccbe4b7408faa625eec1ba80f59a97"
+checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -9100,7 +9100,7 @@ dependencies = [
[[package]]
name = "zlog"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"anyhow",
"chrono",
@@ -9117,7 +9117,7 @@ checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
[[package]]
name = "ztracing"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
dependencies = [
"tracing",
"tracing-subscriber",
@@ -9128,7 +9128,7 @@ dependencies = [
[[package]]
name = "ztracing_macro"
version = "0.1.0"
-source = "git+https://github.com/zed-industries/zed#96abd034a91deab95b68883d09c2ff564edce823"
+source = "git+https://github.com/zed-industries/zed#1123140e40f47ad7b12815c16de0d49e42e36617"
[[package]]
name = "zune-core"
diff --git a/assets/icons/book.svg b/assets/icons/book.svg
new file mode 100644
index 0000000..9f5eee0
--- /dev/null
+++ b/assets/icons/book.svg
@@ -0,0 +1,3 @@
+
diff --git a/crates/chat/src/lib.rs b/crates/chat/src/lib.rs
index 6cce226..d9971c5 100644
--- a/crates/chat/src/lib.rs
+++ b/crates/chat/src/lib.rs
@@ -118,6 +118,7 @@ impl ChatRegistry {
this.reset(cx);
}
RelayState::Configured => {
+ this.get_contact_list(cx);
this.ensure_messaging_relays(cx);
}
_ => {}
@@ -257,6 +258,43 @@ impl ChatRegistry {
}));
}
+ /// Get contact list from relays
+ pub fn get_contact_list(&mut self, cx: &mut Context) {
+ let nostr = NostrRegistry::global(cx);
+ let client = nostr.read(cx).client();
+
+ let signer = nostr.read(cx).signer();
+ let public_key = signer.public_key().unwrap();
+ let write_relays = nostr.read(cx).write_relays(&public_key, cx);
+
+ let task: Task> = cx.background_spawn(async move {
+ let id = SubscriptionId::new("contact-list");
+ let opts = SubscribeAutoCloseOptions::default()
+ .exit_policy(ReqExitPolicy::ExitOnEOSE)
+ .timeout(Some(Duration::from_secs(TIMEOUT)));
+
+ // Get user's write relays
+ let urls = write_relays.await;
+
+ // Construct filter for inbox relays
+ let filter = Filter::new()
+ .kind(Kind::ContactList)
+ .author(public_key)
+ .limit(1);
+
+ // Construct target for subscription
+ let target: HashMap<&RelayUrl, Filter> =
+ urls.iter().map(|relay| (relay, filter.clone())).collect();
+
+ // Subscribe
+ client.subscribe(target).close_on(opts).with_id(id).await?;
+
+ Ok(())
+ });
+
+ self.tasks.push(task);
+ }
+
/// Ensure messaging relays are set up for the current user.
pub fn ensure_messaging_relays(&mut self, cx: &mut Context) {
let task = self.verify_relays(cx);
diff --git a/crates/chat_ui/src/lib.rs b/crates/chat_ui/src/lib.rs
index 5de1a90..e7f078d 100644
--- a/crates/chat_ui/src/lib.rs
+++ b/crates/chat_ui/src/lib.rs
@@ -8,7 +8,7 @@ use chat::{Message, RenderedMessage, Room, RoomEvent, SendReport};
use common::RenderedTimestamp;
use gpui::prelude::FluentBuilder;
use gpui::{
- deferred, div, img, list, px, red, relative, rems, svg, white, AnyElement, App, AppContext,
+ deferred, div, img, list, px, red, relative, svg, white, AnyElement, App, AppContext,
ClipboardItem, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement,
IntoElement, ListAlignment, ListOffset, ListState, MouseButton, ObjectFit, ParentElement,
PathPromptOptions, Render, SharedString, StatefulInteractiveElement, Styled, StyledImage,
@@ -758,7 +758,7 @@ impl ChatPanel {
this.child(
div()
.id(SharedString::from(format!("{ix}-avatar")))
- .child(Avatar::new(author.avatar()).size(rems(2.)))
+ .child(Avatar::new(author.avatar()))
.context_menu(move |this, _window, _cx| {
let view = Box::new(OpenPublicKey(public_key));
let copy = Box::new(CopyPublicKey(public_key));
@@ -940,7 +940,7 @@ impl ChatPanel {
h_flex()
.gap_1()
.font_semibold()
- .child(Avatar::new(avatar).size(rems(1.25)))
+ .child(Avatar::new(avatar).small())
.child(name.clone()),
),
)
@@ -1283,7 +1283,7 @@ impl Panel for ChatPanel {
h_flex()
.gap_1p5()
- .child(Avatar::new(url).size(rems(1.25)))
+ .child(Avatar::new(url).small())
.child(label)
.into_any_element()
})
diff --git a/crates/coop/src/dialogs/screening.rs b/crates/coop/src/dialogs/screening.rs
index cff37c7..208f5ad 100644
--- a/crates/coop/src/dialogs/screening.rs
+++ b/crates/coop/src/dialogs/screening.rs
@@ -5,9 +5,8 @@ use anyhow::{Context as AnyhowContext, Error};
use common::RenderedTimestamp;
use gpui::prelude::FluentBuilder;
use gpui::{
- div, px, relative, rems, uniform_list, App, AppContext, Context, Div, Entity,
- InteractiveElement, IntoElement, ParentElement, Render, SharedString, Styled, Subscription,
- Task, Window,
+ div, px, relative, uniform_list, App, AppContext, Context, Div, Entity, InteractiveElement,
+ IntoElement, ParentElement, Render, SharedString, Styled, Subscription, Task, Window,
};
use nostr_sdk::prelude::*;
use person::{shorten_pubkey, Person, PersonRegistry};
@@ -275,7 +274,7 @@ impl Screening {
.rounded(cx.theme().radius)
.text_sm()
.hover(|this| this.bg(cx.theme().elevated_surface_background))
- .child(Avatar::new(profile.avatar()).size(rems(1.75)))
+ .child(Avatar::new(profile.avatar()).small())
.child(profile.name()),
);
}
@@ -315,7 +314,7 @@ impl Render for Screening {
.items_center()
.justify_center()
.text_center()
- .child(Avatar::new(profile.avatar()).size(rems(4.)))
+ .child(Avatar::new(profile.avatar()).large())
.child(
div()
.font_semibold()
diff --git a/crates/coop/src/panels/contact_list.rs b/crates/coop/src/panels/contact_list.rs
new file mode 100644
index 0000000..addbb82
--- /dev/null
+++ b/crates/coop/src/panels/contact_list.rs
@@ -0,0 +1,369 @@
+use std::collections::HashSet;
+use std::time::Duration;
+
+use anyhow::{Context as AnyhowContext, Error};
+use gpui::prelude::FluentBuilder;
+use gpui::{
+ div, rems, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
+ InteractiveElement, IntoElement, ParentElement, Render, SharedString, Styled, Subscription,
+ Task, TextAlign, Window,
+};
+use nostr_sdk::prelude::*;
+use person::PersonRegistry;
+use smallvec::{smallvec, SmallVec};
+use state::NostrRegistry;
+use theme::ActiveTheme;
+use ui::avatar::Avatar;
+use ui::button::{Button, ButtonVariants};
+use ui::dock_area::panel::{Panel, PanelEvent};
+use ui::input::{InputEvent, InputState, TextInput};
+use ui::{h_flex, v_flex, Disableable, IconName, Sizable, StyledExt, WindowExtension};
+
+pub fn init(window: &mut Window, cx: &mut App) -> Entity {
+ cx.new(|cx| ContactListPanel::new(window, cx))
+}
+
+#[derive(Debug)]
+pub struct ContactListPanel {
+ name: SharedString,
+ focus_handle: FocusHandle,
+
+ /// Npub input
+ input: Entity,
+
+ /// Whether the panel is updating
+ updating: bool,
+
+ /// Error message
+ error: Option,
+
+ /// All contacts
+ contacts: HashSet,
+
+ /// Event subscriptions
+ _subscriptions: SmallVec<[Subscription; 1]>,
+
+ /// Background tasks
+ tasks: Vec>>,
+}
+
+impl ContactListPanel {
+ pub fn new(window: &mut Window, cx: &mut Context) -> Self {
+ let input = cx.new(|cx| InputState::new(window, cx).placeholder("npub1..."));
+ let mut subscriptions = smallvec![];
+
+ subscriptions.push(
+ // Subscribe to user's input events
+ cx.subscribe_in(&input, window, move |this, _input, event, window, cx| {
+ if let InputEvent::PressEnter { .. } = event {
+ this.add(window, cx);
+ }
+ }),
+ );
+
+ // Run at the end of current cycle
+ cx.defer_in(window, |this, window, cx| {
+ this.load(window, cx);
+ });
+
+ Self {
+ name: "Contact List".into(),
+ focus_handle: cx.focus_handle(),
+ input,
+ updating: false,
+ contacts: HashSet::new(),
+ error: None,
+ _subscriptions: subscriptions,
+ tasks: vec![],
+ }
+ }
+
+ fn load(&mut self, window: &mut Window, cx: &mut Context) {
+ let nostr = NostrRegistry::global(cx);
+ let client = nostr.read(cx).client();
+
+ let task: Task, Error>> = cx.background_spawn(async move {
+ let signer = client.signer().context("Signer not found")?;
+ let public_key = signer.get_public_key().await?;
+ let contact_list = client.database().contacts_public_keys(public_key).await?;
+
+ Ok(contact_list)
+ });
+
+ self.tasks.push(cx.spawn_in(window, async move |this, cx| {
+ let public_keys = task.await?;
+
+ // Update state
+ this.update(cx, |this, cx| {
+ this.contacts.extend(public_keys);
+ cx.notify();
+ })?;
+
+ Ok(())
+ }));
+ }
+
+ fn add(&mut self, window: &mut Window, cx: &mut Context) {
+ let value = self.input.read(cx).value().to_string();
+
+ if let Ok(public_key) = PublicKey::parse(&value) {
+ if self.contacts.insert(public_key) {
+ self.input.update(cx, |this, cx| {
+ this.set_value("", window, cx);
+ });
+ cx.notify();
+ }
+ } else {
+ self.set_error("Public Key is invalid", window, cx);
+ }
+ }
+
+ fn remove(&mut self, public_key: &PublicKey, cx: &mut Context) {
+ self.contacts.remove(public_key);
+ cx.notify();
+ }
+
+ fn set_error(&mut self, error: E, window: &mut Window, cx: &mut Context)
+ where
+ E: Into,
+ {
+ self.error = Some(error.into());
+ cx.notify();
+
+ self.tasks.push(cx.spawn_in(window, async move |this, cx| {
+ cx.background_executor().timer(Duration::from_secs(2)).await;
+
+ // Clear the error message after a delay
+ this.update(cx, |this, cx| {
+ this.error = None;
+ cx.notify();
+ })?;
+
+ Ok(())
+ }));
+ }
+
+ fn set_updating(&mut self, updating: bool, cx: &mut Context) {
+ self.updating = updating;
+ cx.notify();
+ }
+
+ pub fn update(&mut self, window: &mut Window, cx: &mut Context) {
+ if self.contacts.is_empty() {
+ self.set_error("You need to add at least 1 contact", window, cx);
+ return;
+ };
+
+ let nostr = NostrRegistry::global(cx);
+ let client = nostr.read(cx).client();
+ let signer = nostr.read(cx).signer();
+
+ let Some(public_key) = signer.public_key() else {
+ window.push_notification("Public Key not found", cx);
+ return;
+ };
+
+ // Get user's write relays
+ let write_relays = nostr.read(cx).write_relays(&public_key, cx);
+
+ // Get contacts
+ let contacts: Vec = self
+ .contacts
+ .iter()
+ .map(|public_key| Contact::new(*public_key))
+ .collect();
+
+ // Set updating state
+ self.set_updating(true, cx);
+
+ let task: Task> = cx.background_spawn(async move {
+ let urls = write_relays.await;
+
+ // Construct contact list event builder
+ let builder = EventBuilder::contact_list(contacts);
+ let event = client.sign_event_builder(builder).await?;
+
+ // Set contact list
+ client.send_event(&event).to(urls).await?;
+
+ Ok(())
+ });
+
+ self.tasks.push(cx.spawn_in(window, async move |this, cx| {
+ match task.await {
+ Ok(_) => {
+ this.update_in(cx, |this, window, cx| {
+ this.set_updating(false, cx);
+ this.load(window, cx);
+
+ window.push_notification("Update successful", cx);
+ })?;
+ }
+ Err(e) => {
+ this.update_in(cx, |this, window, cx| {
+ this.set_updating(false, cx);
+ this.set_error(e.to_string(), window, cx);
+ })?;
+ }
+ };
+
+ Ok(())
+ }));
+ }
+
+ fn render_list_items(&mut self, cx: &mut Context) -> Vec {
+ let persons = PersonRegistry::global(cx);
+ let mut items = Vec::new();
+
+ for (ix, public_key) in self.contacts.iter().enumerate() {
+ let profile = persons.read(cx).get(public_key, cx);
+
+ items.push(
+ h_flex()
+ .id(ix)
+ .group("")
+ .flex_1()
+ .w_full()
+ .h_8()
+ .px_2()
+ .justify_between()
+ .rounded(cx.theme().radius)
+ .bg(cx.theme().secondary_background)
+ .text_color(cx.theme().secondary_foreground)
+ .child(
+ h_flex()
+ .gap_2()
+ .text_sm()
+ .child(Avatar::new(profile.avatar()).small())
+ .child(profile.name()),
+ )
+ .child(
+ Button::new("remove_{ix}")
+ .icon(IconName::Close)
+ .xsmall()
+ .ghost()
+ .invisible()
+ .group_hover("", |this| this.visible())
+ .on_click({
+ let public_key = public_key.to_owned();
+ cx.listener(move |this, _ev, _window, cx| {
+ this.remove(&public_key, cx);
+ })
+ }),
+ ),
+ )
+ }
+
+ items
+ }
+
+ fn render_empty(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement {
+ h_flex()
+ .h_20()
+ .justify_center()
+ .border_2()
+ .border_dashed()
+ .border_color(cx.theme().border)
+ .rounded(cx.theme().radius_lg)
+ .text_sm()
+ .text_align(TextAlign::Center)
+ .child(SharedString::from("Please add some relays."))
+ }
+}
+
+impl Panel for ContactListPanel {
+ fn panel_id(&self) -> SharedString {
+ self.name.clone()
+ }
+
+ fn title(&self, _cx: &App) -> AnyElement {
+ self.name.clone().into_any_element()
+ }
+}
+
+impl EventEmitter for ContactListPanel {}
+
+impl Focusable for ContactListPanel {
+ fn focus_handle(&self, _: &App) -> gpui::FocusHandle {
+ self.focus_handle.clone()
+ }
+}
+
+impl Render for ContactListPanel {
+ fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement {
+ v_flex().p_3().gap_3().w_full().child(
+ v_flex()
+ .gap_2()
+ .flex_1()
+ .w_full()
+ .text_sm()
+ .child(
+ div()
+ .text_xs()
+ .font_semibold()
+ .text_color(cx.theme().text_muted)
+ .child(SharedString::from("New contact:")),
+ )
+ .child(
+ v_flex()
+ .gap_1()
+ .child(
+ h_flex()
+ .gap_1()
+ .w_full()
+ .child(
+ TextInput::new(&self.input)
+ .small()
+ .bordered(false)
+ .cleanable(),
+ )
+ .child(
+ Button::new("add")
+ .icon(IconName::Plus)
+ .tooltip("Add contact")
+ .ghost()
+ .size(rems(2.))
+ .on_click(cx.listener(move |this, _, window, cx| {
+ this.add(window, cx);
+ })),
+ ),
+ )
+ .when_some(self.error.as_ref(), |this, error| {
+ this.child(
+ div()
+ .italic()
+ .text_xs()
+ .text_color(cx.theme().danger_active)
+ .child(error.clone()),
+ )
+ }),
+ )
+ .map(|this| {
+ if self.contacts.is_empty() {
+ this.child(self.render_empty(window, cx))
+ } else {
+ this.child(
+ v_flex()
+ .gap_1()
+ .flex_1()
+ .w_full()
+ .children(self.render_list_items(cx)),
+ )
+ }
+ })
+ .child(
+ Button::new("submit")
+ .icon(IconName::CheckCircle)
+ .label("Update")
+ .primary()
+ .small()
+ .font_semibold()
+ .loading(self.updating)
+ .disabled(self.updating)
+ .on_click(cx.listener(move |this, _ev, window, cx| {
+ this.update(window, cx);
+ })),
+ ),
+ )
+ }
+}
diff --git a/crates/coop/src/panels/encryption_key.rs b/crates/coop/src/panels/encryption_key.rs
index 4584a63..9e0920e 100644
--- a/crates/coop/src/panels/encryption_key.rs
+++ b/crates/coop/src/panels/encryption_key.rs
@@ -269,26 +269,24 @@ impl Render for EncryptionPanel {
)),
)
})
- .when(state.set(), |this| {
- this.child(
- v_flex()
- .gap_1()
- .child(
- Button::new("reset")
- .icon(IconName::Reset)
- .label("Reset")
- .warning()
- .small()
- .font_semibold(),
- )
- .child(
- div()
- .italic()
- .text_size(px(10.))
- .text_color(cx.theme().text_muted)
- .child(SharedString::from(NOTICE)),
- ),
- )
- })
+ .child(
+ v_flex()
+ .gap_1()
+ .child(
+ Button::new("reset")
+ .icon(IconName::Reset)
+ .label("Reset")
+ .warning()
+ .small()
+ .font_semibold(),
+ )
+ .child(
+ div()
+ .italic()
+ .text_size(px(10.))
+ .text_color(cx.theme().text_muted)
+ .child(SharedString::from(NOTICE)),
+ ),
+ )
}
}
diff --git a/crates/coop/src/panels/messaging_relays.rs b/crates/coop/src/panels/messaging_relays.rs
index ad88825..47d46b2 100644
--- a/crates/coop/src/panels/messaging_relays.rs
+++ b/crates/coop/src/panels/messaging_relays.rs
@@ -349,7 +349,7 @@ impl Render for MessagingRelayPanel {
div()
.italic()
.text_xs()
- .text_color(cx.theme().danger_foreground)
+ .text_color(cx.theme().danger_active)
.child(error.clone()),
)
}),
diff --git a/crates/coop/src/panels/mod.rs b/crates/coop/src/panels/mod.rs
index a4c2e6f..a8c04d2 100644
--- a/crates/coop/src/panels/mod.rs
+++ b/crates/coop/src/panels/mod.rs
@@ -1,5 +1,6 @@
pub mod backup;
pub mod connect;
+pub mod contact_list;
pub mod encryption_key;
pub mod greeter;
pub mod import;
diff --git a/crates/coop/src/panels/profile.rs b/crates/coop/src/panels/profile.rs
index 3757b4a..b320eec 100644
--- a/crates/coop/src/panels/profile.rs
+++ b/crates/coop/src/panels/profile.rs
@@ -3,9 +3,9 @@ use std::time::Duration;
use anyhow::{Context as AnyhowContext, Error};
use gpui::{
- div, rems, AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter,
- FocusHandle, Focusable, IntoElement, ParentElement, PathPromptOptions, Render, SharedString,
- Styled, Task, Window,
+ div, AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle,
+ Focusable, IntoElement, ParentElement, PathPromptOptions, Render, SharedString, Styled, Task,
+ Window,
};
use nostr_sdk::prelude::*;
use person::{shorten_pubkey, Person, PersonRegistry};
@@ -322,7 +322,7 @@ impl Render for ProfilePanel {
.items_center()
.justify_center()
.gap_4()
- .child(Avatar::new(avatar).size(rems(4.25)))
+ .child(Avatar::new(avatar).large())
.child(
Button::new("upload")
.icon(IconName::PlusCircle)
diff --git a/crates/coop/src/panels/relay_list.rs b/crates/coop/src/panels/relay_list.rs
index e2709d5..7aa283f 100644
--- a/crates/coop/src/panels/relay_list.rs
+++ b/crates/coop/src/panels/relay_list.rs
@@ -408,7 +408,7 @@ impl Render for RelayListPanel {
div()
.italic()
.text_xs()
- .text_color(cx.theme().danger_foreground)
+ .text_color(cx.theme().danger_active)
.child(error.clone()),
)
}),
diff --git a/crates/coop/src/sidebar/entry.rs b/crates/coop/src/sidebar/entry.rs
index 2a4b73d..d07618b 100644
--- a/crates/coop/src/sidebar/entry.rs
+++ b/crates/coop/src/sidebar/entry.rs
@@ -3,7 +3,7 @@ use std::rc::Rc;
use chat::RoomKind;
use gpui::prelude::FluentBuilder;
use gpui::{
- div, rems, App, ClickEvent, InteractiveElement, IntoElement, ParentElement as _, RenderOnce,
+ div, App, ClickEvent, InteractiveElement, IntoElement, ParentElement as _, RenderOnce,
SharedString, StatefulInteractiveElement, Styled, Window,
};
use nostr_sdk::prelude::*;
@@ -106,14 +106,7 @@ impl RenderOnce for RoomEntry {
.rounded(cx.theme().radius)
.when(!hide_avatar, |this| {
this.when_some(self.avatar, |this, avatar| {
- this.child(
- div()
- .flex_shrink_0()
- .size_6()
- .rounded_full()
- .overflow_hidden()
- .child(Avatar::new(avatar).size(rems(1.5))),
- )
+ this.child(Avatar::new(avatar).small().flex_shrink_0())
})
})
.child(
diff --git a/crates/coop/src/workspace.rs b/crates/coop/src/workspace.rs
index f6d6d5a..1e5e6b6 100644
--- a/crates/coop/src/workspace.rs
+++ b/crates/coop/src/workspace.rs
@@ -4,7 +4,7 @@ use ::settings::AppSettings;
use chat::{ChatEvent, ChatRegistry, InboxState};
use gpui::prelude::FluentBuilder;
use gpui::{
- div, px, rems, Action, App, AppContext, Axis, Context, Entity, InteractiveElement, IntoElement,
+ div, px, Action, App, AppContext, Axis, Context, Entity, InteractiveElement, IntoElement,
ParentElement, Render, SharedString, Styled, Subscription, Window,
};
use person::PersonRegistry;
@@ -22,7 +22,9 @@ use ui::menu::DropdownMenu;
use ui::{h_flex, v_flex, IconName, Root, Sizable, WindowExtension};
use crate::dialogs::settings;
-use crate::panels::{backup, encryption_key, greeter, messaging_relays, profile, relay_list};
+use crate::panels::{
+ backup, contact_list, encryption_key, greeter, messaging_relays, profile, relay_list,
+};
use crate::sidebar;
pub fn init(window: &mut Window, cx: &mut App) -> Entity {
@@ -43,6 +45,7 @@ enum Command {
ShowProfile,
ShowSettings,
ShowBackup,
+ ShowContactList,
}
pub struct Workspace {
@@ -215,6 +218,16 @@ impl Workspace {
});
}
}
+ Command::ShowContactList => {
+ self.dock.update(cx, |this, cx| {
+ this.add_panel(
+ Arc::new(contact_list::init(window, cx)),
+ DockPlacement::Right,
+ window,
+ cx,
+ );
+ });
+ }
Command::ShowBackup => {
self.dock.update(cx, |this, cx| {
this.add_panel(
@@ -372,7 +385,7 @@ impl Workspace {
this.child(
Button::new("current-user")
- .child(Avatar::new(profile.avatar()).size(rems(1.25)))
+ .child(Avatar::new(profile.avatar()).xsmall())
.small()
.caret()
.compact()
@@ -386,6 +399,11 @@ impl Workspace {
IconName::Profile,
Box::new(Command::ShowProfile),
)
+ .menu_with_icon(
+ "Contact List",
+ IconName::Book,
+ Box::new(Command::ShowContactList),
+ )
.menu_with_icon(
"Backup",
IconName::UserKey,
@@ -396,6 +414,7 @@ impl Workspace {
IconName::Sun,
Box::new(Command::ToggleTheme),
)
+ .separator()
.menu_with_icon(
"Settings",
IconName::Settings,
diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs
index 9c2f968..c05fa72 100644
--- a/crates/state/src/lib.rs
+++ b/crates/state/src/lib.rs
@@ -183,20 +183,16 @@ impl NostrRegistry {
..
} = notification
{
- // Skip if the event has already been processed
- if processed_events.insert(event.id) {
- match event.kind {
- Kind::RelayList => {
- if subscription_id.as_str().contains("room-") {
- get_events_for_room(&client, &event).await.ok();
- }
- tx.send_async(event.into_owned()).await?;
- }
- Kind::InboxRelays => {
- tx.send_async(event.into_owned()).await?;
- }
- _ => {}
+ if !processed_events.insert(event.id) {
+ // Skip if the event has already been processed
+ continue;
+ }
+
+ if let Kind::RelayList = event.kind {
+ if subscription_id.as_str().contains("room-") {
+ get_events_for_room(&client, &event).await.ok();
}
+ tx.send_async(event.into_owned()).await?;
}
}
}
diff --git a/crates/ui/src/avatar.rs b/crates/ui/src/avatar.rs
index 03f8da5..2d79545 100644
--- a/crates/ui/src/avatar.rs
+++ b/crates/ui/src/avatar.rs
@@ -1,10 +1,24 @@
use gpui::prelude::FluentBuilder;
use gpui::{
- div, img, px, rems, AbsoluteLength, App, Hsla, ImageSource, Img, IntoElement, ParentElement,
- RenderOnce, Styled, StyledImage, Window,
+ div, img, px, AbsoluteLength, App, Div, Hsla, ImageSource, Img, InteractiveElement,
+ Interactivity, IntoElement, ParentElement, RenderOnce, StyleRefinement, Styled, StyledImage,
+ Window,
};
use theme::ActiveTheme;
+use crate::{Sizable, Size};
+
+/// Returns the size of the avatar based on the given [`Size`].
+pub(super) fn avatar_size(size: Size) -> AbsoluteLength {
+ match size {
+ Size::Large => px(64.).into(),
+ Size::Medium => px(32.).into(),
+ Size::Small => px(24.).into(),
+ Size::XSmall => px(20.).into(),
+ Size::Size(size) => size.into(),
+ }
+}
+
/// An element that renders a user avatar with customizable appearance options.
///
/// # Examples
@@ -18,8 +32,10 @@ use theme::ActiveTheme;
/// ```
#[derive(IntoElement)]
pub struct Avatar {
+ base: Div,
image: Img,
- size: Option,
+ style: StyleRefinement,
+ size: Size,
border_color: Option,
}
@@ -27,8 +43,10 @@ impl Avatar {
/// Creates a new avatar element with the specified image source.
pub fn new(src: impl Into) -> Self {
Avatar {
+ base: div(),
image: img(src),
- size: None,
+ style: StyleRefinement::default(),
+ size: Size::Medium,
border_color: None,
}
}
@@ -56,14 +74,27 @@ impl Avatar {
self.border_color = Some(color.into());
self
}
+}
- /// Size overrides the avatar size. By default they are 1rem.
- pub fn size>(mut self, size: impl Into