Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e7f63d79a | ||
|
|
ee693aa503 | ||
|
|
ebcc60cd92 | ||
|
|
0db48bc003 |
Generated
+75
-87
@@ -190,7 +190,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "assets"
|
name = "assets"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -428,7 +428,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auto_update"
|
name = "auto_update"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo-packager-updater",
|
"cargo-packager-updater",
|
||||||
@@ -482,9 +482,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aws-lc-sys"
|
name = "aws-lc-sys"
|
||||||
version = "0.32.1"
|
version = "0.32.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ba2e2516bdf37af57fc6ff047855f54abad0066e5c4fdaaeb76dabb2e05bcf5"
|
checksum = "a2b715a6010afb9e457ca2b7c9d2b9c344baa8baed7b38dc476034c171b32575"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen 0.72.1",
|
"bindgen 0.72.1",
|
||||||
"cc",
|
"cc",
|
||||||
@@ -661,14 +661,15 @@ checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blade-graphics"
|
name = "blade-graphics"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
source = "git+https://github.com/kvark/blade?rev=bfa594ea697d4b6326ea29f747525c85ecf933b9#bfa594ea697d4b6326ea29f747525c85ecf933b9"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e4deb8f595ce7f00dee3543ebf6fd9a20ea86fc421ab79600dac30876250bdae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"ash-window",
|
"ash-window",
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"codespan-reporting 0.11.1",
|
"codespan-reporting",
|
||||||
"glow",
|
"glow",
|
||||||
"gpu-alloc",
|
"gpu-alloc",
|
||||||
"gpu-alloc-ash",
|
"gpu-alloc-ash",
|
||||||
@@ -686,6 +687,7 @@ dependencies = [
|
|||||||
"objc2-metal",
|
"objc2-metal",
|
||||||
"objc2-quartz-core",
|
"objc2-quartz-core",
|
||||||
"objc2-ui-kit",
|
"objc2-ui-kit",
|
||||||
|
"once_cell",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"slab",
|
"slab",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
@@ -695,7 +697,8 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "blade-macros"
|
name = "blade-macros"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/kvark/blade?rev=bfa594ea697d4b6326ea29f747525c85ecf933b9#bfa594ea697d4b6326ea29f747525c85ecf933b9"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "27142319e2f4c264581067eaccb9f80acccdde60d8b4bf57cc50cd3152f109ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -704,8 +707,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blade-util"
|
name = "blade-util"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/kvark/blade?rev=bfa594ea697d4b6326ea29f747525c85ecf933b9#bfa594ea697d4b6326ea29f747525c85ecf933b9"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3a6be3a82c001ba7a17b6f8e413ede5d1004e6047213f8efaf0ffc15b5c4904c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blade-graphics",
|
"blade-graphics",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
@@ -1027,7 +1031,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client_keys"
|
name = "client_keys"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"global",
|
"global",
|
||||||
@@ -1105,16 +1109,6 @@ dependencies = [
|
|||||||
"objc",
|
"objc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "codespan-reporting"
|
|
||||||
version = "0.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
|
|
||||||
dependencies = [
|
|
||||||
"termcolor",
|
|
||||||
"unicode-width 0.1.14",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@@ -1123,13 +1117,13 @@ checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"unicode-width 0.2.1",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "collections"
|
name = "collections"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
@@ -1159,12 +1153,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f849b92c694fe237ecd8fafd1ba0df7ae0d45c1df6daeb7f68ed4220d51640bd"
|
checksum = "f849b92c694fe237ecd8fafd1ba0df7ae0d45c1df6daeb7f68ed4220d51640bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix 0.30.1",
|
"nix 0.30.1",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -1237,7 +1231,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coop"
|
name = "coop"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assets",
|
"assets",
|
||||||
@@ -1570,7 +1564,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_refineable"
|
name = "derive_refineable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2413,7 +2407,7 @@ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "global"
|
name = "global"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
@@ -2463,9 +2457,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glow"
|
name = "glow"
|
||||||
version = "0.14.2"
|
version = "0.16.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483"
|
checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
@@ -2506,7 +2500,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui"
|
name = "gpui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
@@ -2575,7 +2569,7 @@ dependencies = [
|
|||||||
"strum 0.27.2",
|
"strum 0.27.2",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"taffy",
|
"taffy",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
"usvg",
|
"usvg",
|
||||||
"util",
|
"util",
|
||||||
"util_macros",
|
"util_macros",
|
||||||
@@ -2600,7 +2594,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_macros"
|
name = "gpui_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2612,7 +2606,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_tokio"
|
name = "gpui_tokio"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -2832,7 +2826,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "http_client"
|
name = "http_client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2852,7 +2846,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "http_client_tls"
|
name = "http_client_tls"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-platform-verifier",
|
"rustls-platform-verifier",
|
||||||
@@ -2955,7 +2949,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "i18n"
|
name = "i18n"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rust-i18n",
|
"rust-i18n",
|
||||||
]
|
]
|
||||||
@@ -3657,7 +3651,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "media"
|
name = "media"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bindgen 0.71.1",
|
"bindgen 0.71.1",
|
||||||
@@ -3793,7 +3787,7 @@ dependencies = [
|
|||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
"cfg_aliases",
|
"cfg_aliases",
|
||||||
"codespan-reporting 0.12.0",
|
"codespan-reporting",
|
||||||
"half",
|
"half",
|
||||||
"hashbrown 0.15.5",
|
"hashbrown 0.15.5",
|
||||||
"hexf-parse",
|
"hexf-parse",
|
||||||
@@ -3804,7 +3798,7 @@ dependencies = [
|
|||||||
"rustc-hash 1.1.0",
|
"rustc-hash 1.1.0",
|
||||||
"spirv",
|
"spirv",
|
||||||
"strum 0.26.3",
|
"strum 0.26.3",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3905,7 +3899,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr"
|
name = "nostr"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#75345c65c645d33d15f6a5ec10fa6ffd0d8f4cac"
|
source = "git+https://github.com/rust-nostr/nostr#a5b37e2bc510b609c20e3ea28b1f3892a186241c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"base64",
|
"base64",
|
||||||
@@ -3929,7 +3923,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-connect"
|
name = "nostr-connect"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#75345c65c645d33d15f6a5ec10fa6ffd0d8f4cac"
|
source = "git+https://github.com/rust-nostr/nostr#a5b37e2bc510b609c20e3ea28b1f3892a186241c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"nostr",
|
"nostr",
|
||||||
@@ -3941,7 +3935,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-database"
|
name = "nostr-database"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#75345c65c645d33d15f6a5ec10fa6ffd0d8f4cac"
|
source = "git+https://github.com/rust-nostr/nostr#a5b37e2bc510b609c20e3ea28b1f3892a186241c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"lru",
|
"lru",
|
||||||
@@ -3952,7 +3946,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-lmdb"
|
name = "nostr-lmdb"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#75345c65c645d33d15f6a5ec10fa6ffd0d8f4cac"
|
source = "git+https://github.com/rust-nostr/nostr#a5b37e2bc510b609c20e3ea28b1f3892a186241c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"flume",
|
"flume",
|
||||||
@@ -3966,7 +3960,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-relay-pool"
|
name = "nostr-relay-pool"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#75345c65c645d33d15f6a5ec10fa6ffd0d8f4cac"
|
source = "git+https://github.com/rust-nostr/nostr#a5b37e2bc510b609c20e3ea28b1f3892a186241c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"async-wsocket",
|
"async-wsocket",
|
||||||
@@ -3983,7 +3977,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-sdk"
|
name = "nostr-sdk"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#75345c65c645d33d15f6a5ec10fa6ffd0d8f4cac"
|
source = "git+https://github.com/rust-nostr/nostr#a5b37e2bc510b609c20e3ea28b1f3892a186241c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"nostr",
|
"nostr",
|
||||||
@@ -4500,7 +4494,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "perf"
|
name = "perf"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"collections",
|
"collections",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -4846,7 +4840,7 @@ dependencies = [
|
|||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
"rustls",
|
"rustls",
|
||||||
"socket2",
|
"socket2",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"web-time",
|
"web-time",
|
||||||
@@ -4867,7 +4861,7 @@ dependencies = [
|
|||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"slab",
|
"slab",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
"tracing",
|
"tracing",
|
||||||
"web-time",
|
"web-time",
|
||||||
@@ -4889,9 +4883,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.40"
|
version = "1.0.41"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
@@ -5087,18 +5081,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ref-cast"
|
name = "ref-cast"
|
||||||
version = "1.0.24"
|
version = "1.0.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf"
|
checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ref-cast-impl",
|
"ref-cast-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ref-cast-impl"
|
name = "ref-cast-impl"
|
||||||
version = "1.0.24"
|
version = "1.0.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7"
|
checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5108,7 +5102,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "refineable"
|
name = "refineable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_refineable",
|
"derive_refineable",
|
||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
@@ -5145,7 +5139,7 @@ checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "registry"
|
name = "registry"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -5262,7 +5256,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest_client"
|
name = "reqwest_client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -5317,7 +5311,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rope"
|
name = "rope"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"log",
|
"log",
|
||||||
@@ -5512,7 +5506,7 @@ dependencies = [
|
|||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework 3.5.0",
|
"security-framework 3.5.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5549,7 +5543,7 @@ dependencies = [
|
|||||||
"rustls-native-certs",
|
"rustls-native-certs",
|
||||||
"rustls-platform-verifier-android",
|
"rustls-platform-verifier-android",
|
||||||
"rustls-webpki",
|
"rustls-webpki",
|
||||||
"security-framework 3.5.0",
|
"security-framework 3.5.1",
|
||||||
"security-framework-sys",
|
"security-framework-sys",
|
||||||
"webpki-root-certs 0.26.11",
|
"webpki-root-certs 0.26.11",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
@@ -5782,9 +5776,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework"
|
name = "security-framework"
|
||||||
version = "3.5.0"
|
version = "3.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc198e42d9b7510827939c9a15f5062a0c913f3371d765977e586d2fe6c16f4a"
|
checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
"core-foundation 0.10.1",
|
"core-foundation 0.10.1",
|
||||||
@@ -5812,7 +5806,7 @@ checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "semantic_version"
|
name = "semantic_version"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -5958,7 +5952,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "settings"
|
name = "settings"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"global",
|
"global",
|
||||||
@@ -6025,7 +6019,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signer_proxy"
|
name = "signer_proxy"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"atomic-destructor",
|
"atomic-destructor",
|
||||||
@@ -6264,7 +6258,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "sum_tree"
|
name = "sum_tree"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"log",
|
"log",
|
||||||
@@ -6567,7 +6561,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theme"
|
name = "theme"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -6585,11 +6579,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.16"
|
version = "2.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
|
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl 2.0.16",
|
"thiserror-impl 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -6605,9 +6599,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.16"
|
version = "2.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960"
|
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -6730,7 +6724,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "title_bar"
|
name = "title_bar"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -7084,7 +7078,7 @@ dependencies = [
|
|||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"sha1",
|
"sha1",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -7113,7 +7107,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ui"
|
name = "ui"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -7222,12 +7216,6 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
|
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.1.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@@ -7310,7 +7298,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "util"
|
name = "util"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-fs",
|
"async-fs",
|
||||||
@@ -7345,7 +7333,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "util_macros"
|
name = "util_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#78098f6809346ba8b45db7ffa768fba75578a263"
|
source = "git+https://github.com/zed-industries/zed#1659fb81e7ead8b050a9fe10bcea6e46c5ded6b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"perf",
|
"perf",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -7833,7 +7821,7 @@ checksum = "3a4df73e95feddb9ec1a7e9c2ca6323b8c97d5eeeff78d28f1eccdf19c882b24"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rayon",
|
"rayon",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.17",
|
||||||
"windows 0.61.3",
|
"windows 0.61.3",
|
||||||
"windows-future",
|
"windows-future",
|
||||||
]
|
]
|
||||||
@@ -8661,9 +8649,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zeroize"
|
name = "zeroize"
|
||||||
version = "1.8.1"
|
version = "1.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zeroize_derive",
|
"zeroize_derive",
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||||||
default-members = ["crates/coop"]
|
default-members = ["crates/coop"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
use std::hash::{DefaultHasher, Hash, Hasher};
|
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@@ -7,26 +6,14 @@ use nostr_sdk::prelude::*;
|
|||||||
pub trait EventUtils {
|
pub trait EventUtils {
|
||||||
fn uniq_id(&self) -> u64;
|
fn uniq_id(&self) -> u64;
|
||||||
fn all_pubkeys(&self) -> Vec<PublicKey>;
|
fn all_pubkeys(&self) -> Vec<PublicKey>;
|
||||||
fn compare_pubkeys(&self, other: &[PublicKey]) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventUtils for Event {
|
impl EventUtils for Event {
|
||||||
fn uniq_id(&self) -> u64 {
|
fn uniq_id(&self) -> u64 {
|
||||||
let mut hasher = DefaultHasher::new();
|
let mut hasher = DefaultHasher::new();
|
||||||
let mut pubkeys: Vec<PublicKey> = vec![];
|
let mut pubkeys: Vec<PublicKey> = self.all_pubkeys();
|
||||||
|
pubkeys.sort();
|
||||||
// Add all public keys from event
|
pubkeys.hash(&mut hasher);
|
||||||
pubkeys.push(self.pubkey);
|
|
||||||
pubkeys.extend(self.tags.public_keys().collect::<Vec<_>>());
|
|
||||||
|
|
||||||
// Generate unique hash
|
|
||||||
pubkeys
|
|
||||||
.into_iter()
|
|
||||||
.unique()
|
|
||||||
.sorted()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.hash(&mut hasher);
|
|
||||||
|
|
||||||
hasher.finish()
|
hasher.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,15 +21,7 @@ impl EventUtils for Event {
|
|||||||
let mut public_keys: Vec<PublicKey> = self.tags.public_keys().copied().collect();
|
let mut public_keys: Vec<PublicKey> = self.tags.public_keys().copied().collect();
|
||||||
public_keys.push(self.pubkey);
|
public_keys.push(self.pubkey);
|
||||||
|
|
||||||
public_keys
|
public_keys.into_iter().unique().collect()
|
||||||
}
|
|
||||||
|
|
||||||
fn compare_pubkeys(&self, other: &[PublicKey]) -> bool {
|
|
||||||
let pubkeys = self.all_pubkeys();
|
|
||||||
let a: HashSet<_> = pubkeys.iter().collect();
|
|
||||||
let b: HashSet<_> = other.iter().collect();
|
|
||||||
|
|
||||||
a == b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,12 +51,4 @@ impl EventUtils for UnsignedEvent {
|
|||||||
|
|
||||||
public_keys
|
public_keys
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_pubkeys(&self, other: &[PublicKey]) -> bool {
|
|
||||||
let pubkeys = self.all_pubkeys();
|
|
||||||
let a: HashSet<_> = pubkeys.iter().collect();
|
|
||||||
let b: HashSet<_> = other.iter().collect();
|
|
||||||
|
|
||||||
a == b
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ product-name = "Coop"
|
|||||||
description = "Chat Freely, Stay Private on Nostr"
|
description = "Chat Freely, Stay Private on Nostr"
|
||||||
identifier = "su.reya.coop"
|
identifier = "su.reya.coop"
|
||||||
category = "SocialNetworking"
|
category = "SocialNetworking"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
out-dir = "../../dist"
|
out-dir = "../../dist"
|
||||||
before-packaging-command = "cargo build --release"
|
before-packaging-command = "cargo build --release"
|
||||||
resources = ["Cargo.toml", "src"]
|
resources = ["Cargo.toml", "src"]
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
// Load all chat rooms
|
// Load all chat rooms
|
||||||
registry.update(cx, |this, cx| {
|
registry.update(cx, |this, cx| {
|
||||||
this.set_identity(public_key, cx);
|
this.set_signer_pubkey(public_key, cx);
|
||||||
this.load_rooms(window, cx);
|
this.load_rooms(window, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1481,8 +1481,8 @@ impl Render for ChatSpace {
|
|||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
|
|
||||||
// Only render titlebar child elements if user is logged in
|
// Only render titlebar child elements if user is logged in
|
||||||
if registry.identity.is_some() {
|
if let Some(public_key) = registry.signer_pubkey() {
|
||||||
let profile = registry.identity(cx);
|
let profile = registry.get_person(&public_key, cx);
|
||||||
|
|
||||||
let left_side = self
|
let left_side = self
|
||||||
.render_titlebar_left_side(window, cx)
|
.render_titlebar_left_side(window, cx)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use common::display::{RenderedProfile, RenderedTimestamp};
|
use common::display::{RenderedProfile, RenderedTimestamp};
|
||||||
use common::nip96::nip96_upload;
|
use common::nip96::nip96_upload;
|
||||||
@@ -99,7 +100,7 @@ impl Chat {
|
|||||||
let messages = BTreeSet::from([Message::system()]);
|
let messages = BTreeSet::from([Message::system()]);
|
||||||
let list_state = ListState::new(messages.len(), ListAlignment::Bottom, px(1024.));
|
let list_state = ListState::new(messages.len(), ListAlignment::Bottom, px(1024.));
|
||||||
|
|
||||||
let connect_relays = room.read(cx).connect_relays(cx);
|
let connect = room.read(cx).connect(cx);
|
||||||
let load_messages = room.read(cx).load_messages(cx);
|
let load_messages = room.read(cx).load_messages(cx);
|
||||||
|
|
||||||
let mut subscriptions = smallvec![];
|
let mut subscriptions = smallvec![];
|
||||||
@@ -108,43 +109,41 @@ impl Chat {
|
|||||||
tasks.push(
|
tasks.push(
|
||||||
// Load all messages belonging to this room
|
// Load all messages belonging to this room
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
match connect_relays.await {
|
let result = load_messages.await;
|
||||||
Ok(relays) => {
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, window, cx| {
|
||||||
this.relays.update(cx, |this, cx| {
|
match result {
|
||||||
*this = relays;
|
Ok(events) => {
|
||||||
cx.notify();
|
this.insert_messages(events, cx);
|
||||||
});
|
}
|
||||||
})
|
Err(e) => {
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
cx.update(|window, cx| {
|
|
||||||
window.push_notification(e.to_string(), cx);
|
window.push_notification(e.to_string(), cx);
|
||||||
})
|
}
|
||||||
.ok();
|
};
|
||||||
}
|
})
|
||||||
};
|
.ok();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
tasks.push(
|
tasks.push(
|
||||||
// Load all messages belonging to this room
|
// Get messaging relays for all members
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
match load_messages.await {
|
let result = connect.await;
|
||||||
Ok(events) => {
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.insert_messages(events, cx);
|
match result {
|
||||||
})
|
Ok(relays) => {
|
||||||
.ok();
|
this.relays.update(cx, |this, cx| {
|
||||||
}
|
this.extend(relays);
|
||||||
Err(e) => {
|
cx.notify();
|
||||||
cx.update(|window, cx| {
|
});
|
||||||
window.push_notification(e.to_string(), cx);
|
}
|
||||||
})
|
Err(e) => {
|
||||||
.ok();
|
this.insert_warning(e.to_string(), cx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -192,9 +191,12 @@ impl Chat {
|
|||||||
subscriptions.push(
|
subscriptions.push(
|
||||||
// Observe the messaging relays of the room's members
|
// Observe the messaging relays of the room's members
|
||||||
cx.observe_in(&relays, window, |this, entity, _window, cx| {
|
cx.observe_in(&relays, window, |this, entity, _window, cx| {
|
||||||
for (public_key, urls) in entity.read(cx).clone().into_iter() {
|
let registry = Registry::global(cx);
|
||||||
|
let relays = entity.read(cx).clone();
|
||||||
|
|
||||||
|
for (public_key, urls) in relays.iter() {
|
||||||
if urls.is_empty() {
|
if urls.is_empty() {
|
||||||
let profile = Registry::read_global(cx).get_person(&public_key, cx);
|
let profile = registry.read(cx).get_person(public_key, cx);
|
||||||
let content = t!("chat.nip17_not_found", u = profile.name());
|
let content = t!("chat.nip17_not_found", u = profile.name());
|
||||||
|
|
||||||
this.insert_warning(content, cx);
|
this.insert_warning(content, cx);
|
||||||
@@ -206,7 +208,6 @@ impl Chat {
|
|||||||
subscriptions.push(
|
subscriptions.push(
|
||||||
// Observe when user close chat panel
|
// Observe when user close chat panel
|
||||||
cx.on_release_in(window, move |this, window, cx| {
|
cx.on_release_in(window, move |this, window, cx| {
|
||||||
this.disconnect_relays(cx);
|
|
||||||
this.messages.clear();
|
this.messages.clear();
|
||||||
this.rendered_texts_by_id.clear();
|
this.rendered_texts_by_id.clear();
|
||||||
this.reports_by_id.clear();
|
this.reports_by_id.clear();
|
||||||
@@ -235,20 +236,6 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnect all relays when the user closes the chat panel
|
|
||||||
fn disconnect_relays(&mut self, cx: &mut App) {
|
|
||||||
let relays = self.relays.read(cx).clone();
|
|
||||||
|
|
||||||
cx.background_spawn(async move {
|
|
||||||
let client = nostr_client();
|
|
||||||
|
|
||||||
for relay in relays.values().flatten() {
|
|
||||||
client.disconnect_relay(relay).await.ok();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Load all messages belonging to this room
|
/// Load all messages belonging to this room
|
||||||
fn load_messages(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn load_messages(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let load_messages = self.room.read(cx).load_messages(cx);
|
let load_messages = self.room.read(cx).load_messages(cx);
|
||||||
@@ -273,11 +260,6 @@ impl Chat {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn mention_popup(&mut self, _text: &str, _input: &Entity<InputState>, _cx: &mut Context<Self>) {
|
|
||||||
// TODO: open mention popup at current cursor position
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get user input content and merged all attachments
|
/// Get user input content and merged all attachments
|
||||||
fn input_content(&self, cx: &Context<Self>) -> String {
|
fn input_content(&self, cx: &Context<Self>) -> String {
|
||||||
let mut content = self.input.read(cx).value().trim().to_string();
|
let mut content = self.input.read(cx).value().trim().to_string();
|
||||||
@@ -313,36 +295,48 @@ impl Chat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary disable the message input
|
||||||
|
self.input.update(cx, |this, cx| {
|
||||||
|
this.set_loading(false, cx);
|
||||||
|
this.set_disabled(false, cx);
|
||||||
|
this.set_value("", window, cx);
|
||||||
|
});
|
||||||
|
|
||||||
// Get the backup setting
|
// Get the backup setting
|
||||||
let backup = AppSettings::get_backup_messages(cx);
|
let backup = AppSettings::get_backup_messages(cx);
|
||||||
|
|
||||||
// Get replies_to if it's present
|
// Get replies_to if it's present
|
||||||
let replies = self.replies_to.read(cx).iter().copied().collect_vec();
|
let replies: Vec<EventId> = self.replies_to.read(cx).iter().copied().collect();
|
||||||
|
|
||||||
// Get the current room entity
|
// Get the current room entity
|
||||||
let room = self.room.read(cx);
|
let room = self.room.read(cx);
|
||||||
let identity = Registry::read_global(cx).identity(cx).public_key();
|
|
||||||
|
|
||||||
// Create a temporary message for optimistic update
|
// Create a temporary message for optimistic update
|
||||||
let temp_message = room.create_temp_message(identity, &content, replies.as_ref());
|
let rumor = room.create_message(&content, replies.as_ref(), cx);
|
||||||
let temp_id = temp_message.id.unwrap();
|
let rumor_id = rumor.id.unwrap();
|
||||||
|
|
||||||
// Create a task for sending the message in the background
|
// Create a task for sending the message in the background
|
||||||
let send_message = room.send_in_background(&content, replies, backup, cx);
|
let send_message = room.send_message(rumor.clone(), backup, cx);
|
||||||
|
|
||||||
// Optimistically update message list
|
// Optimistically update message list
|
||||||
self.insert_message(Message::user(temp_message), true, cx);
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
|
cx.background_executor()
|
||||||
|
.timer(Duration::from_millis(100))
|
||||||
|
.await;
|
||||||
|
|
||||||
// Remove all replies
|
this.update_in(cx, |this, window, cx| {
|
||||||
self.remove_all_replies(cx);
|
this.insert_message(Message::user(rumor), true, cx);
|
||||||
|
this.remove_all_replies(cx);
|
||||||
// remove all attachments
|
this.remove_all_attachments(cx);
|
||||||
self.remove_all_attachments(cx);
|
this.input.update(cx, |this, cx| {
|
||||||
|
this.set_loading(false, cx);
|
||||||
// Reset the input state
|
this.set_disabled(false, cx);
|
||||||
self.input.update(cx, |this, cx| {
|
this.set_value("", window, cx);
|
||||||
this.set_value("", window, cx);
|
});
|
||||||
});
|
})
|
||||||
|
.ok();
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
|
||||||
// Continue sending the message in the background
|
// Continue sending the message in the background
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
@@ -363,7 +357,7 @@ impl Chat {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Insert the sent reports
|
// Insert the sent reports
|
||||||
this.reports_by_id.insert(temp_id, reports);
|
this.reports_by_id.insert(rumor_id, reports);
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
@@ -377,37 +371,31 @@ impl Chat {
|
|||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resend a failed message
|
||||||
fn resend_message(&mut self, id: &EventId, window: &mut Window, cx: &mut Context<Self>) {
|
fn resend_message(&mut self, id: &EventId, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
if let Some(reports) = self.reports_by_id.get(id).cloned() {
|
if let Some(reports) = self.reports_by_id.get(id).cloned() {
|
||||||
if let Some(message) = self.message(id) {
|
let id_clone = id.to_owned();
|
||||||
let backup = AppSettings::get_backup_messages(cx);
|
let resend = self.room.read(cx).resend_message(reports, cx);
|
||||||
let id_clone = id.to_owned();
|
|
||||||
let message = message.content.to_owned();
|
|
||||||
let task = self.room.read(cx).resend(reports, message, backup, cx);
|
|
||||||
|
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
match task.await {
|
let result = resend.await;
|
||||||
|
|
||||||
|
this.update_in(cx, |this, window, cx| {
|
||||||
|
match result {
|
||||||
Ok(reports) => {
|
Ok(reports) => {
|
||||||
if !reports.is_empty() {
|
this.reports_by_id.entry(id_clone).and_modify(|this| {
|
||||||
this.update(cx, |this, cx| {
|
*this = reports;
|
||||||
this.reports_by_id.entry(id_clone).and_modify(|this| {
|
});
|
||||||
*this = reports;
|
cx.notify();
|
||||||
});
|
|
||||||
cx.notify();
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
cx.update(|window, cx| {
|
window.push_notification(Notification::error(e.to_string()), cx);
|
||||||
window.push_notification(e.to_string(), cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.detach();
|
.ok();
|
||||||
}
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,7 +600,7 @@ impl Chat {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_announcement(&mut self, ix: usize, cx: &mut Context<Self>) -> AnyElement {
|
fn render_announcement(&self, ix: usize, cx: &Context<Self>) -> AnyElement {
|
||||||
v_flex()
|
v_flex()
|
||||||
.id(ix)
|
.id(ix)
|
||||||
.group("")
|
.group("")
|
||||||
@@ -638,7 +626,7 @@ impl Chat {
|
|||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_warning(&mut self, ix: usize, content: String, cx: &mut Context<Self>) -> AnyElement {
|
fn render_warning(&self, ix: usize, content: SharedString, cx: &Context<Self>) -> AnyElement {
|
||||||
div()
|
div()
|
||||||
.id(ix)
|
.id(ix)
|
||||||
.relative()
|
.relative()
|
||||||
@@ -652,7 +640,7 @@ impl Chat {
|
|||||||
.text_sm()
|
.text_sm()
|
||||||
.text_color(cx.theme().warning_foreground)
|
.text_color(cx.theme().warning_foreground)
|
||||||
.child(Avatar::new("brand/system.png").size(rems(2.)))
|
.child(Avatar::new("brand/system.png").size(rems(2.)))
|
||||||
.child(SharedString::from(content)),
|
.child(content),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
@@ -666,23 +654,6 @@ impl Chat {
|
|||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_message_not_found(&self, ix: usize, cx: &Context<Self>) -> AnyElement {
|
|
||||||
div()
|
|
||||||
.id(ix)
|
|
||||||
.w_full()
|
|
||||||
.py_1()
|
|
||||||
.px_3()
|
|
||||||
.child(
|
|
||||||
h_flex()
|
|
||||||
.gap_1()
|
|
||||||
.text_xs()
|
|
||||||
.text_color(cx.theme().danger_foreground)
|
|
||||||
.child(SharedString::from(ix.to_string()))
|
|
||||||
.child(shared_t!("chat.not_found")),
|
|
||||||
)
|
|
||||||
.into_any_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_message(
|
fn render_message(
|
||||||
&self,
|
&self,
|
||||||
ix: usize,
|
ix: usize,
|
||||||
@@ -1237,8 +1208,7 @@ impl Chat {
|
|||||||
weak_view.read_with(cx, |this, cx| this.new_subject(cx))
|
weak_view.read_with(cx, |this, cx| this.new_subject(cx))
|
||||||
{
|
{
|
||||||
room.update(cx, |this, cx| {
|
room.update(cx, |this, cx| {
|
||||||
this.subject = Some(subject);
|
this.set_subject(subject, cx);
|
||||||
cx.notify();
|
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -1381,13 +1351,13 @@ impl Render for Chat {
|
|||||||
|
|
||||||
this.render_message(ix, rendered, text, cx)
|
this.render_message(ix, rendered, text, cx)
|
||||||
}
|
}
|
||||||
Message::Warning(content, _) => {
|
Message::Warning(content, _timestamp) => {
|
||||||
this.render_warning(ix, content.to_owned(), cx)
|
this.render_warning(ix, SharedString::from(content), cx)
|
||||||
}
|
}
|
||||||
Message::System(_) => this.render_announcement(ix, cx),
|
Message::System(_timestamp) => this.render_announcement(ix, cx),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.render_message_not_found(ix, cx)
|
this.render_warning(ix, shared_t!("chat.not_found"), cx)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ use registry::room::Room;
|
|||||||
use registry::Registry;
|
use registry::Registry;
|
||||||
use settings::AppSettings;
|
use settings::AppSettings;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use smol::Timer;
|
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
use ui::button::{Button, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
@@ -237,7 +236,7 @@ impl Compose {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.set_error(Some(t!("compose.contact_existed").into()), cx);
|
self.set_error(t!("compose.contact_existed"), cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +282,7 @@ impl Compose {
|
|||||||
}
|
}
|
||||||
Ok(Err(e)) => {
|
Ok(Err(e)) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.set_error(Some(e.to_string().into()), cx);
|
this.set_error(e.to_string(), cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -312,47 +311,38 @@ impl Compose {
|
|||||||
|
|
||||||
fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let registry = Registry::global(cx);
|
let registry = Registry::global(cx);
|
||||||
let public_keys: Vec<PublicKey> = self.selected(cx);
|
let receivers: Vec<PublicKey> = self.selected(cx);
|
||||||
|
let subject_input = self.title_input.read(cx).value();
|
||||||
|
let subject = (!subject_input.is_empty()).then(|| subject_input.to_string());
|
||||||
|
|
||||||
if !self.user_input.read(cx).value().is_empty() {
|
if !self.user_input.read(cx).value().is_empty() {
|
||||||
self.add_and_select_contact(window, cx);
|
self.add_and_select_contact(window, cx);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if public_keys.is_empty() {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
self.set_error(Some(t!("compose.receiver_required").into()), cx);
|
let result = Room::new(subject, receivers).await;
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Convert selected pubkeys into Nostr tags
|
this.update_in(cx, |this, window, cx| {
|
||||||
let mut tags: Tags = Tags::from_list(
|
match result {
|
||||||
public_keys
|
Ok(room) => {
|
||||||
.iter()
|
registry.update(cx, |this, cx| {
|
||||||
.map(|pubkey| Tag::public_key(pubkey.to_owned()))
|
this.push_room(cx.new(|_| room), cx);
|
||||||
.collect(),
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// Add subject if it is present
|
window.close_modal(cx);
|
||||||
if !self.title_input.read(cx).value().is_empty() {
|
}
|
||||||
tags.push(Tag::custom(
|
Err(e) => {
|
||||||
TagKind::Subject,
|
this.set_error(e.to_string(), cx);
|
||||||
vec![self.title_input.read(cx).value().to_string()],
|
}
|
||||||
));
|
};
|
||||||
}
|
})
|
||||||
|
.ok();
|
||||||
// Create a new room
|
})
|
||||||
let room = Room::new(public_keys[0], tags, cx);
|
.detach();
|
||||||
|
|
||||||
// Insert the new room into the registry
|
|
||||||
registry.update(cx, |this, cx| {
|
|
||||||
this.push_room(cx.new(|_| room), cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Close the current modal
|
|
||||||
window.close_modal(cx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_error(&mut self, error: impl Into<Option<SharedString>>, cx: &mut Context<Self>) {
|
fn set_error(&mut self, error: impl Into<SharedString>, cx: &mut Context<Self>) {
|
||||||
// Unlock the user input
|
// Unlock the user input
|
||||||
self.user_input.update(cx, |this, cx| {
|
self.user_input.update(cx, |this, cx| {
|
||||||
this.set_loading(false, cx);
|
this.set_loading(false, cx);
|
||||||
@@ -360,15 +350,19 @@ impl Compose {
|
|||||||
|
|
||||||
// Update error message
|
// Update error message
|
||||||
self.error_message.update(cx, |this, cx| {
|
self.error_message.update(cx, |this, cx| {
|
||||||
*this = error.into();
|
*this = Some(error.into());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dismiss error after 2 seconds
|
// Dismiss error after 2 seconds
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
Timer::after(Duration::from_secs(2)).await;
|
cx.background_executor().timer(Duration::from_secs(2)).await;
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.set_error(None, cx);
|
this.error_message.update(cx, |this, cx| {
|
||||||
|
*this = None;
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use common::display::RenderedProfile;
|
use common::display::RenderedProfile;
|
||||||
use gpui::http_client::Url;
|
use gpui::http_client::Url;
|
||||||
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, relative, rems, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
|
div, px, relative, rems, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
|
||||||
ParentElement, Render, SharedString, StatefulInteractiveElement, Styled, Window,
|
ParentElement, Render, SharedString, StatefulInteractiveElement, Styled, Window,
|
||||||
@@ -111,9 +112,6 @@ impl Preferences {
|
|||||||
|
|
||||||
impl Render for Preferences {
|
impl Render for Preferences {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let input_state = self.media_input.downgrade();
|
|
||||||
let profile = Registry::read_global(cx).identity(cx);
|
|
||||||
|
|
||||||
let auto_auth = AppSettings::get_auto_auth(cx);
|
let auto_auth = AppSettings::get_auto_auth(cx);
|
||||||
let backup = AppSettings::get_backup_messages(cx);
|
let backup = AppSettings::get_backup_messages(cx);
|
||||||
let screening = AppSettings::get_screening(cx);
|
let screening = AppSettings::get_screening(cx);
|
||||||
@@ -121,6 +119,9 @@ impl Render for Preferences {
|
|||||||
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
||||||
let hide = AppSettings::get_hide_user_avatars(cx);
|
let hide = AppSettings::get_hide_user_avatars(cx);
|
||||||
|
|
||||||
|
let registry = Registry::read_global(cx);
|
||||||
|
let input_state = self.media_input.downgrade();
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
@@ -133,48 +134,54 @@ impl Render for Preferences {
|
|||||||
.font_semibold()
|
.font_semibold()
|
||||||
.child(shared_t!("preferences.account_header")),
|
.child(shared_t!("preferences.account_header")),
|
||||||
)
|
)
|
||||||
.child(
|
.when_some(registry.signer_pubkey(), |this, public_key| {
|
||||||
h_flex()
|
let profile = registry.get_person(&public_key, cx);
|
||||||
.w_full()
|
|
||||||
.justify_between()
|
this.child(
|
||||||
.child(
|
h_flex()
|
||||||
h_flex()
|
.w_full()
|
||||||
.id("user")
|
.justify_between()
|
||||||
.gap_2()
|
.child(
|
||||||
.child(Avatar::new(profile.avatar(proxy)).size(rems(2.4)))
|
h_flex()
|
||||||
.child(
|
.id("user")
|
||||||
div()
|
.gap_2()
|
||||||
.flex_1()
|
.child(Avatar::new(profile.avatar(proxy)).size(rems(2.4)))
|
||||||
.text_sm()
|
.child(
|
||||||
.child(
|
div()
|
||||||
div()
|
.flex_1()
|
||||||
.font_semibold()
|
.text_sm()
|
||||||
.line_height(relative(1.3))
|
.child(
|
||||||
.child(profile.display_name()),
|
div()
|
||||||
)
|
.font_semibold()
|
||||||
.child(
|
.line_height(relative(1.3))
|
||||||
div()
|
.child(profile.display_name()),
|
||||||
.text_xs()
|
)
|
||||||
.text_color(cx.theme().text_muted)
|
.child(
|
||||||
.line_height(relative(1.3))
|
div()
|
||||||
.child(shared_t!("preferences.account_btn")),
|
.text_xs()
|
||||||
),
|
.text_color(cx.theme().text_muted)
|
||||||
)
|
.line_height(relative(1.3))
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
.child(shared_t!(
|
||||||
this.open_edit_profile(window, cx);
|
"preferences.account_btn"
|
||||||
})),
|
)),
|
||||||
)
|
),
|
||||||
.child(
|
)
|
||||||
Button::new("relays")
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
.label("Messaging Relays")
|
this.open_edit_profile(window, cx);
|
||||||
.xsmall()
|
})),
|
||||||
.ghost_alt()
|
)
|
||||||
.rounded()
|
.child(
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
Button::new("relays")
|
||||||
this.open_relays(window, cx);
|
.label("Messaging Relays")
|
||||||
})),
|
.xsmall()
|
||||||
),
|
.ghost_alt()
|
||||||
),
|
.rounded()
|
||||||
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
|
this.open_relays(window, cx);
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
|
|||||||
@@ -37,33 +37,35 @@ pub struct Screening {
|
|||||||
impl Screening {
|
impl Screening {
|
||||||
pub fn new(public_key: PublicKey, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
pub fn new(public_key: PublicKey, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
let identity = registry.identity(cx).public_key();
|
|
||||||
let profile = registry.get_person(&public_key, cx);
|
let profile = registry.get_person(&public_key, cx);
|
||||||
|
|
||||||
let mut tasks = smallvec![];
|
let mut tasks = smallvec![];
|
||||||
|
|
||||||
let contact_check: Task<(bool, Vec<Profile>)> = cx.background_spawn(async move {
|
let contact_check: Task<Result<(bool, Vec<Profile>), Error>> =
|
||||||
let client = nostr_client();
|
cx.background_spawn(async move {
|
||||||
|
let client = nostr_client();
|
||||||
|
let signer = client.signer().await?;
|
||||||
|
let signer_pubkey = signer.get_public_key().await?;
|
||||||
|
|
||||||
// Check if user is in contact list
|
// Check if user is in contact list
|
||||||
let contacts = client.database().contacts_public_keys(identity).await;
|
let contacts = client.database().contacts_public_keys(signer_pubkey).await;
|
||||||
let followed = contacts.unwrap_or_default().contains(&public_key);
|
let followed = contacts.unwrap_or_default().contains(&public_key);
|
||||||
|
|
||||||
// Check mutual contacts
|
// Check mutual contacts
|
||||||
let contact_list = Filter::new().kind(Kind::ContactList).pubkey(public_key);
|
let contact_list = Filter::new().kind(Kind::ContactList).pubkey(public_key);
|
||||||
let mut mutual_contacts = vec![];
|
let mut mutual_contacts = vec![];
|
||||||
|
|
||||||
if let Ok(events) = client.database().query(contact_list).await {
|
if let Ok(events) = client.database().query(contact_list).await {
|
||||||
for event in events.into_iter().filter(|ev| ev.pubkey != identity) {
|
for event in events.into_iter().filter(|ev| ev.pubkey != signer_pubkey) {
|
||||||
if let Ok(metadata) = client.database().metadata(event.pubkey).await {
|
if let Ok(metadata) = client.database().metadata(event.pubkey).await {
|
||||||
let profile = Profile::new(event.pubkey, metadata.unwrap_or_default());
|
let profile = Profile::new(event.pubkey, metadata.unwrap_or_default());
|
||||||
mutual_contacts.push(profile);
|
mutual_contacts.push(profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
(followed, mutual_contacts)
|
Ok((followed, mutual_contacts))
|
||||||
});
|
});
|
||||||
|
|
||||||
let activity_check = cx.background_spawn(async move {
|
let activity_check = cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
@@ -93,14 +95,14 @@ impl Screening {
|
|||||||
tasks.push(
|
tasks.push(
|
||||||
// Run the contact check in the background
|
// Run the contact check in the background
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
let (followed, mutual_contacts) = contact_check.await;
|
if let Ok((followed, mutual_contacts)) = contact_check.await {
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
this.update(cx, |this, cx| {
|
this.followed = followed;
|
||||||
this.followed = followed;
|
this.mutual_contacts = mutual_contacts;
|
||||||
this.mutual_contacts = mutual_contacts;
|
cx.notify();
|
||||||
cx.notify();
|
})
|
||||||
})
|
.ok();
|
||||||
.ok();
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use i18n::{shared_t, t};
|
use i18n::{shared_t, t};
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use registry::Registry;
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::button::{Button, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
@@ -70,7 +69,6 @@ pub struct SetupRelay {
|
|||||||
|
|
||||||
impl SetupRelay {
|
impl SetupRelay {
|
||||||
pub fn new(kind: Kind, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
pub fn new(kind: Kind, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
let identity = Registry::read_global(cx).identity(cx).public_key();
|
|
||||||
let input = cx.new(|cx| InputState::new(window, cx).placeholder("wss://example.com"));
|
let input = cx.new(|cx| InputState::new(window, cx).placeholder("wss://example.com"));
|
||||||
|
|
||||||
let mut subscriptions = smallvec![];
|
let mut subscriptions = smallvec![];
|
||||||
@@ -78,7 +76,10 @@ impl SetupRelay {
|
|||||||
|
|
||||||
let load_relay = cx.background_spawn(async move {
|
let load_relay = cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let filter = Filter::new().kind(kind).author(identity).limit(1);
|
let signer = client.signer().await?;
|
||||||
|
let public_key = signer.get_public_key().await?;
|
||||||
|
|
||||||
|
let filter = Filter::new().kind(kind).author(public_key).limit(1);
|
||||||
|
|
||||||
if let Some(event) = client.database().query(filter).await?.first() {
|
if let Some(event) = client.database().query(filter).await?.first() {
|
||||||
let relays: Vec<RelayUrl> = event
|
let relays: Vec<RelayUrl> = event
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ impl Sidebar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn request_metadata(client: &Client, public_key: PublicKey) -> Result<(), Error> {
|
async fn request_metadata(public_key: PublicKey) -> Result<(), Error> {
|
||||||
|
let client = nostr_client();
|
||||||
let opts = SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE);
|
let opts = SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE);
|
||||||
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
|
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
|
||||||
let filter = Filter::new().author(public_key).kinds(kinds).limit(10);
|
let filter = Filter::new().author(public_key).kinds(kinds).limit(10);
|
||||||
@@ -152,23 +153,21 @@ impl Sidebar {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_temp_room(identity: PublicKey, public_key: PublicKey) -> Result<Room, Error> {
|
async fn create_temp_room(receiver: PublicKey) -> Result<Room, Error> {
|
||||||
let client = nostr_client();
|
|
||||||
let keys = Keys::generate();
|
|
||||||
let builder = EventBuilder::private_msg_rumor(public_key, "");
|
|
||||||
let event = builder.build(identity).sign(&keys).await?;
|
|
||||||
|
|
||||||
// Request to get user's metadata
|
// Request to get user's metadata
|
||||||
Self::request_metadata(client, public_key).await?;
|
Self::request_metadata(receiver).await?;
|
||||||
|
|
||||||
// Create a temporary room
|
// Create a temporary room
|
||||||
let room = Room::from(&event).current_user(identity);
|
let room = Room::new(None, vec![receiver]).await?;
|
||||||
|
|
||||||
Ok(room)
|
Ok(room)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn nip50(identity: PublicKey, query: &str) -> BTreeSet<Room> {
|
async fn nip50(query: &str) -> Result<BTreeSet<Room>, Error> {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
|
let signer = client.signer().await?;
|
||||||
|
let public_key = signer.get_public_key().await?;
|
||||||
|
|
||||||
let timeout = Duration::from_secs(2);
|
let timeout = Duration::from_secs(2);
|
||||||
let mut rooms: BTreeSet<Room> = BTreeSet::new();
|
let mut rooms: BTreeSet<Room> = BTreeSet::new();
|
||||||
|
|
||||||
@@ -184,18 +183,18 @@ impl Sidebar {
|
|||||||
// Process to verify the search results
|
// Process to verify the search results
|
||||||
for event in events.into_iter().unique_by(|event| event.pubkey) {
|
for event in events.into_iter().unique_by(|event| event.pubkey) {
|
||||||
// Skip if author is match current user
|
// Skip if author is match current user
|
||||||
if event.pubkey == identity {
|
if event.pubkey == public_key {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a temporary room
|
// Return a temporary room
|
||||||
if let Ok(room) = Self::create_temp_room(identity, event.pubkey).await {
|
if let Ok(room) = Self::create_temp_room(event.pubkey).await {
|
||||||
rooms.insert(room);
|
rooms.insert(room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rooms
|
Ok(rooms)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debounced_search(&self, window: &mut Window, cx: &mut Context<Self>) -> Task<()> {
|
fn debounced_search(&self, window: &mut Window, cx: &mut Context<Self>) -> Task<()> {
|
||||||
@@ -214,15 +213,11 @@ impl Sidebar {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let identity = Registry::read_global(cx).identity(cx).public_key();
|
|
||||||
let query = query.to_owned();
|
let query = query.to_owned();
|
||||||
let query_cloned = query.clone();
|
let query_cloned = query.clone();
|
||||||
|
|
||||||
let task = smol::future::or(
|
let task = smol::future::or(
|
||||||
Tokio::spawn(cx, async move {
|
Tokio::spawn(cx, async move { Self::nip50(&query).await.ok() }),
|
||||||
let rooms = Self::nip50(identity, &query).await;
|
|
||||||
Some(rooms)
|
|
||||||
}),
|
|
||||||
Tokio::spawn(cx, async move {
|
Tokio::spawn(cx, async move {
|
||||||
let _ = rx.recv().await.is_ok();
|
let _ = rx.recv().await.is_ok();
|
||||||
None
|
None
|
||||||
@@ -269,12 +264,11 @@ impl Sidebar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn search_by_nip05(&mut self, query: &str, window: &mut Window, cx: &mut Context<Self>) {
|
fn search_by_nip05(&mut self, query: &str, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let identity = Registry::read_global(cx).identity(cx).public_key();
|
|
||||||
let address = query.to_owned();
|
let address = query.to_owned();
|
||||||
|
|
||||||
let task = Tokio::spawn(cx, async move {
|
let task = Tokio::spawn(cx, async move {
|
||||||
if let Ok(profile) = common::nip05::nip05_profile(&address).await {
|
if let Ok(profile) = common::nip05::nip05_profile(&address).await {
|
||||||
Self::create_temp_room(identity, profile.public_key).await
|
Self::create_temp_room(profile.public_key).await
|
||||||
} else {
|
} else {
|
||||||
Err(anyhow!(t!("sidebar.addr_error")))
|
Err(anyhow!(t!("sidebar.addr_error")))
|
||||||
}
|
}
|
||||||
@@ -323,10 +317,9 @@ impl Sidebar {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let identity = Registry::read_global(cx).identity(cx).public_key();
|
|
||||||
let task: Task<Result<Room, Error>> = cx.background_spawn(async move {
|
let task: Task<Result<Room, Error>> = cx.background_spawn(async move {
|
||||||
// Create a gift wrap event to represent as room
|
// Create a gift wrap event to represent as room
|
||||||
Self::create_temp_room(identity, public_key).await
|
Self::create_temp_room(public_key).await
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
|
|||||||
@@ -147,28 +147,40 @@ impl Ingester {
|
|||||||
/// A simple storage to store all states that using across the application.
|
/// A simple storage to store all states that using across the application.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
|
/// The timestamp when the application was initialized.
|
||||||
pub init_at: Timestamp,
|
pub init_at: Timestamp,
|
||||||
|
|
||||||
|
/// The timestamp when the application was last used.
|
||||||
pub last_used_at: Option<Timestamp>,
|
pub last_used_at: Option<Timestamp>,
|
||||||
|
|
||||||
|
/// Whether this is the first run of the application.
|
||||||
pub is_first_run: AtomicBool,
|
pub is_first_run: AtomicBool,
|
||||||
|
|
||||||
|
/// Subscription ID for listening to gift wrap events from relays.
|
||||||
pub gift_wrap_sub_id: SubscriptionId,
|
pub gift_wrap_sub_id: SubscriptionId,
|
||||||
|
|
||||||
pub gift_wrap_processing: AtomicBool,
|
/// Auto-close options for relay subscriptions
|
||||||
|
|
||||||
pub auto_close_opts: Option<SubscribeAutoCloseOptions>,
|
pub auto_close_opts: Option<SubscribeAutoCloseOptions>,
|
||||||
|
|
||||||
|
/// Whether gift wrap processing is in progress.
|
||||||
|
pub gift_wrap_processing: AtomicBool,
|
||||||
|
|
||||||
|
/// Tracking events sent by Coop in the current session
|
||||||
pub sent_ids: RwLock<HashSet<EventId>>,
|
pub sent_ids: RwLock<HashSet<EventId>>,
|
||||||
|
|
||||||
|
/// Tracking events seen on which relays in the current session
|
||||||
pub seen_on_relays: RwLock<HashMap<EventId, HashSet<RelayUrl>>>,
|
pub seen_on_relays: RwLock<HashMap<EventId, HashSet<RelayUrl>>>,
|
||||||
|
|
||||||
|
/// Tracking events that have been resent by Coop in the current session
|
||||||
pub resent_ids: RwLock<Vec<Output<EventId>>>,
|
pub resent_ids: RwLock<Vec<Output<EventId>>>,
|
||||||
|
|
||||||
|
/// Temporarily store events that need to be resent later
|
||||||
pub resend_queue: RwLock<HashMap<EventId, RelayUrl>>,
|
pub resend_queue: RwLock<HashMap<EventId, RelayUrl>>,
|
||||||
|
|
||||||
|
/// Signal channel for communication between Nostr and GPUI
|
||||||
pub signal: Signal,
|
pub signal: Signal,
|
||||||
|
|
||||||
|
/// Ingester channel for processing public keys
|
||||||
pub ingester: Ingester,
|
pub ingester: Ingester,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +235,7 @@ pub fn nostr_client() -> &'static Client {
|
|||||||
.automatic_authentication(false)
|
.automatic_authentication(false)
|
||||||
.verify_subscriptions(false)
|
.verify_subscriptions(false)
|
||||||
.sleep_when_idle(SleepWhenIdle::Enabled {
|
.sleep_when_idle(SleepWhenIdle::Enabled {
|
||||||
timeout: Duration::from_secs(300),
|
timeout: Duration::from_secs(600),
|
||||||
});
|
});
|
||||||
|
|
||||||
ClientBuilder::default().database(lmdb).opts(opts).build()
|
ClientBuilder::default().database(lmdb).opts(opts).build()
|
||||||
|
|||||||
+25
-28
@@ -44,8 +44,8 @@ pub struct Registry {
|
|||||||
/// Status of the unwrapping process
|
/// Status of the unwrapping process
|
||||||
pub unwrapping_status: Entity<UnwrappingStatus>,
|
pub unwrapping_status: Entity<UnwrappingStatus>,
|
||||||
|
|
||||||
/// Public Key of the current user
|
/// Public key of the currently activated signer
|
||||||
pub identity: Option<PublicKey>,
|
signer_pubkey: Option<PublicKey>,
|
||||||
|
|
||||||
/// Tasks for asynchronous operations
|
/// Tasks for asynchronous operations
|
||||||
_tasks: SmallVec<[Task<()>; 1]>,
|
_tasks: SmallVec<[Task<()>; 1]>,
|
||||||
@@ -106,21 +106,19 @@ impl Registry {
|
|||||||
unwrapping_status,
|
unwrapping_status,
|
||||||
rooms: vec![],
|
rooms: vec![],
|
||||||
persons: HashMap::new(),
|
persons: HashMap::new(),
|
||||||
identity: None,
|
signer_pubkey: None,
|
||||||
_tasks: tasks,
|
_tasks: tasks,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the identity of the user.
|
/// Returns the public key of the currently activated signer.
|
||||||
///
|
pub fn signer_pubkey(&self) -> Option<PublicKey> {
|
||||||
/// WARNING: This method will panic if user is not logged in.
|
self.signer_pubkey
|
||||||
pub fn identity(&self, cx: &App) -> Profile {
|
|
||||||
self.get_person(&self.identity.unwrap(), cx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the identity of the user.
|
/// Update the public key of the currently activated signer.
|
||||||
pub fn set_identity(&mut self, identity: PublicKey, cx: &mut Context<Self>) {
|
pub fn set_signer_pubkey(&mut self, public_key: PublicKey, cx: &mut Context<Self>) {
|
||||||
self.identity = Some(identity);
|
self.signer_pubkey = Some(public_key);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +252,7 @@ impl Registry {
|
|||||||
self.set_unwrapping_status(UnwrappingStatus::default(), cx);
|
self.set_unwrapping_status(UnwrappingStatus::default(), cx);
|
||||||
|
|
||||||
// Clear the current identity
|
// Clear the current identity
|
||||||
self.identity = None;
|
self.signer_pubkey = None;
|
||||||
|
|
||||||
// Clear all current rooms
|
// Clear all current rooms
|
||||||
self.rooms.clear();
|
self.rooms.clear();
|
||||||
@@ -276,7 +274,7 @@ impl Registry {
|
|||||||
let contacts = client.database().contacts_public_keys(public_key).await?;
|
let contacts = client.database().contacts_public_keys(public_key).await?;
|
||||||
|
|
||||||
// Get messages sent by the user
|
// Get messages sent by the user
|
||||||
let send = Filter::new()
|
let sent = Filter::new()
|
||||||
.kind(Kind::PrivateDirectMessage)
|
.kind(Kind::PrivateDirectMessage)
|
||||||
.author(public_key);
|
.author(public_key);
|
||||||
|
|
||||||
@@ -285,9 +283,9 @@ impl Registry {
|
|||||||
.kind(Kind::PrivateDirectMessage)
|
.kind(Kind::PrivateDirectMessage)
|
||||||
.pubkey(public_key);
|
.pubkey(public_key);
|
||||||
|
|
||||||
let send_events = client.database().query(send).await?;
|
let sent_events = client.database().query(sent).await?;
|
||||||
let recv_events = client.database().query(recv).await?;
|
let recv_events = client.database().query(recv).await?;
|
||||||
let events = send_events.merge(recv_events);
|
let events = sent_events.merge(recv_events);
|
||||||
|
|
||||||
let mut rooms: HashSet<Room> = HashSet::new();
|
let mut rooms: HashSet<Room> = HashSet::new();
|
||||||
|
|
||||||
@@ -297,12 +295,16 @@ impl Registry {
|
|||||||
.sorted_by_key(|event| Reverse(event.created_at))
|
.sorted_by_key(|event| Reverse(event.created_at))
|
||||||
.filter(|ev| ev.tags.public_keys().peekable().peek().is_some())
|
.filter(|ev| ev.tags.public_keys().peekable().peek().is_some())
|
||||||
{
|
{
|
||||||
if rooms.iter().any(|room| room.id == event.uniq_id()) {
|
// Parse the room from the nostr event
|
||||||
|
let room = Room::from(&event);
|
||||||
|
|
||||||
|
// Skip if the room is already in the set
|
||||||
|
if rooms.iter().any(|r| r.id == room.id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all public keys from the event's tags
|
// Get all public keys from the event's tags
|
||||||
let mut public_keys = event.all_pubkeys();
|
let mut public_keys: Vec<PublicKey> = room.members().to_vec();
|
||||||
public_keys.retain(|pk| pk != &public_key);
|
public_keys.retain(|pk| pk != &public_key);
|
||||||
|
|
||||||
// Bypass screening flag
|
// Bypass screening flag
|
||||||
@@ -323,9 +325,6 @@ impl Registry {
|
|||||||
// If current user has sent a message at least once, mark as ongoing
|
// If current user has sent a message at least once, mark as ongoing
|
||||||
let is_ongoing = client.database().count(filter).await.unwrap_or(1) >= 1;
|
let is_ongoing = client.database().count(filter).await.unwrap_or(1) >= 1;
|
||||||
|
|
||||||
// Create a new room
|
|
||||||
let room = Room::from(&event).current_user(public_key);
|
|
||||||
|
|
||||||
if is_ongoing || bypassed {
|
if is_ongoing || bypassed {
|
||||||
rooms.insert(room.kind(RoomKind::Ongoing));
|
rooms.insert(room.kind(RoomKind::Ongoing));
|
||||||
} else {
|
} else {
|
||||||
@@ -419,7 +418,7 @@ impl Registry {
|
|||||||
/// Updates room ordering based on the most recent messages.
|
/// Updates room ordering based on the most recent messages.
|
||||||
pub fn event_to_message(
|
pub fn event_to_message(
|
||||||
&mut self,
|
&mut self,
|
||||||
gift_wrap_id: EventId,
|
gift_wrap: EventId,
|
||||||
event: Event,
|
event: Event,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
@@ -427,7 +426,7 @@ impl Registry {
|
|||||||
let id = event.uniq_id();
|
let id = event.uniq_id();
|
||||||
let author = event.pubkey;
|
let author = event.pubkey;
|
||||||
|
|
||||||
let Some(identity) = self.identity else {
|
let Some(public_key) = self.signer_pubkey else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -437,17 +436,17 @@ impl Registry {
|
|||||||
// Update room
|
// Update room
|
||||||
room.update(cx, |this, cx| {
|
room.update(cx, |this, cx| {
|
||||||
if is_new_event {
|
if is_new_event {
|
||||||
this.created_at(event.created_at, cx);
|
this.set_created_at(event.created_at, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set this room is ongoing if the new message is from current user
|
// Set this room is ongoing if the new message is from current user
|
||||||
if author == identity {
|
if author == public_key {
|
||||||
this.set_ongoing(cx);
|
this.set_ongoing(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the new message to the room
|
// Emit the new message to the room
|
||||||
cx.defer_in(window, move |this, _window, cx| {
|
cx.defer_in(window, move |this, _window, cx| {
|
||||||
this.emit_message(gift_wrap_id, event, cx);
|
this.emit_message(gift_wrap, event, cx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -458,10 +457,8 @@ impl Registry {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let room = Room::from(&event).current_user(identity);
|
|
||||||
|
|
||||||
// Push the new room to the front of the list
|
// Push the new room to the front of the list
|
||||||
self.add_room(cx.new(|_| room), cx);
|
self.add_room(cx.new(|_| Room::from(&event)), cx);
|
||||||
|
|
||||||
// Notify the UI about the new room
|
// Notify the UI about the new room
|
||||||
cx.defer_in(window, move |_this, _window, cx| {
|
cx.defer_in(window, move |_this, _window, cx| {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ impl Message {
|
|||||||
Self::User(user.into())
|
Self::User(user.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warning(content: String) -> Self {
|
pub fn warning(content: impl Into<String>) -> Self {
|
||||||
Self::Warning(content, Timestamp::now())
|
Self::Warning(content.into(), Timestamp::now())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn system() -> Self {
|
pub fn system() -> Self {
|
||||||
|
|||||||
+252
-230
@@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::{anyhow, Error};
|
||||||
use common::display::RenderedProfile;
|
use common::display::RenderedProfile;
|
||||||
use common::event::EventUtils;
|
use common::event::EventUtils;
|
||||||
use global::constants::SEND_RETRY;
|
use global::constants::SEND_RETRY;
|
||||||
@@ -17,9 +17,9 @@ use crate::Registry;
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SendReport {
|
pub struct SendReport {
|
||||||
pub receiver: PublicKey,
|
pub receiver: PublicKey,
|
||||||
pub tags: Option<Vec<Tag>>,
|
|
||||||
pub status: Option<Output<EventId>>,
|
pub status: Option<Output<EventId>>,
|
||||||
pub error: Option<SharedString>,
|
pub error: Option<SharedString>,
|
||||||
|
pub on_hold: Option<Event>,
|
||||||
pub relays_not_found: bool,
|
pub relays_not_found: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,13 +29,14 @@ impl SendReport {
|
|||||||
receiver,
|
receiver,
|
||||||
status: None,
|
status: None,
|
||||||
error: None,
|
error: None,
|
||||||
tags: None,
|
on_hold: None,
|
||||||
relays_not_found: false,
|
relays_not_found: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn not_found(mut self) -> Self {
|
pub fn status(mut self, output: Output<EventId>) -> Self {
|
||||||
self.relays_not_found = true;
|
self.status = Some(output);
|
||||||
|
self.relays_not_found = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,14 +46,13 @@ impl SendReport {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn status(mut self, output: Output<EventId>) -> Self {
|
pub fn on_hold(mut self, event: Event) -> Self {
|
||||||
self.status = Some(output);
|
self.on_hold = Some(event);
|
||||||
self.relays_not_found = false;
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tags(mut self, tags: &Vec<Tag>) -> Self {
|
pub fn not_found(mut self) -> Self {
|
||||||
self.tags = Some(tags.to_owned());
|
self.relays_not_found = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +88,6 @@ pub struct Room {
|
|||||||
pub created_at: Timestamp,
|
pub created_at: Timestamp,
|
||||||
/// Subject of the room
|
/// Subject of the room
|
||||||
pub subject: Option<String>,
|
pub subject: Option<String>,
|
||||||
/// Picture of the room
|
|
||||||
pub picture: Option<String>,
|
|
||||||
/// All members of the room
|
/// All members of the room
|
||||||
pub members: Vec<PublicKey>,
|
pub members: Vec<PublicKey>,
|
||||||
/// Kind
|
/// Kind
|
||||||
@@ -130,32 +128,18 @@ impl From<&Event> for Room {
|
|||||||
let created_at = val.created_at;
|
let created_at = val.created_at;
|
||||||
|
|
||||||
// Get the members from the event's tags and event's pubkey
|
// Get the members from the event's tags and event's pubkey
|
||||||
let members = val
|
let members = val.all_pubkeys();
|
||||||
.all_pubkeys()
|
|
||||||
.into_iter()
|
|
||||||
.unique()
|
|
||||||
.sorted()
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
// Get the subject from the event's tags
|
// Get subject from tags
|
||||||
let subject = if let Some(tag) = val.tags.find(TagKind::Subject) {
|
let subject = val
|
||||||
tag.content().map(|s| s.to_owned())
|
.tags
|
||||||
} else {
|
.find(TagKind::Subject)
|
||||||
None
|
.and_then(|tag| tag.content().map(|s| s.to_owned()));
|
||||||
};
|
|
||||||
|
|
||||||
// Get the picture from the event's tags
|
|
||||||
let picture = if let Some(tag) = val.tags.find(TagKind::custom("picture")) {
|
|
||||||
tag.content().map(|s| s.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Room {
|
Room {
|
||||||
id,
|
id,
|
||||||
created_at,
|
created_at,
|
||||||
subject,
|
subject,
|
||||||
picture,
|
|
||||||
members,
|
members,
|
||||||
kind: RoomKind::default(),
|
kind: RoomKind::default(),
|
||||||
}
|
}
|
||||||
@@ -168,32 +152,18 @@ impl From<&UnsignedEvent> for Room {
|
|||||||
let created_at = val.created_at;
|
let created_at = val.created_at;
|
||||||
|
|
||||||
// Get the members from the event's tags and event's pubkey
|
// Get the members from the event's tags and event's pubkey
|
||||||
let members = val
|
let members = val.all_pubkeys();
|
||||||
.all_pubkeys()
|
|
||||||
.into_iter()
|
|
||||||
.unique()
|
|
||||||
.sorted()
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
// Get the subject from the event's tags
|
// Get subject from tags
|
||||||
let subject = if let Some(tag) = val.tags.find(TagKind::Subject) {
|
let subject = val
|
||||||
tag.content().map(|s| s.to_owned())
|
.tags
|
||||||
} else {
|
.find(TagKind::Subject)
|
||||||
None
|
.and_then(|tag| tag.content().map(|s| s.to_owned()));
|
||||||
};
|
|
||||||
|
|
||||||
// Get the picture from the event's tags
|
|
||||||
let picture = if let Some(tag) = val.tags.find(TagKind::custom("picture")) {
|
|
||||||
tag.content().map(|s| s.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Room {
|
Room {
|
||||||
id,
|
id,
|
||||||
created_at,
|
created_at,
|
||||||
subject,
|
subject,
|
||||||
picture,
|
|
||||||
members,
|
members,
|
||||||
kind: RoomKind::default(),
|
kind: RoomKind::default(),
|
||||||
}
|
}
|
||||||
@@ -201,32 +171,39 @@ impl From<&UnsignedEvent> for Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Room {
|
impl Room {
|
||||||
/// Constructs a new room instance with a given receiver.
|
/// Constructs a new room instance for a private message with the given receiver and tags.
|
||||||
pub fn new(receiver: PublicKey, tags: Tags, cx: &App) -> Self {
|
pub async fn new(subject: Option<String>, receivers: Vec<PublicKey>) -> Result<Self, Error> {
|
||||||
let identity = Registry::read_global(cx).identity(cx);
|
let client = nostr_client();
|
||||||
|
let signer = client.signer().await?;
|
||||||
|
let public_key = signer.get_public_key().await?;
|
||||||
|
|
||||||
let mut event = EventBuilder::private_msg_rumor(receiver, "")
|
if receivers.is_empty() {
|
||||||
|
return Err(anyhow!("You need to add at least one receiver"));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert receiver's public keys into tags
|
||||||
|
let mut tags: Tags = Tags::from_list(
|
||||||
|
receivers
|
||||||
|
.iter()
|
||||||
|
.map(|pubkey| Tag::public_key(pubkey.to_owned()))
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add subject if it is present
|
||||||
|
if let Some(subject) = subject {
|
||||||
|
tags.push(Tag::from_standardized_without_cell(TagStandard::Subject(
|
||||||
|
subject,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut event = EventBuilder::new(Kind::PrivateDirectMessage, "")
|
||||||
.tags(tags)
|
.tags(tags)
|
||||||
.build(identity.public_key());
|
.build(public_key);
|
||||||
|
|
||||||
// Ensure event ID is generated
|
// Generate event ID
|
||||||
event.ensure_id();
|
event.ensure_id();
|
||||||
|
|
||||||
Room::from(&event).current_user(identity.public_key())
|
Ok(Room::from(&event))
|
||||||
}
|
|
||||||
|
|
||||||
/// Constructs a new room instance from an nostr event.
|
|
||||||
pub fn from(event: impl Into<Room>) -> Self {
|
|
||||||
event.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Call this function to ensure the current user is always at the bottom of the members list
|
|
||||||
pub fn current_user(mut self, public_key: PublicKey) -> Self {
|
|
||||||
let (not_match, matches): (Vec<PublicKey>, Vec<PublicKey>) =
|
|
||||||
self.members.iter().partition(|&key| key != &public_key);
|
|
||||||
self.members = not_match;
|
|
||||||
self.members.extend(matches);
|
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the kind of the room and returns the modified room
|
/// Sets the kind of the room and returns the modified room
|
||||||
@@ -235,7 +212,7 @@ impl Room {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the room kind to ongoing
|
/// Sets this room is ongoing conversation
|
||||||
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
|
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
|
||||||
if self.kind != RoomKind::Ongoing {
|
if self.kind != RoomKind::Ongoing {
|
||||||
self.kind = RoomKind::Ongoing;
|
self.kind = RoomKind::Ongoing;
|
||||||
@@ -243,27 +220,26 @@ impl Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the room is a group chat
|
|
||||||
pub fn is_group(&self) -> bool {
|
|
||||||
self.members.len() > 2
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Updates the creation timestamp of the room
|
/// Updates the creation timestamp of the room
|
||||||
pub fn created_at(&mut self, created_at: impl Into<Timestamp>, cx: &mut Context<Self>) {
|
pub fn set_created_at(&mut self, created_at: impl Into<Timestamp>, cx: &mut Context<Self>) {
|
||||||
self.created_at = created_at.into();
|
self.created_at = created_at.into();
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the subject of the room
|
/// Updates the subject of the room
|
||||||
pub fn subject(&mut self, subject: String, cx: &mut Context<Self>) {
|
pub fn set_subject(&mut self, subject: String, cx: &mut Context<Self>) {
|
||||||
self.subject = Some(subject);
|
self.subject = Some(subject);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the picture of the room
|
/// Returns the members of the room
|
||||||
pub fn picture(&mut self, picture: String, cx: &mut Context<Self>) {
|
pub fn members(&self) -> &Vec<PublicKey> {
|
||||||
self.picture = Some(picture);
|
&self.members
|
||||||
cx.notify();
|
}
|
||||||
|
|
||||||
|
/// Checks if the room has more than two members (group)
|
||||||
|
pub fn is_group(&self) -> bool {
|
||||||
|
self.members.len() > 2
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the display name for the room
|
/// Gets the display name for the room
|
||||||
@@ -277,33 +253,40 @@ impl Room {
|
|||||||
|
|
||||||
/// Gets the display image for the room
|
/// Gets the display image for the room
|
||||||
pub fn display_image(&self, proxy: bool, cx: &App) -> SharedUri {
|
pub fn display_image(&self, proxy: bool, cx: &App) -> SharedUri {
|
||||||
if let Some(picture) = self.picture.as_ref() {
|
if !self.is_group() {
|
||||||
SharedUri::from(picture)
|
self.display_member(cx).avatar(proxy)
|
||||||
} else if !self.is_group() {
|
|
||||||
self.first_member(cx).avatar(proxy)
|
|
||||||
} else {
|
} else {
|
||||||
SharedUri::from("brand/group.png")
|
SharedUri::from("brand/group.png")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the first member of the room.
|
/// Get a single member to represent the room
|
||||||
///
|
///
|
||||||
/// First member is always different from the current user.
|
/// This member is always different from the current user.
|
||||||
pub(crate) fn first_member(&self, cx: &App) -> Profile {
|
fn display_member(&self, cx: &App) -> Profile {
|
||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
|
|
||||||
|
if let Some(public_key) = registry.signer_pubkey() {
|
||||||
|
for member in self.members() {
|
||||||
|
if member != &public_key {
|
||||||
|
return registry.get_person(member, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
registry.get_person(&self.members[0], cx)
|
registry.get_person(&self.members[0], cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merge the names of the first two members of the room.
|
/// Merge the names of the first two members of the room.
|
||||||
pub(crate) fn merged_name(&self, cx: &App) -> SharedString {
|
fn merged_name(&self, cx: &App) -> SharedString {
|
||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
|
|
||||||
if self.is_group() {
|
if self.is_group() {
|
||||||
let profiles = self
|
let profiles: Vec<Profile> = self
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
.map(|pk| registry.get_person(pk, cx))
|
.map(|public_key| registry.get_person(public_key, cx))
|
||||||
.collect::<Vec<_>>();
|
.collect();
|
||||||
|
|
||||||
let mut name = profiles
|
let mut name = profiles
|
||||||
.iter()
|
.iter()
|
||||||
@@ -318,47 +301,75 @@ impl Room {
|
|||||||
|
|
||||||
SharedString::from(name)
|
SharedString::from(name)
|
||||||
} else {
|
} else {
|
||||||
self.first_member(cx).display_name()
|
self.display_member(cx).display_name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connects to all members' messaging relays
|
/// Connects to all members's messaging relays
|
||||||
pub fn connect_relays(
|
pub fn connect(&self, cx: &App) -> Task<Result<HashMap<PublicKey, Vec<RelayUrl>>, Error>> {
|
||||||
&self,
|
|
||||||
cx: &App,
|
|
||||||
) -> Task<Result<HashMap<PublicKey, Vec<RelayUrl>>, Error>> {
|
|
||||||
let members = self.members.clone();
|
let members = self.members.clone();
|
||||||
|
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let timeout = Duration::from_secs(3);
|
let signer = client.signer().await?;
|
||||||
|
let public_key = signer.get_public_key().await?;
|
||||||
|
|
||||||
|
let mut relays = HashMap::new();
|
||||||
let mut processed = HashSet::new();
|
let mut processed = HashSet::new();
|
||||||
let mut relays: HashMap<PublicKey, Vec<RelayUrl>> = HashMap::new();
|
|
||||||
|
|
||||||
if let Some((_, members)) = members.split_last() {
|
for member in members.into_iter() {
|
||||||
for member in members.iter() {
|
if member == public_key {
|
||||||
relays.insert(member.to_owned(), vec![]);
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
let filter = Filter::new()
|
relays.insert(member, vec![]);
|
||||||
.kind(Kind::InboxRelays)
|
|
||||||
.author(member.to_owned())
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if let Ok(mut stream) = client.stream_events(filter, timeout).await {
|
let filter = Filter::new()
|
||||||
if let Some(event) = stream.next().await {
|
.kind(Kind::InboxRelays)
|
||||||
if processed.insert(event.id) {
|
.author(member)
|
||||||
let urls = nip17::extract_owned_relay_list(event).collect_vec();
|
.limit(1);
|
||||||
relays.entry(member.to_owned()).or_default().extend(urls);
|
|
||||||
}
|
let mut stream = client
|
||||||
|
.stream_events(filter, Duration::from_secs(10))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if let Some(event) = stream.next().await {
|
||||||
|
if processed.insert(event.id) {
|
||||||
|
let public_key = event.pubkey;
|
||||||
|
let urls: Vec<RelayUrl> = nip17::extract_owned_relay_list(event).collect();
|
||||||
|
|
||||||
|
// Check if at least one URL exists
|
||||||
|
if urls.is_empty() {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connect to relays
|
||||||
|
for url in urls.iter() {
|
||||||
|
client.add_relay(url).await?;
|
||||||
|
client.connect_relay(url).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
relays.entry(public_key).and_modify(|v| v.extend(urls));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(relays)
|
Ok(relays)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn disconnect(&self, relays: Vec<RelayUrl>, cx: &App) -> Task<Result<(), Error>> {
|
||||||
|
cx.background_spawn(async move {
|
||||||
|
let client = nostr_client();
|
||||||
|
|
||||||
|
for relay in relays.into_iter() {
|
||||||
|
client.disconnect_relay(relay).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Loads all messages for this room from the database
|
/// Loads all messages for this room from the database
|
||||||
pub fn load_messages(&self, cx: &App) -> Task<Result<Vec<Event>, Error>> {
|
pub fn load_messages(&self, cx: &App) -> Task<Result<Vec<Event>, Error>> {
|
||||||
let members = self.members.clone();
|
let members = self.members.clone();
|
||||||
@@ -415,24 +426,43 @@ impl Room {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a temporary message for optimistic updates
|
/// Emits a new message signal to the current room
|
||||||
///
|
pub fn emit_message(&self, gift_wrap_id: EventId, event: Event, cx: &mut Context<Self>) {
|
||||||
/// The event must not been published to relays.
|
cx.emit(RoomSignal::NewMessage((gift_wrap_id, Box::new(event))));
|
||||||
pub fn create_temp_message(
|
}
|
||||||
&self,
|
|
||||||
receiver: PublicKey,
|
/// Emits a signal to refresh the current room's messages.
|
||||||
content: &str,
|
pub fn emit_refresh(&mut self, cx: &mut Context<Self>) {
|
||||||
replies: &[EventId],
|
cx.emit(RoomSignal::Refresh);
|
||||||
) -> UnsignedEvent {
|
}
|
||||||
let builder = EventBuilder::private_msg_rumor(receiver, content);
|
|
||||||
|
/// Create a new message event (unsigned)
|
||||||
|
pub fn create_message(&self, content: &str, replies: &[EventId], cx: &App) -> UnsignedEvent {
|
||||||
|
let public_key = Registry::read_global(cx).signer_pubkey().unwrap();
|
||||||
|
let subject = self.subject.clone();
|
||||||
|
|
||||||
let mut tags = vec![];
|
let mut tags = vec![];
|
||||||
|
|
||||||
// Add event reference if it's present (replying to another event)
|
// Add receivers
|
||||||
|
//
|
||||||
|
// NOTE: current user will be removed from the list of receivers
|
||||||
|
for member in self.members.iter() {
|
||||||
|
tags.push(Tag::public_key(member.to_owned()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add subject tag if it's present
|
||||||
|
if let Some(subject) = subject {
|
||||||
|
tags.push(Tag::from_standardized_without_cell(TagStandard::Subject(
|
||||||
|
subject,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add reply/quote tag
|
||||||
if replies.len() == 1 {
|
if replies.len() == 1 {
|
||||||
tags.push(Tag::event(replies[0]))
|
tags.push(Tag::event(replies[0]))
|
||||||
} else {
|
} else {
|
||||||
for id in replies.iter() {
|
for id in replies {
|
||||||
tags.push(Tag::from_standardized(TagStandard::Quote {
|
tags.push(Tag::from_standardized_without_cell(TagStandard::Quote {
|
||||||
event_id: id.to_owned(),
|
event_id: id.to_owned(),
|
||||||
relay_url: None,
|
relay_url: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
@@ -440,26 +470,27 @@ impl Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut event = builder.tags(tags).build(receiver);
|
// Construct a direct message event
|
||||||
|
//
|
||||||
|
// WARNING: never send this event to relays
|
||||||
|
let mut event = EventBuilder::new(Kind::PrivateDirectMessage, content)
|
||||||
|
.tags(tags)
|
||||||
|
.build(public_key);
|
||||||
|
|
||||||
// Ensure event ID is set
|
// Generate event ID
|
||||||
event.ensure_id();
|
event.ensure_id();
|
||||||
|
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a task to sends a message to all members in the background
|
/// Create a task to send a message to all room members
|
||||||
pub fn send_in_background(
|
pub fn send_message(
|
||||||
&self,
|
&self,
|
||||||
content: &str,
|
rumor: UnsignedEvent,
|
||||||
replies: Vec<EventId>,
|
|
||||||
backup: bool,
|
backup: bool,
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) -> Task<Result<Vec<SendReport>, Error>> {
|
) -> Task<Result<Vec<SendReport>, Error>> {
|
||||||
let content = content.to_owned();
|
let mut members = self.members.clone();
|
||||||
let subject = self.subject.clone();
|
|
||||||
let picture = self.picture.clone();
|
|
||||||
let mut public_keys = self.members.clone();
|
|
||||||
|
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let app_state = app_state();
|
let app_state = app_state();
|
||||||
@@ -467,57 +498,26 @@ impl Room {
|
|||||||
let signer = client.signer().await?;
|
let signer = client.signer().await?;
|
||||||
let public_key = signer.get_public_key().await?;
|
let public_key = signer.get_public_key().await?;
|
||||||
|
|
||||||
let mut tags: Vec<Tag> = public_keys
|
// Remove the current user's public key from the list of receivers
|
||||||
.iter()
|
// Current user will be handled separately
|
||||||
.filter_map(|&this| {
|
members.retain(|&pk| pk != public_key);
|
||||||
if this != public_key {
|
|
||||||
Some(Tag::public_key(this))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Add event reference if it's present (replying to another event)
|
let mut reports: Vec<SendReport> = vec![];
|
||||||
if replies.len() == 1 {
|
|
||||||
tags.push(Tag::event(replies[0]))
|
|
||||||
} else {
|
|
||||||
for id in replies.iter() {
|
|
||||||
tags.push(Tag::from_standardized(TagStandard::Quote {
|
|
||||||
event_id: id.to_owned(),
|
|
||||||
relay_url: None,
|
|
||||||
public_key: None,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add subject tag if it's present
|
for receiver in members.into_iter() {
|
||||||
if let Some(subject) = subject {
|
let rumor = rumor.clone();
|
||||||
tags.push(Tag::from_standardized(TagStandard::Subject(
|
let event = EventBuilder::gift_wrap(&signer, &receiver, rumor, vec![]).await?;
|
||||||
subject.to_string(),
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add picture tag if it's present
|
let Ok(relay_urls) = Self::messaging_relays(receiver).await else {
|
||||||
if let Some(picture) = picture {
|
reports.push(SendReport::new(receiver).not_found());
|
||||||
tags.push(Tag::custom(TagKind::custom("picture"), vec![picture]));
|
continue;
|
||||||
}
|
};
|
||||||
|
|
||||||
// Remove the current public key from the list of receivers
|
match client.send_event_to(relay_urls, &event).await {
|
||||||
public_keys.retain(|&pk| pk != public_key);
|
|
||||||
|
|
||||||
// Stored all send errors
|
|
||||||
let mut reports = vec![];
|
|
||||||
|
|
||||||
for pubkey in public_keys.into_iter() {
|
|
||||||
match client
|
|
||||||
.send_private_msg(pubkey, &content, tags.clone())
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
let id = output.id().to_owned();
|
let id = output.id().to_owned();
|
||||||
let auth_required = output.failed.iter().any(|m| m.1.starts_with("auth-"));
|
let auth_required = output.failed.iter().any(|m| m.1.starts_with("auth-"));
|
||||||
let report = SendReport::new(pubkey).status(output).tags(&tags);
|
let report = SendReport::new(receiver).status(output);
|
||||||
|
|
||||||
if auth_required {
|
if auth_required {
|
||||||
// Wait for authenticated and resent event successfully
|
// Wait for authenticated and resent event successfully
|
||||||
@@ -526,7 +526,7 @@ impl Room {
|
|||||||
|
|
||||||
// Check if event was successfully resent
|
// Check if event was successfully resent
|
||||||
if let Some(output) = ids.iter().find(|e| e.id() == &id).cloned() {
|
if let Some(output) = ids.iter().find(|e| e.id() == &id).cloned() {
|
||||||
let output = SendReport::new(pubkey).status(output).tags(&tags);
|
let output = SendReport::new(receiver).status(output);
|
||||||
reports.push(output);
|
reports.push(output);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -544,33 +544,31 @@ impl Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if let nostr_sdk::client::Error::PrivateMsgRelaysNotFound = e {
|
reports.push(SendReport::new(receiver).error(e.to_string()));
|
||||||
reports.push(SendReport::new(pubkey).not_found().tags(&tags));
|
|
||||||
} else {
|
|
||||||
reports.push(SendReport::new(pubkey).error(e.to_string()).tags(&tags));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Construct a gift wrap to back up to current user's owned messaging relays
|
||||||
|
let rumor = rumor.clone();
|
||||||
|
let event = EventBuilder::gift_wrap(&signer, &public_key, rumor, vec![]).await?;
|
||||||
|
|
||||||
// Only send a backup message to current user if sent successfully to others
|
// Only send a backup message to current user if sent successfully to others
|
||||||
if reports.iter().all(|r| r.is_sent_success()) && backup {
|
if reports.iter().all(|r| r.is_sent_success()) && backup {
|
||||||
match client
|
if let Ok(relay_urls) = Self::messaging_relays(public_key).await {
|
||||||
.send_private_msg(public_key, &content, tags.clone())
|
match client.send_event_to(relay_urls, &event).await {
|
||||||
.await
|
Ok(output) => {
|
||||||
{
|
reports.push(SendReport::new(public_key).status(output));
|
||||||
Ok(output) => {
|
}
|
||||||
reports.push(SendReport::new(public_key).status(output).tags(&tags));
|
Err(e) => {
|
||||||
}
|
reports.push(SendReport::new(public_key).error(e.to_string()));
|
||||||
Err(e) => {
|
|
||||||
if let nostr_sdk::client::Error::PrivateMsgRelaysNotFound = e {
|
|
||||||
reports.push(SendReport::new(public_key).not_found());
|
|
||||||
} else {
|
|
||||||
reports
|
|
||||||
.push(SendReport::new(public_key).error(e.to_string()).tags(&tags));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
reports.push(SendReport::new(public_key).not_found());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
reports.push(SendReport::new(public_key).on_hold(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(reports)
|
Ok(reports)
|
||||||
@@ -578,19 +576,19 @@ impl Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a task to resend a failed message
|
/// Create a task to resend a failed message
|
||||||
pub fn resend(
|
pub fn resend_message(
|
||||||
&self,
|
&self,
|
||||||
reports: Vec<SendReport>,
|
reports: Vec<SendReport>,
|
||||||
message: String,
|
|
||||||
backup: bool,
|
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) -> Task<Result<Vec<SendReport>, Error>> {
|
) -> Task<Result<Vec<SendReport>, Error>> {
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let mut resend_reports = vec![];
|
let mut resend_reports = vec![];
|
||||||
let mut resend_tag = vec![];
|
|
||||||
|
|
||||||
for report in reports.into_iter() {
|
for report in reports.into_iter() {
|
||||||
|
let receiver = report.receiver;
|
||||||
|
|
||||||
|
// Process failed events
|
||||||
if let Some(output) = report.status {
|
if let Some(output) = report.status {
|
||||||
let id = output.id();
|
let id = output.id();
|
||||||
let urls: Vec<&RelayUrl> = output.failed.keys().collect();
|
let urls: Vec<&RelayUrl> = output.failed.keys().collect();
|
||||||
@@ -599,44 +597,68 @@ impl Room {
|
|||||||
for url in urls.into_iter() {
|
for url in urls.into_iter() {
|
||||||
let relay = client.pool().relay(url).await?;
|
let relay = client.pool().relay(url).await?;
|
||||||
let id = relay.send_event(&event).await?;
|
let id = relay.send_event(&event).await?;
|
||||||
|
|
||||||
let resent: Output<EventId> = Output {
|
let resent: Output<EventId> = Output {
|
||||||
val: id,
|
val: id,
|
||||||
success: HashSet::from([url.to_owned()]),
|
success: HashSet::from([url.to_owned()]),
|
||||||
failed: HashMap::new(),
|
failed: HashMap::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
resend_reports.push(SendReport::new(report.receiver).status(resent));
|
resend_reports.push(SendReport::new(receiver).status(resent));
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(tags) = report.tags {
|
|
||||||
resend_tag.extend(tags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Only send a backup message to current user if sent successfully to others
|
// Process the on hold event if it exists
|
||||||
if backup && !resend_reports.is_empty() {
|
if let Some(event) = report.on_hold {
|
||||||
let signer = client.signer().await?;
|
if let Ok(relay_urls) = Self::messaging_relays(receiver).await {
|
||||||
let public_key = signer.get_public_key().await?;
|
match client.send_event_to(relay_urls, &event).await {
|
||||||
let output = client
|
Ok(output) => {
|
||||||
.send_private_msg(public_key, message, resend_tag)
|
resend_reports.push(SendReport::new(receiver).status(output));
|
||||||
.await?;
|
}
|
||||||
|
Err(e) => {
|
||||||
resend_reports.push(SendReport::new(public_key).status(output));
|
resend_reports.push(SendReport::new(receiver).error(e.to_string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resend_reports.push(SendReport::new(receiver).not_found());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(resend_reports)
|
Ok(resend_reports)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emits a new message signal to the current room
|
/// Gets messaging relays for public key
|
||||||
pub fn emit_message(&self, gift_wrap_id: EventId, event: Event, cx: &mut Context<Self>) {
|
async fn messaging_relays(public_key: PublicKey) -> Result<Vec<RelayUrl>, Error> {
|
||||||
cx.emit(RoomSignal::NewMessage((gift_wrap_id, Box::new(event))));
|
let client = nostr_client();
|
||||||
}
|
let mut relay_urls = vec![];
|
||||||
|
|
||||||
/// Emits a signal to refresh the current room's messages.
|
let filter = Filter::new()
|
||||||
pub fn emit_refresh(&mut self, cx: &mut Context<Self>) {
|
.kind(Kind::InboxRelays)
|
||||||
cx.emit(RoomSignal::Refresh);
|
.author(public_key)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if let Some(event) = client.database().query(filter).await?.first_owned() {
|
||||||
|
let urls: Vec<RelayUrl> = nip17::extract_owned_relay_list(event).collect();
|
||||||
|
|
||||||
|
// Check if at least one URL exists
|
||||||
|
if urls.is_empty() {
|
||||||
|
return Err(anyhow!("Not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect to relays
|
||||||
|
for url in urls.iter() {
|
||||||
|
client.add_relay(url).await?;
|
||||||
|
client.connect_relay(url).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
relay_urls.extend(urls.into_iter().take(3).unique());
|
||||||
|
} else {
|
||||||
|
return Err(anyhow!("Not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(relay_urls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,8 +331,6 @@ compose:
|
|||||||
en: "Your recently contacts will appear here."
|
en: "Your recently contacts will appear here."
|
||||||
contact_existed:
|
contact_existed:
|
||||||
en: "Contact already added"
|
en: "Contact already added"
|
||||||
receiver_required:
|
|
||||||
en: "You need to add at least 1 receiver"
|
|
||||||
description:
|
description:
|
||||||
en: "Start a conversation with someone using their npub or NIP-05 (like foo@bar.com)."
|
en: "Start a conversation with someone using their npub or NIP-05 (like foo@bar.com)."
|
||||||
subject_label:
|
subject_label:
|
||||||
|
|||||||
+62
-6
@@ -57,9 +57,65 @@ echo "Updating versions..."
|
|||||||
update_version "$WORKSPACE_CARGO"
|
update_version "$WORKSPACE_CARGO"
|
||||||
update_version "$CRATE_CARGO"
|
update_version "$CRATE_CARGO"
|
||||||
|
|
||||||
|
# Check git status before committing
|
||||||
|
echo "Checking git status..."
|
||||||
|
if git status --porcelain | grep -q .; then
|
||||||
|
echo "Current uncommitted changes:"
|
||||||
|
git status --short
|
||||||
|
|
||||||
|
# Ask user if they want to commit all changes or just version files
|
||||||
|
echo ""
|
||||||
|
echo "Do you want to:"
|
||||||
|
echo "1) Commit all current changes (including the version updates)"
|
||||||
|
echo "2) Commit only the version file changes"
|
||||||
|
echo "3) Abort the release"
|
||||||
|
read -p "Enter choice (1/2/3): " choice
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
echo "Committing all changes..."
|
||||||
|
git add .
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo "Committing only version file changes..."
|
||||||
|
git add "$WORKSPACE_CARGO" "$CRATE_CARGO"
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
echo "Release aborted by user"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid choice. Release aborted."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# Only version files were modified, add them specifically
|
||||||
|
echo "Only version files were modified, adding them for commit..."
|
||||||
|
git add "$WORKSPACE_CARGO" "$CRATE_CARGO"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
|
COMMIT_MSG="chore: release version $NEW_VERSION"
|
||||||
|
|
||||||
|
if git commit -m "$COMMIT_MSG"; then
|
||||||
|
echo "✓ Committed version changes"
|
||||||
|
else
|
||||||
|
echo "Error: Failed to commit version changes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push version changes to origin
|
||||||
|
echo "Pushing version changes to origin..."
|
||||||
|
if git push origin master; then
|
||||||
|
echo "✓ Successfully pushed version changes to origin"
|
||||||
|
else
|
||||||
|
echo "Error: Failed to push version changes to origin"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Create git tag
|
# Create git tag
|
||||||
TAG_NAME="v$NEW_VERSION"
|
TAG_NAME="v$NEW_VERSION"
|
||||||
COMMIT_MSG="Release version $NEW_VERSION"
|
|
||||||
|
|
||||||
if git tag -a "$TAG_NAME" -m "$COMMIT_MSG"; then
|
if git tag -a "$TAG_NAME" -m "$COMMIT_MSG"; then
|
||||||
echo "✓ Created git tag: $TAG_NAME"
|
echo "✓ Created git tag: $TAG_NAME"
|
||||||
@@ -68,12 +124,12 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Push to origin (both commits and tags)
|
# Push tag to origin
|
||||||
echo "Pushing to origin..."
|
echo "Pushing tag to origin..."
|
||||||
if git push origin master && git push origin "$TAG_NAME"; then
|
if git push origin "$TAG_NAME"; then
|
||||||
echo "✓ Successfully pushed to origin"
|
echo "✓ Successfully pushed tag to origin"
|
||||||
echo "✓ Release $NEW_VERSION completed successfully!"
|
echo "✓ Release $NEW_VERSION completed successfully!"
|
||||||
else
|
else
|
||||||
echo "Error: Failed to push to origin"
|
echo "Error: Failed to push tag to origin"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user