chore: update deps

This commit is contained in:
2025-09-19 08:42:08 +07:00
parent 9f369bf57f
commit 1de3045505
11 changed files with 219 additions and 170 deletions

175
Cargo.lock generated
View File

@@ -1131,7 +1131,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"indexmap",
"rustc-hash 2.1.1",
@@ -1572,7 +1572,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"proc-macro2",
"quote",
@@ -1746,7 +1746,7 @@ dependencies = [
"cc",
"memchr",
"rustc_version",
"toml 0.9.5",
"toml 0.9.7",
"vswhom",
"winreg",
]
@@ -2378,7 +2378,7 @@ dependencies = [
"js-sys",
"libc",
"r-efi",
"wasi 0.14.5+wasi-0.2.4",
"wasi 0.14.7+wasi-0.2.4",
"wasm-bindgen",
]
@@ -2499,7 +2499,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"as-raw-xcb-connection",
@@ -2592,7 +2592,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@@ -2604,7 +2604,7 @@ dependencies = [
[[package]]
name = "gpui_tokio"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"gpui",
@@ -2673,6 +2673,12 @@ dependencies = [
"foldhash",
]
[[package]]
name = "hashbrown"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
[[package]]
name = "heck"
version = "0.4.1"
@@ -2818,7 +2824,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"bytes",
@@ -2838,7 +2844,7 @@ dependencies = [
[[package]]
name = "http_client_tls"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"rustls",
"rustls-platform-verifier",
@@ -2915,9 +2921,9 @@ dependencies = [
[[package]]
name = "hyper-util"
version = "0.1.16"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8"
dependencies = [
"base64",
"bytes",
@@ -3141,13 +3147,14 @@ checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
[[package]]
name = "indexmap"
version = "2.11.1"
version = "2.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921"
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
dependencies = [
"equivalent",
"hashbrown 0.15.5",
"hashbrown 0.16.0",
"serde",
"serde_core",
]
[[package]]
@@ -3335,9 +3342,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.78"
version = "0.3.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738"
checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -3629,7 +3636,7 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"bindgen 0.71.1",
@@ -3877,7 +3884,7 @@ dependencies = [
[[package]]
name = "nostr"
version = "0.43.0"
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
source = "git+https://github.com/rust-nostr/nostr#2f14457d6b87eb9aa7ccf2ddfbcfef23670436f0"
dependencies = [
"aes",
"base64",
@@ -3901,7 +3908,7 @@ dependencies = [
[[package]]
name = "nostr-connect"
version = "0.43.0"
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
source = "git+https://github.com/rust-nostr/nostr#2f14457d6b87eb9aa7ccf2ddfbcfef23670436f0"
dependencies = [
"async-utility",
"nostr",
@@ -3913,7 +3920,7 @@ dependencies = [
[[package]]
name = "nostr-database"
version = "0.43.0"
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
source = "git+https://github.com/rust-nostr/nostr#2f14457d6b87eb9aa7ccf2ddfbcfef23670436f0"
dependencies = [
"flatbuffers",
"lru",
@@ -3924,7 +3931,7 @@ dependencies = [
[[package]]
name = "nostr-lmdb"
version = "0.43.0"
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
source = "git+https://github.com/rust-nostr/nostr#2f14457d6b87eb9aa7ccf2ddfbcfef23670436f0"
dependencies = [
"async-utility",
"flume",
@@ -3938,7 +3945,7 @@ dependencies = [
[[package]]
name = "nostr-relay-pool"
version = "0.43.0"
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
source = "git+https://github.com/rust-nostr/nostr#2f14457d6b87eb9aa7ccf2ddfbcfef23670436f0"
dependencies = [
"async-utility",
"async-wsocket",
@@ -3955,7 +3962,7 @@ dependencies = [
[[package]]
name = "nostr-sdk"
version = "0.43.0"
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
source = "git+https://github.com/rust-nostr/nostr#2f14457d6b87eb9aa7ccf2ddfbcfef23670436f0"
dependencies = [
"async-utility",
"nostr",
@@ -4676,11 +4683,11 @@ dependencies = [
[[package]]
name = "proc-macro-crate"
version = "3.3.0"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983"
dependencies = [
"toml_edit",
"toml_edit 0.23.6",
]
[[package]]
@@ -5069,7 +5076,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"derive_refineable",
"workspace-hack",
@@ -5223,7 +5230,7 @@ dependencies = [
[[package]]
name = "reqwest_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"bytes",
@@ -5509,9 +5516,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
[[package]]
name = "rustls-webpki"
version = "0.103.5"
version = "0.103.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a37813727b78798e53c2bec3f5e8fe12a6d6f8389bf9ca7802add4c9905ad8"
checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb"
dependencies = [
"aws-lc-rs",
"ring",
@@ -5758,7 +5765,7 @@ checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
[[package]]
name = "semantic_version"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"serde",
@@ -5773,9 +5780,9 @@ checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
[[package]]
name = "serde"
version = "1.0.223"
version = "1.0.225"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a505d71960adde88e293da5cb5eda57093379f64e61cf77bf0e6a63af07a7bac"
checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d"
dependencies = [
"serde_core",
"serde_derive",
@@ -5783,18 +5790,18 @@ dependencies = [
[[package]]
name = "serde_core"
version = "1.0.223"
version = "1.0.225"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20f57cbd357666aa7b3ac84a90b4ea328f1d4ddb6772b430caa5d9e1309bb9e9"
checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.223"
version = "1.0.225"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d428d07faf17e306e699ec1e91996e5a165ba5d6bce5b5155173e91a8a01a56"
checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516"
dependencies = [
"proc-macro2",
"quote",
@@ -5870,11 +5877,11 @@ dependencies = [
[[package]]
name = "serde_spanned"
version = "1.0.0"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83"
checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee"
dependencies = [
"serde",
"serde_core",
]
[[package]]
@@ -6210,7 +6217,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"arrayvec",
"log",
@@ -6733,9 +6740,9 @@ dependencies = [
[[package]]
name = "tokio-rustls"
version = "0.26.2"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b"
checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd"
dependencies = [
"rustls",
"tokio",
@@ -6791,19 +6798,19 @@ dependencies = [
"serde",
"serde_spanned 0.6.9",
"toml_datetime 0.6.11",
"toml_edit",
"toml_edit 0.22.27",
]
[[package]]
name = "toml"
version = "0.9.5"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8"
checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0"
dependencies = [
"indexmap",
"serde",
"serde_spanned 1.0.0",
"toml_datetime 0.7.0",
"serde_core",
"serde_spanned 1.0.2",
"toml_datetime 0.7.2",
"toml_parser",
"toml_writer",
"winnow",
@@ -6820,11 +6827,11 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.7.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3"
checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1"
dependencies = [
"serde",
"serde_core",
]
[[package]]
@@ -6842,10 +6849,22 @@ dependencies = [
]
[[package]]
name = "toml_parser"
version = "1.0.2"
name = "toml_edit"
version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10"
checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b"
dependencies = [
"indexmap",
"toml_datetime 0.7.2",
"toml_parser",
"winnow",
]
[[package]]
name = "toml_parser"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627"
dependencies = [
"winnow",
]
@@ -6858,9 +6877,9 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "toml_writer"
version = "1.0.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109"
[[package]]
name = "tower"
@@ -7240,7 +7259,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "util"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
source = "git+https://github.com/zed-industries/zed#e5e308ba78c3de679b822e50a07b3432a1624ce1"
dependencies = [
"anyhow",
"async-fs",
@@ -7409,18 +7428,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasi"
version = "0.14.5+wasi-0.2.4"
version = "0.14.7+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4"
checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
dependencies = [
"wasip2",
]
[[package]]
name = "wasip2"
version = "1.0.0+wasi-0.2.4"
version = "1.0.1+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24"
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
dependencies = [
"wit-bindgen",
]
@@ -7433,9 +7452,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
[[package]]
name = "wasm-bindgen"
version = "0.2.101"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b"
checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819"
dependencies = [
"cfg-if",
"once_cell",
@@ -7446,9 +7465,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.101"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb"
checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c"
dependencies = [
"bumpalo",
"log",
@@ -7460,9 +7479,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.51"
version = "0.4.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ca85039a9b469b38336411d6d6ced91f3fc87109a2a27b0c197663f5144dffe"
checksum = "a0b221ff421256839509adbb55998214a70d829d3a28c69b4a6672e9d2a42f67"
dependencies = [
"cfg-if",
"js-sys",
@@ -7473,9 +7492,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.101"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d"
checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -7483,9 +7502,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.101"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa"
checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32"
dependencies = [
"proc-macro2",
"quote",
@@ -7496,9 +7515,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.101"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1"
checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf"
dependencies = [
"unicode-ident",
]
@@ -7603,9 +7622,9 @@ dependencies = [
[[package]]
name = "web-sys"
version = "0.3.78"
version = "0.3.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77e4b637749ff0d92b8fad63aa1f7cff3cbe125fd49c175cd6345e7272638b12"
checksum = "fbe734895e869dc429d78c4b433f8d17d95f8d05317440b4fad5ab2d33e596dc"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -8293,9 +8312,9 @@ dependencies = [
[[package]]
name = "wit-bindgen"
version = "0.45.1"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36"
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
[[package]]
name = "workspace-hack"

View File

@@ -1,7 +1,7 @@
use std::sync::atomic::Ordering;
use global::app_state;
use global::constants::KEYRING_URL;
use global::css;
use gpui::{App, AppContext, Context, Entity, Global, Subscription, Window};
use nostr_sdk::prelude::*;
use smallvec::{smallvec, SmallVec};
@@ -61,7 +61,7 @@ impl ClientKeys {
return;
}
let css = css();
let app_state = app_state();
let read_client_keys = cx.read_credentials(KEYRING_URL);
cx.spawn_in(window, async move |this, cx| {
@@ -76,7 +76,7 @@ impl ClientKeys {
this.set_keys(Some(keys), false, true, cx);
})
.ok();
} else if css.is_first_run.load(Ordering::Acquire) {
} else if app_state.is_first_run.load(Ordering::Acquire) {
// If this is the first run, generate new keys and use them for the client keys
this.update(cx, |this, cx| {
this.new_keys(cx);

View File

@@ -13,7 +13,7 @@ use global::constants::{
ACCOUNT_IDENTIFIER, BOOTSTRAP_RELAYS, DEFAULT_SIDEBAR_WIDTH, METADATA_BATCH_LIMIT,
METADATA_BATCH_TIMEOUT, SEARCH_RELAYS,
};
use global::{css, nostr_client, AuthRequest, Notice, SignalKind, UnwrappingStatus};
use global::{app_state, nostr_client, AuthRequest, Notice, SignalKind, UnwrappingStatus};
use gpui::prelude::FluentBuilder;
use gpui::{
div, px, rems, App, AppContext, AsyncWindowContext, Axis, Context, Entity, InteractiveElement,
@@ -213,7 +213,7 @@ impl ChatSpace {
async fn observe_signer() {
let client = nostr_client();
let css = css();
let app_state = app_state();
let stream_timeout = Duration::from_secs(5);
let loop_duration = Duration::from_secs(1);
@@ -229,7 +229,10 @@ impl ChatSpace {
};
// Notify the app that the signer has been set.
css.signal.send(SignalKind::SignerSet(public_key)).await;
app_state
.signal
.send(SignalKind::SignerSet(public_key))
.await;
// Subscribe to the NIP-65 relays for the public key.
let filter = Filter::new()
@@ -248,12 +251,12 @@ impl ChatSpace {
nip65_found = true;
} else {
// Timeout
css.signal.send(SignalKind::RelaysNotFound).await;
app_state.signal.send(SignalKind::RelaysNotFound).await;
}
}
Err(e) => {
log::error!("Error fetching NIP-65 Relay: {e:?}");
css.signal.send(SignalKind::RelaysNotFound).await;
app_state.signal.send(SignalKind::RelaysNotFound).await;
}
};
@@ -270,12 +273,12 @@ impl ChatSpace {
break;
} else {
// Timeout
css.signal.send(SignalKind::RelaysNotFound).await;
app_state.signal.send(SignalKind::RelaysNotFound).await;
}
}
Err(e) => {
log::error!("Error fetching NIP-17 Relay: {e:?}");
css.signal.send(SignalKind::RelaysNotFound).await;
app_state.signal.send(SignalKind::RelaysNotFound).await;
}
};
}
@@ -286,7 +289,7 @@ impl ChatSpace {
async fn observe_giftwrap() {
let client = nostr_client();
let css = css();
let app_state = app_state();
let loop_duration = Duration::from_secs(20);
let mut is_start_processing = false;
let mut total_loops = 0;
@@ -295,11 +298,11 @@ impl ChatSpace {
if client.has_signer().await {
total_loops += 1;
if css.gift_wrap_processing.load(Ordering::Acquire) {
if app_state.gift_wrap_processing.load(Ordering::Acquire) {
is_start_processing = true;
// Reset gift wrap processing flag
let _ = css.gift_wrap_processing.compare_exchange(
let _ = app_state.gift_wrap_processing.compare_exchange(
true,
false,
Ordering::Release,
@@ -307,13 +310,13 @@ impl ChatSpace {
);
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Processing);
css.signal.send(signal).await;
app_state.signal.send(signal).await;
} else {
// Only run further if we are already processing
// Wait until after 2 loops to prevent exiting early while events are still being processed
if is_start_processing && total_loops >= 2 {
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Complete);
css.signal.send(signal).await;
app_state.signal.send(signal).await;
// Reset the counter
is_start_processing = false;
@@ -327,7 +330,7 @@ impl ChatSpace {
}
async fn process_batching_metadata() {
let css = css();
let app_state = app_state();
let timeout = Duration::from_millis(METADATA_BATCH_TIMEOUT);
let mut processed_pubkeys: HashSet<PublicKey> = HashSet::new();
let mut batch: HashSet<PublicKey> = HashSet::new();
@@ -342,7 +345,7 @@ impl ChatSpace {
loop {
let futs = smol::future::or(
async move {
if let Ok(public_key) = css.ingester.receiver().recv_async().await {
if let Ok(public_key) = app_state.ingester.receiver().recv_async().await {
BatchEvent::PublicKey(public_key)
} else {
BatchEvent::Closed
@@ -379,7 +382,7 @@ impl ChatSpace {
async fn process_nostr_events() -> Result<(), Error> {
let client = nostr_client();
let css = css();
let app_state = app_state();
let mut processed_events: HashSet<EventId> = HashSet::new();
let mut challenges: HashSet<Cow<'_, str>> = HashSet::new();
@@ -393,7 +396,8 @@ impl ChatSpace {
match message {
RelayMessage::Event { event, .. } => {
// Keep track of which relays have seen this event
css.seen_on_relays
app_state
.seen_on_relays
.write()
.await
.entry(event.id)
@@ -423,18 +427,18 @@ impl ChatSpace {
for relay in relays.clone().into_iter() {
if client.add_relay(relay).await.is_err() {
let notice = Notice::RelayFailed(relay.clone());
css.signal.send(SignalKind::Notice(notice)).await;
app_state.signal.send(SignalKind::Notice(notice)).await;
}
if client.connect_relay(relay).await.is_err() {
let notice = Notice::RelayFailed(relay.clone());
css.signal.send(SignalKind::Notice(notice)).await;
app_state.signal.send(SignalKind::Notice(notice)).await;
}
}
// Subscribe to gift wrap events only in the current user's NIP-17 relays
Self::fetch_gift_wrap(relays, event.pubkey).await;
} else {
css.signal.send(SignalKind::RelaysNotFound).await;
app_state.signal.send(SignalKind::RelaysNotFound).await;
}
}
}
@@ -447,7 +451,11 @@ impl ChatSpace {
Filter::new().limit(limit).authors(public_keys).kinds(kinds);
client
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
.subscribe_to(
BOOTSTRAP_RELAYS,
filter,
app_state.auto_close_opts,
)
.await
.ok();
}
@@ -456,7 +464,7 @@ impl ChatSpace {
let metadata = Metadata::from_json(&event.content).unwrap_or_default();
let profile = Profile::new(event.pubkey, metadata);
css.signal.send(SignalKind::NewProfile(profile)).await;
app_state.signal.send(SignalKind::NewProfile(profile)).await;
}
Kind::GiftWrap => {
Self::unwrap_gift_wrap(&event).await;
@@ -465,28 +473,32 @@ impl ChatSpace {
}
}
RelayMessage::EndOfStoredEvents(subscription_id) => {
if *subscription_id == css.gift_wrap_sub_id {
if *subscription_id == app_state.gift_wrap_sub_id {
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Processing);
css.signal.send(signal).await;
app_state.signal.send(signal).await;
}
}
RelayMessage::Auth { challenge } => {
if challenges.insert(challenge.clone()) {
let req = AuthRequest::new(challenge, relay_url);
// Send a signal to the ingester to handle the auth request
css.signal.send(SignalKind::Auth(req)).await;
app_state.signal.send(SignalKind::Auth(req)).await;
}
}
RelayMessage::Ok {
event_id, message, ..
} => {
// Keep track of events sent by Coop
css.sent_ids.write().await.insert(event_id);
app_state.sent_ids.write().await.insert(event_id);
// Keep track of events that need to be resent
match MachineReadablePrefix::parse(&message) {
Some(MachineReadablePrefix::AuthRequired) => {
css.resend_queue.write().await.insert(event_id, relay_url);
app_state
.resend_queue
.write()
.await
.insert(event_id, relay_url);
}
Some(_) => {}
None => {}
@@ -500,10 +512,10 @@ impl ChatSpace {
}
async fn process_nostr_signals(view: WeakEntity<ChatSpace>, cx: &mut AsyncWindowContext) {
let css = css();
let app_state = app_state();
let mut is_open_proxy_modal = false;
while let Ok(signal) = css.signal.receiver().recv_async().await {
while let Ok(signal) = app_state.signal.receiver().recv_async().await {
cx.update(|window, cx| {
let registry = Registry::global(cx);
let settings = AppSettings::global(cx);
@@ -611,10 +623,10 @@ impl ChatSpace {
/// Fetches a single event by kind and public key
pub async fn fetch_single_event(kind: Kind, public_key: PublicKey) {
let client = nostr_client();
let css = css();
let app_state = app_state();
let filter = Filter::new().kind(kind).author(public_key).limit(1);
if let Err(e) = client.subscribe(filter, css.auto_close_opts).await {
if let Err(e) = client.subscribe(filter, app_state.auto_close_opts).await {
log::info!("Failed to subscribe: {e}");
}
}
@@ -622,11 +634,11 @@ impl ChatSpace {
/// Fetches gift wrap events for a given public key and relays
pub async fn fetch_gift_wrap(relays: Vec<&RelayUrl>, public_key: PublicKey) {
let client = nostr_client();
let sub_id = css().gift_wrap_sub_id.clone();
let id = app_state().gift_wrap_sub_id.clone();
let filter = Filter::new().kind(Kind::GiftWrap).pubkey(public_key);
if client
.subscribe_with_id_to(relays.clone(), sub_id, filter, None)
.subscribe_with_id_to(relays.clone(), id, filter, None)
.await
.is_ok()
{
@@ -641,7 +653,7 @@ impl ChatSpace {
}
let client = nostr_client();
let css = css();
let app_state = app_state();
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
let limit = public_keys.len() * kinds.len() + 20;
@@ -650,7 +662,7 @@ impl ChatSpace {
let filter = Filter::new().authors(public_keys).kinds(kinds).limit(limit);
client
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
.subscribe_to(BOOTSTRAP_RELAYS, filter, app_state.auto_close_opts)
.await
.ok();
}
@@ -698,7 +710,7 @@ impl ChatSpace {
/// Unwraps a gift-wrapped event and processes its contents.
async fn unwrap_gift_wrap(target: &Event) {
let client = nostr_client();
let css = css();
let app_state = app_state();
let mut message: Option<Event> = None;
if let Ok(event) = Self::get_unwrapped_event(target.id).await {
@@ -718,21 +730,24 @@ impl ChatSpace {
if let Some(event) = message {
// Send all pubkeys to the metadata batch to sync data
for public_key in event.all_pubkeys() {
css.ingester.send(public_key).await;
app_state.ingester.send(public_key).await;
}
match event.created_at >= css.init_at {
match event.created_at >= app_state.init_at {
// New message: send a signal to notify the UI
true => {
// A small delay to prevent UI flickering
smol::Timer::after(Duration::from_millis(200)).await;
css.signal
app_state
.signal
.send(SignalKind::NewMessage((target.id, event)))
.await;
}
// Old message: Coop is probably processing the user's messages during initial load
false => {
css.gift_wrap_processing.store(true, Ordering::Release);
app_state
.gift_wrap_processing
.store(true, Ordering::Release);
}
}
}
@@ -783,7 +798,7 @@ impl ChatSpace {
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let app_state = app_state();
let signer = client.signer().await?;
// Construct event
@@ -814,7 +829,7 @@ impl ChatSpace {
relay.resubscribe().await?;
// Get all failed events that need to be resent
let mut queue = css.resend_queue.write().await;
let mut queue = app_state.resend_queue.write().await;
let ids: Vec<EventId> = queue
.iter()
@@ -833,8 +848,8 @@ impl ChatSpace {
success: HashSet::from([relay_url]),
};
css.sent_ids.write().await.insert(event_id);
css.resent_ids.write().await.push(output);
app_state.sent_ids.write().await.insert(event_id);
app_state.resent_ids.write().await.push(output);
}
}
}
@@ -1092,7 +1107,7 @@ impl ChatSpace {
) {
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let app_state = app_state();
let filter = Filter::new().kind(Kind::PrivateDirectMessage);
@@ -1111,7 +1126,7 @@ impl ChatSpace {
.authors(pubkeys);
client
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
.subscribe_to(BOOTSTRAP_RELAYS, filter, app_state.auto_close_opts)
.await?;
Ok(())
@@ -1131,7 +1146,7 @@ impl ChatSpace {
fn on_sign_out(&mut self, _e: &Logout, _window: &mut Window, cx: &mut Context<Self>) {
cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let app_state = app_state();
let filter = Filter::new()
.kind(Kind::ApplicationSpecificData)
@@ -1144,7 +1159,7 @@ impl ChatSpace {
client.reset().await;
// Notify the channel about the signer being unset
css.signal.send(SignalKind::SignerUnset).await;
app_state.signal.send(SignalKind::SignerUnset).await;
})
.detach();
}
@@ -1368,7 +1383,7 @@ impl ChatSpace {
this._tasks.push(cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let app_state = app_state();
if proxy.start().await.is_ok() {
webbrowser::open(&url).ok();
@@ -1399,7 +1414,7 @@ impl ChatSpace {
break;
} else {
css.signal.send(SignalKind::ProxyDown).await;
app_state.signal.send(SignalKind::ProxyDown).await;
}
smol::Timer::after(Duration::from_secs(1)).await;
}

View File

@@ -2,7 +2,7 @@ use std::sync::Arc;
use assets::Assets;
use global::constants::{APP_ID, APP_NAME};
use global::{css, nostr_client};
use global::{app_state, nostr_client};
use gpui::{
point, px, size, AppContext, Application, Bounds, KeyBinding, Menu, MenuItem, SharedString,
TitlebarOptions, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowKind,
@@ -27,7 +27,7 @@ fn main() {
let _client = nostr_client();
// Initialize the coop simple storage
let _css = css();
let _app_state = app_state();
// Initialize the Application
let app = Application::new()

View File

@@ -5,7 +5,7 @@ use client_keys::ClientKeys;
use common::display::ReadableProfile;
use common::handle_auth::CoopAuthUrlHandler;
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
use global::{css, nostr_client, SignalKind};
use global::{app_state, nostr_client, SignalKind};
use gpui::prelude::FluentBuilder;
use gpui::{
div, relative, rems, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter,
@@ -245,7 +245,7 @@ impl Account {
// Reset the nostr client in the background
cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let app_state = app_state();
let filter = Filter::new()
.kind(Kind::ApplicationSpecificData)
@@ -258,7 +258,7 @@ impl Account {
client.unset_signer().await;
// Notify the channel about the signer being unset
css.signal.send(SignalKind::SignerUnset).await;
app_state.signal.send(SignalKind::SignerUnset).await;
}),
);
}
@@ -339,8 +339,7 @@ impl Render for Account {
.id("account")
.h_10()
.w_72()
.bg(cx.theme().element_background)
.text_color(cx.theme().element_foreground)
.bg(cx.theme().elevated_surface_background)
.rounded_lg()
.text_sm()
.when(self.loading, |this| {
@@ -368,19 +367,40 @@ impl Render for Account {
.child(Avatar::new(avatar).size(rems(1.5)))
.child(div().pb_px().font_semibold().child(name)),
)
.child(SharedString::from("-"))
.child(
div()
.text_xs()
.when(self.is_bunker, |this| {
this.child(SharedString::from("Nostr Connect"))
this.child(
div()
.py_0p5()
.px_2()
.text_xs()
.bg(cx.theme().secondary_active)
.text_color(
cx.theme().secondary_foreground,
)
.rounded_full()
.child("Nostr Connect"),
)
})
.when(self.is_extension, |this| {
this.child(SharedString::from("Extension"))
this.child(
div()
.py_0p5()
.px_2()
.text_xs()
.bg(cx.theme().secondary_active)
.text_color(
cx.theme().secondary_foreground,
)
.rounded_full()
.child("Extension"),
)
}),
),
)
})
.active(|this| this.bg(cx.theme().element_active))
.hover(|this| this.bg(cx.theme().element_hover))
.on_click(cx.listener(move |this, _e, window, cx| {
this.login(window, cx);

View File

@@ -3,7 +3,7 @@ use std::collections::HashMap;
use anyhow::anyhow;
use common::display::{ReadableProfile, ReadableTimestamp};
use common::nip96::nip96_upload;
use global::{css, nostr_client};
use global::{app_state, nostr_client};
use gpui::prelude::FluentBuilder;
use gpui::{
div, img, list, px, red, relative, rems, svg, white, Action, AnyElement, App, AppContext,
@@ -298,7 +298,7 @@ impl Chat {
/// Check if the event is sent by Coop
fn is_sent_by_coop(&self, gift_wrap_id: &EventId) -> bool {
css().sent_ids.read_blocking().contains(gift_wrap_id)
app_state().sent_ids.read_blocking().contains(gift_wrap_id)
}
/// Send a message to all members of the chat
@@ -1263,7 +1263,7 @@ impl Chat {
let task: Task<Result<Vec<RelayUrl>, Error>> = cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let app_state = app_state();
let mut relays: Vec<RelayUrl> = vec![];
let filter = Filter::new()
@@ -1273,7 +1273,7 @@ impl Chat {
if let Some(event) = client.database().query(filter).await?.first_owned() {
if let Some(Ok(id)) = event.tags.identifier().map(EventId::parse) {
if let Some(urls) = css.seen_on_relays.read().await.get(&id).cloned() {
if let Some(urls) = app_state.seen_on_relays.read().await.get(&id).cloned() {
relays.extend(urls);
}
}

View File

@@ -5,7 +5,7 @@ use anyhow::{anyhow, Error};
use common::display::{ReadableProfile, TextUtils};
use common::nip05::nip05_profile;
use global::constants::BOOTSTRAP_RELAYS;
use global::{css, nostr_client};
use global::{app_state, nostr_client};
use gpui::prelude::FluentBuilder;
use gpui::{
div, px, relative, rems, uniform_list, App, AppContext, Context, Entity, InteractiveElement,
@@ -186,12 +186,12 @@ impl Compose {
async fn request_metadata(public_key: PublicKey) -> Result<(), Error> {
let client = nostr_client();
let css = css();
let app_state = app_state();
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
let filter = Filter::new().author(public_key).kinds(kinds).limit(10);
client
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
.subscribe_to(BOOTSTRAP_RELAYS, filter, app_state.auto_close_opts)
.await?;
Ok(())

View File

@@ -2,7 +2,7 @@ use std::time::Duration;
use anyhow::{anyhow, Error};
use global::constants::NIP17_RELAYS;
use global::{css, nostr_client};
use global::{app_state, nostr_client};
use gpui::prelude::FluentBuilder;
use gpui::{
div, px, uniform_list, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
@@ -218,7 +218,7 @@ impl SetupRelay {
}
// Fetch gift wrap events
let sub_id = css().gift_wrap_sub_id.clone();
let sub_id = app_state().gift_wrap_sub_id.clone();
let filter = Filter::new().kind(Kind::GiftWrap).pubkey(public_key);
if client

View File

@@ -6,7 +6,7 @@ use anyhow::{anyhow, Error};
use common::debounced_delay::DebouncedDelay;
use common::display::{ReadableTimestamp, TextUtils};
use global::constants::{BOOTSTRAP_RELAYS, SEARCH_RELAYS};
use global::{css, nostr_client, UnwrappingStatus};
use global::{app_state, nostr_client, UnwrappingStatus};
use gpui::prelude::FluentBuilder;
use gpui::{
div, relative, uniform_list, AnyElement, App, AppContext, Context, Entity, EventEmitter,
@@ -530,8 +530,8 @@ impl Sidebar {
fn on_manage(&mut self, _ev: &RelayStatus, window: &mut Window, cx: &mut Context<Self>) {
let task: Task<Result<Vec<Relay>, Error>> = cx.background_spawn(async move {
let client = nostr_client();
let css = css();
let subscription = client.subscription(&css.gift_wrap_sub_id).await;
let app_state = app_state();
let subscription = client.subscription(&app_state.gift_wrap_sub_id).await;
let mut relays: Vec<Relay> = vec![];
for (url, _filter) in subscription.into_iter() {

View File

@@ -146,7 +146,7 @@ impl Ingester {
/// A simple storage to store all states that using across the application.
#[derive(Debug)]
pub struct CoopSimpleStorage {
pub struct AppState {
pub init_at: Timestamp,
pub last_used_at: Option<Timestamp>,
@@ -172,13 +172,13 @@ pub struct CoopSimpleStorage {
pub ingester: Ingester,
}
impl Default for CoopSimpleStorage {
impl Default for AppState {
fn default() -> Self {
Self::new()
}
}
impl CoopSimpleStorage {
impl AppState {
pub fn new() -> Self {
let init_at = Timestamp::now();
let first_run = first_run();
@@ -205,7 +205,7 @@ impl CoopSimpleStorage {
}
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
static COOP_SIMPLE_STORAGE: OnceLock<CoopSimpleStorage> = OnceLock::new();
static APP_STATE: OnceLock<AppState> = OnceLock::new();
pub fn nostr_client() -> &'static Client {
NOSTR_CLIENT.get_or_init(|| {
@@ -223,15 +223,15 @@ pub fn nostr_client() -> &'static Client {
.automatic_authentication(false)
.verify_subscriptions(false)
.sleep_when_idle(SleepWhenIdle::Enabled {
timeout: Duration::from_secs(30),
timeout: Duration::from_secs(300),
});
ClientBuilder::default().database(lmdb).opts(opts).build()
})
}
pub fn css() -> &'static CoopSimpleStorage {
COOP_SIMPLE_STORAGE.get_or_init(CoopSimpleStorage::new)
pub fn app_state() -> &'static AppState {
APP_STATE.get_or_init(AppState::new)
}
fn first_run() -> bool {

View File

@@ -7,7 +7,7 @@ use anyhow::Error;
use common::display::ReadableProfile;
use common::event::EventUtils;
use global::constants::SEND_RETRY;
use global::{css, nostr_client};
use global::{app_state, nostr_client};
use gpui::{App, AppContext, Context, EventEmitter, SharedString, Task};
use itertools::Itertools;
use nostr_sdk::prelude::*;
@@ -432,7 +432,7 @@ impl Room {
let mut public_keys = self.members.clone();
cx.background_spawn(async move {
let css = css();
let app_state = app_state();
let client = nostr_client();
let signer = client.signer().await?;
let public_key = signer.get_public_key().await?;
@@ -492,15 +492,10 @@ impl Room {
if auth_required {
// Wait for authenticated and resent event successfully
for attempt in 0..=SEND_RETRY {
let ids = app_state.resent_ids.read().await;
// Check if event was successfully resent
if let Some(output) = css
.resent_ids
.read()
.await
.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);
reports.push(output);
break;