Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c12856cda0 | ||
|
|
c67b223a53 | ||
|
|
9880a3ed3d | ||
|
|
d13ffd5a54 | ||
|
|
cc79f0ed1c | ||
|
|
5127eaadbb |
Generated
+64
-53
@@ -190,7 +190,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "assets"
|
name = "assets"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -251,9 +251,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-fs"
|
name = "async-fs"
|
||||||
version = "2.1.3"
|
version = "2.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09f7e37c0ed80b2a977691c47dae8625cfb21e205827106c64f7c588766b2e50"
|
checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"blocking",
|
"blocking",
|
||||||
@@ -262,11 +262,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-io"
|
name = "async-io"
|
||||||
version = "2.5.0"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19634d6336019ef220f09fd31168ce5c184b295cbf80345437cc36094ef223ca"
|
checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-lock",
|
"autocfg",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
@@ -275,7 +275,7 @@ dependencies = [
|
|||||||
"polling",
|
"polling",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"slab",
|
"slab",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.61.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -302,9 +302,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-process"
|
name = "async-process"
|
||||||
version = "2.4.0"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "65daa13722ad51e6ab1a1b9c01299142bc75135b337923cfa10e79bbbd669f00"
|
checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"async-io",
|
"async-io",
|
||||||
@@ -331,9 +331,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-signal"
|
name = "async-signal"
|
||||||
version = "0.2.12"
|
version = "0.2.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f567af260ef69e1d52c2b560ce0ea230763e6fbb9214a85d768760a920e3e3c1"
|
checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-io",
|
"async-io",
|
||||||
"async-lock",
|
"async-lock",
|
||||||
@@ -344,7 +344,7 @@ dependencies = [
|
|||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"slab",
|
"slab",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.61.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -428,7 +428,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auto_update"
|
name = "auto_update"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo-packager-updater",
|
"cargo-packager-updater",
|
||||||
@@ -1029,7 +1029,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client_keys"
|
name = "client_keys"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"global",
|
"global",
|
||||||
@@ -1131,7 +1131,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "collections"
|
name = "collections"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
@@ -1166,7 +1166,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -1239,7 +1239,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coop"
|
name = "coop"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assets",
|
"assets",
|
||||||
@@ -1572,7 +1572,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1824,11 +1824,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "erased-serde"
|
name = "erased-serde"
|
||||||
version = "0.4.6"
|
version = "0.4.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7"
|
checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_core",
|
||||||
"typeid",
|
"typeid",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2405,7 +2406,7 @@ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "global"
|
name = "global"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
@@ -2498,7 +2499,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui"
|
name = "gpui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
@@ -2559,7 +2560,6 @@ dependencies = [
|
|||||||
"seahash",
|
"seahash",
|
||||||
"semantic_version",
|
"semantic_version",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -2592,7 +2592,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2604,7 +2604,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -2818,7 +2818,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2838,7 +2838,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-platform-verifier",
|
"rustls-platform-verifier",
|
||||||
@@ -2941,7 +2941,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "i18n"
|
name = "i18n"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rust-i18n",
|
"rust-i18n",
|
||||||
]
|
]
|
||||||
@@ -3428,9 +3428,9 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libredox"
|
name = "libredox"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
|
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -3629,7 +3629,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "media"
|
name = "media"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bindgen 0.71.1",
|
"bindgen 0.71.1",
|
||||||
@@ -4594,16 +4594,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "3.10.0"
|
version = "3.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829"
|
checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"hermit-abi",
|
"hermit-abi",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.61.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5069,7 +5069,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "refineable"
|
name = "refineable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_refineable",
|
"derive_refineable",
|
||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
@@ -5106,7 +5106,7 @@ checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "registry"
|
name = "registry"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -5223,7 +5223,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -5758,7 +5758,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -5767,24 +5767,34 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.26"
|
version = "1.0.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
|
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.219"
|
version = "1.0.223"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
checksum = "a505d71960adde88e293da5cb5eda57093379f64e61cf77bf0e6a63af07a7bac"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_core"
|
||||||
|
version = "1.0.223"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20f57cbd357666aa7b3ac84a90b4ea328f1d4ddb6772b430caa5d9e1309bb9e9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.219"
|
version = "1.0.223"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
checksum = "3d428d07faf17e306e699ec1e91996e5a165ba5d6bce5b5155173e91a8a01a56"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5813,15 +5823,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.143"
|
version = "1.0.145"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
|
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5893,7 +5904,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "settings"
|
name = "settings"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"global",
|
"global",
|
||||||
@@ -5960,7 +5971,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signer_proxy"
|
name = "signer_proxy"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"atomic-destructor",
|
"atomic-destructor",
|
||||||
@@ -6199,7 +6210,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"log",
|
"log",
|
||||||
@@ -6502,7 +6513,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theme"
|
name = "theme"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -6664,7 +6675,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "title_bar"
|
name = "title_bar"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -7035,7 +7046,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ui"
|
name = "ui"
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -7229,7 +7240,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#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
source = "git+https://github.com/zed-industries/zed#1090c47a90c586b397dc3fdd0cd09b530f37e5a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-fs",
|
"async-fs",
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||||||
default-members = ["crates/coop"]
|
default-members = ["crates/coop"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.6"
|
version = "0.2.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
||||||
|
<path stroke="currentColor" stroke-linecap="square" stroke-linejoin="round" stroke-width="1.5" d="M21.25 12V6.75a2 2 0 0 0-2-2H4.75a2 2 0 0 0-2 2V12m18.5 0H2.75m18.5 0v5.25a2 2 0 0 1-2 2H4.75a2 2 0 0 1-2-2V12"/>
|
||||||
|
<path fill="currentColor" stroke="currentColor" stroke-width=".5" d="M6.5 14.875a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5Zm0-7.25a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5Z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 486 B |
@@ -1,5 +1,7 @@
|
|||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
use global::constants::KEYRING_URL;
|
use global::constants::KEYRING_URL;
|
||||||
use global::first_run;
|
use global::css;
|
||||||
use gpui::{App, AppContext, Context, Entity, Global, Subscription, Window};
|
use gpui::{App, AppContext, Context, Entity, Global, Subscription, Window};
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
@@ -59,6 +61,7 @@ impl ClientKeys {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let css = css();
|
||||||
let read_client_keys = cx.read_credentials(KEYRING_URL);
|
let read_client_keys = cx.read_credentials(KEYRING_URL);
|
||||||
|
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
@@ -73,7 +76,7 @@ impl ClientKeys {
|
|||||||
this.set_keys(Some(keys), false, true, cx);
|
this.set_keys(Some(keys), false, true, cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
} else if *first_run() {
|
} else if css.is_first_run.load(Ordering::Acquire) {
|
||||||
// If this is the first run, generate new keys and use them for the client keys
|
// If this is the first run, generate new keys and use them for the client keys
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.new_keys(cx);
|
this.new_keys(cx);
|
||||||
|
|||||||
@@ -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.6"
|
version = "0.2.8"
|
||||||
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"]
|
||||||
|
|||||||
+112
-103
@@ -9,12 +9,11 @@ use auto_update::AutoUpdater;
|
|||||||
use client_keys::ClientKeys;
|
use client_keys::ClientKeys;
|
||||||
use common::display::ReadableProfile;
|
use common::display::ReadableProfile;
|
||||||
use common::event::EventUtils;
|
use common::event::EventUtils;
|
||||||
use flume::{Receiver, Sender};
|
|
||||||
use global::constants::{
|
use global::constants::{
|
||||||
ACCOUNT_IDENTIFIER, BOOTSTRAP_RELAYS, DEFAULT_SIDEBAR_WIDTH, METADATA_BATCH_LIMIT,
|
ACCOUNT_IDENTIFIER, BOOTSTRAP_RELAYS, DEFAULT_SIDEBAR_WIDTH, METADATA_BATCH_LIMIT,
|
||||||
METADATA_BATCH_TIMEOUT, SEARCH_RELAYS,
|
METADATA_BATCH_TIMEOUT, SEARCH_RELAYS,
|
||||||
};
|
};
|
||||||
use global::{css, ingester, nostr_client, AuthRequest, Notice, Signal, UnwrappingStatus};
|
use global::{css, nostr_client, AuthRequest, Notice, SignalKind, UnwrappingStatus};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, rems, App, AppContext, AsyncWindowContext, Axis, Context, Entity, InteractiveElement,
|
div, px, rems, App, AppContext, AsyncWindowContext, Axis, Context, Entity, InteractiveElement,
|
||||||
@@ -92,7 +91,6 @@ impl ChatSpace {
|
|||||||
let title_bar = cx.new(|_| TitleBar::new());
|
let title_bar = cx.new(|_| TitleBar::new());
|
||||||
let dock = cx.new(|cx| DockArea::new(window, cx));
|
let dock = cx.new(|cx| DockArea::new(window, cx));
|
||||||
|
|
||||||
let (pubkey_tx, pubkey_rx) = flume::bounded::<PublicKey>(1024);
|
|
||||||
let mut subscriptions = smallvec![];
|
let mut subscriptions = smallvec![];
|
||||||
let mut tasks = smallvec![];
|
let mut tasks = smallvec![];
|
||||||
|
|
||||||
@@ -147,7 +145,7 @@ impl ChatSpace {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed connect the bootstrap relays. Please restart the application.");
|
.expect("Failed connect the bootstrap relays. Please restart the application.");
|
||||||
|
|
||||||
Self::process_nostr_events(&pubkey_tx)
|
Self::process_nostr_events()
|
||||||
.await
|
.await
|
||||||
.expect("Failed to handle nostr events. Please restart the application.");
|
.expect("Failed to handle nostr events. Please restart the application.");
|
||||||
}),
|
}),
|
||||||
@@ -171,7 +169,7 @@ impl ChatSpace {
|
|||||||
tasks.push(
|
tasks.push(
|
||||||
// Listen all metadata requests then batch them into single subscription
|
// Listen all metadata requests then batch them into single subscription
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
Self::process_batching_metadata(&pubkey_rx).await;
|
Self::process_batching_metadata().await;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -215,7 +213,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
async fn observe_signer() {
|
async fn observe_signer() {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let ingester = ingester();
|
let css = css();
|
||||||
let stream_timeout = Duration::from_secs(5);
|
let stream_timeout = Duration::from_secs(5);
|
||||||
let loop_duration = Duration::from_secs(1);
|
let loop_duration = Duration::from_secs(1);
|
||||||
|
|
||||||
@@ -231,7 +229,7 @@ impl ChatSpace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Notify the app that the signer has been set.
|
// Notify the app that the signer has been set.
|
||||||
ingester.send(Signal::SignerSet(public_key)).await;
|
css.signal.send(SignalKind::SignerSet(public_key)).await;
|
||||||
|
|
||||||
// Subscribe to the NIP-65 relays for the public key.
|
// Subscribe to the NIP-65 relays for the public key.
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
@@ -239,35 +237,48 @@ impl ChatSpace {
|
|||||||
.author(public_key)
|
.author(public_key)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
|
let mut nip65_found = false;
|
||||||
|
|
||||||
match client
|
match client
|
||||||
.stream_events_from(BOOTSTRAP_RELAYS, filter, stream_timeout)
|
.stream_events_from(BOOTSTRAP_RELAYS, filter, stream_timeout)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(mut stream) => {
|
Ok(mut stream) => {
|
||||||
let mut processed_ids = HashSet::new();
|
if stream.next().await.is_some() {
|
||||||
|
nip65_found = true;
|
||||||
if let Some(event) = stream.next().await {
|
|
||||||
if processed_ids.insert(event.id) {
|
|
||||||
// Fetch user's metadata event
|
|
||||||
Self::fetch_single_event(Kind::Metadata, event.pubkey).await;
|
|
||||||
|
|
||||||
// Fetch user's contact list event
|
|
||||||
Self::fetch_single_event(Kind::ContactList, event.pubkey).await;
|
|
||||||
|
|
||||||
// Fetch user's inbox relays event
|
|
||||||
Self::fetch_nip17_relays(event.pubkey).await;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ingester.send(Signal::DmRelayNotFound).await;
|
// Timeout
|
||||||
|
css.signal.send(SignalKind::RelaysNotFound).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Error fetching NIP-65 Relay: {e:?}");
|
||||||
|
css.signal.send(SignalKind::RelaysNotFound).await;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if nip65_found {
|
||||||
|
// Subscribe to the NIP-17 relays for the public key.
|
||||||
|
let filter = Filter::new()
|
||||||
|
.kind(Kind::InboxRelays)
|
||||||
|
.author(public_key)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
match client.stream_events(filter, stream_timeout).await {
|
||||||
|
Ok(mut stream) => {
|
||||||
|
if stream.next().await.is_some() {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// Timeout
|
||||||
|
css.signal.send(SignalKind::RelaysNotFound).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Error fetching NIP-17 Relay: {e:?}");
|
log::error!("Error fetching NIP-17 Relay: {e:?}");
|
||||||
ingester.send(Signal::DmRelayNotFound).await;
|
css.signal.send(SignalKind::RelaysNotFound).await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -276,7 +287,6 @@ impl ChatSpace {
|
|||||||
async fn observe_giftwrap() {
|
async fn observe_giftwrap() {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let css = css();
|
let css = css();
|
||||||
let ingester = ingester();
|
|
||||||
let loop_duration = Duration::from_secs(20);
|
let loop_duration = Duration::from_secs(20);
|
||||||
let mut is_start_processing = false;
|
let mut is_start_processing = false;
|
||||||
let mut total_loops = 0;
|
let mut total_loops = 0;
|
||||||
@@ -296,14 +306,14 @@ impl ChatSpace {
|
|||||||
Ordering::Relaxed,
|
Ordering::Relaxed,
|
||||||
);
|
);
|
||||||
|
|
||||||
let signal = Signal::GiftWrapProcess(UnwrappingStatus::Processing);
|
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Processing);
|
||||||
ingester.send(signal).await;
|
css.signal.send(signal).await;
|
||||||
} else {
|
} else {
|
||||||
// Only run further if we are already processing
|
// Only run further if we are already processing
|
||||||
// Wait until after 2 loops to prevent exiting early while events are still being processed
|
// Wait until after 2 loops to prevent exiting early while events are still being processed
|
||||||
if is_start_processing && total_loops >= 2 {
|
if is_start_processing && total_loops >= 2 {
|
||||||
let signal = Signal::GiftWrapProcess(UnwrappingStatus::Complete);
|
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Complete);
|
||||||
ingester.send(signal).await;
|
css.signal.send(signal).await;
|
||||||
|
|
||||||
// Reset the counter
|
// Reset the counter
|
||||||
is_start_processing = false;
|
is_start_processing = false;
|
||||||
@@ -316,7 +326,8 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_batching_metadata(rx: &Receiver<PublicKey>) {
|
async fn process_batching_metadata() {
|
||||||
|
let css = css();
|
||||||
let timeout = Duration::from_millis(METADATA_BATCH_TIMEOUT);
|
let timeout = Duration::from_millis(METADATA_BATCH_TIMEOUT);
|
||||||
let mut processed_pubkeys: HashSet<PublicKey> = HashSet::new();
|
let mut processed_pubkeys: HashSet<PublicKey> = HashSet::new();
|
||||||
let mut batch: HashSet<PublicKey> = HashSet::new();
|
let mut batch: HashSet<PublicKey> = HashSet::new();
|
||||||
@@ -331,7 +342,7 @@ impl ChatSpace {
|
|||||||
loop {
|
loop {
|
||||||
let futs = smol::future::or(
|
let futs = smol::future::or(
|
||||||
async move {
|
async move {
|
||||||
if let Ok(public_key) = rx.recv_async().await {
|
if let Ok(public_key) = css.ingester.receiver().recv_async().await {
|
||||||
BatchEvent::PublicKey(public_key)
|
BatchEvent::PublicKey(public_key)
|
||||||
} else {
|
} else {
|
||||||
BatchEvent::Closed
|
BatchEvent::Closed
|
||||||
@@ -366,9 +377,8 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_nostr_events(pubkey_tx: &Sender<PublicKey>) -> Result<(), Error> {
|
async fn process_nostr_events() -> Result<(), Error> {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let ingester = ingester();
|
|
||||||
let css = css();
|
let css = css();
|
||||||
|
|
||||||
let mut processed_events: HashSet<EventId> = HashSet::new();
|
let mut processed_events: HashSet<EventId> = HashSet::new();
|
||||||
@@ -382,12 +392,52 @@ impl ChatSpace {
|
|||||||
|
|
||||||
match message {
|
match message {
|
||||||
RelayMessage::Event { event, .. } => {
|
RelayMessage::Event { event, .. } => {
|
||||||
|
// Keep track of which relays have seen this event
|
||||||
|
css.seen_on_relays
|
||||||
|
.write()
|
||||||
|
.await
|
||||||
|
.entry(event.id)
|
||||||
|
.or_insert_with(HashSet::new)
|
||||||
|
.insert(relay_url);
|
||||||
|
|
||||||
// Skip events that have already been processed
|
// Skip events that have already been processed
|
||||||
if !processed_events.insert(event.id) {
|
if !processed_events.insert(event.id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
match event.kind {
|
match event.kind {
|
||||||
|
Kind::RelayList => {
|
||||||
|
if let Ok(true) = Self::is_self_event(&event).await {
|
||||||
|
// Fetch user's metadata event
|
||||||
|
Self::fetch_single_event(Kind::Metadata, event.pubkey).await;
|
||||||
|
|
||||||
|
// Fetch user's contact list event
|
||||||
|
Self::fetch_single_event(Kind::ContactList, event.pubkey).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Kind::InboxRelays => {
|
||||||
|
if let Ok(true) = Self::is_self_event(&event).await {
|
||||||
|
let relays = nip17::extract_relay_list(&event).collect_vec();
|
||||||
|
|
||||||
|
if !relays.is_empty() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
if client.connect_relay(relay).await.is_err() {
|
||||||
|
let notice = Notice::RelayFailed(relay.clone());
|
||||||
|
css.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Kind::ContactList => {
|
Kind::ContactList => {
|
||||||
if let Ok(true) = Self::is_self_event(&event).await {
|
if let Ok(true) = Self::is_self_event(&event).await {
|
||||||
let public_keys = event.tags.public_keys().copied().collect_vec();
|
let public_keys = event.tags.public_keys().copied().collect_vec();
|
||||||
@@ -403,28 +453,28 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Kind::Metadata => {
|
Kind::Metadata => {
|
||||||
if let Ok(metadata) = Metadata::from_json(&event.content) {
|
let metadata = Metadata::from_json(&event.content).unwrap_or_default();
|
||||||
let profile = Profile::new(event.pubkey, metadata);
|
let profile = Profile::new(event.pubkey, metadata);
|
||||||
ingester.send(Signal::Metadata(profile)).await;
|
|
||||||
}
|
css.signal.send(SignalKind::NewProfile(profile)).await;
|
||||||
}
|
}
|
||||||
Kind::GiftWrap => {
|
Kind::GiftWrap => {
|
||||||
Self::unwrap_gift_wrap(&event, pubkey_tx).await;
|
Self::unwrap_gift_wrap(&event).await;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelayMessage::EndOfStoredEvents(subscription_id) => {
|
RelayMessage::EndOfStoredEvents(subscription_id) => {
|
||||||
if *subscription_id == css.gift_wrap_sub_id {
|
if *subscription_id == css.gift_wrap_sub_id {
|
||||||
let signal = Signal::GiftWrapProcess(UnwrappingStatus::Processing);
|
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Processing);
|
||||||
ingester.send(signal).await;
|
css.signal.send(signal).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelayMessage::Auth { challenge } => {
|
RelayMessage::Auth { challenge } => {
|
||||||
if challenges.insert(challenge.clone()) {
|
if challenges.insert(challenge.clone()) {
|
||||||
let req = AuthRequest::new(challenge, relay_url);
|
let req = AuthRequest::new(challenge, relay_url);
|
||||||
// Send a signal to the ingester to handle the auth request
|
// Send a signal to the ingester to handle the auth request
|
||||||
ingester.send(Signal::Auth(req)).await;
|
css.signal.send(SignalKind::Auth(req)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelayMessage::Ok {
|
RelayMessage::Ok {
|
||||||
@@ -450,17 +500,16 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn process_nostr_signals(view: WeakEntity<ChatSpace>, cx: &mut AsyncWindowContext) {
|
async fn process_nostr_signals(view: WeakEntity<ChatSpace>, cx: &mut AsyncWindowContext) {
|
||||||
let ingester = ingester();
|
let css = css();
|
||||||
let signals = ingester.signals();
|
|
||||||
let mut is_open_proxy_modal = false;
|
let mut is_open_proxy_modal = false;
|
||||||
|
|
||||||
while let Ok(signal) = signals.recv_async().await {
|
while let Ok(signal) = css.signal.receiver().recv_async().await {
|
||||||
cx.update(|window, cx| {
|
cx.update(|window, cx| {
|
||||||
let registry = Registry::global(cx);
|
let registry = Registry::global(cx);
|
||||||
let settings = AppSettings::global(cx);
|
let settings = AppSettings::global(cx);
|
||||||
|
|
||||||
match signal {
|
match signal {
|
||||||
Signal::SignerSet(public_key) => {
|
SignalKind::SignerSet(public_key) => {
|
||||||
window.close_modal(cx);
|
window.close_modal(cx);
|
||||||
|
|
||||||
// Setup the default layout for current workspace
|
// Setup the default layout for current workspace
|
||||||
@@ -480,7 +529,7 @@ impl ChatSpace {
|
|||||||
this.load_rooms(window, cx);
|
this.load_rooms(window, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Signal::SignerUnset => {
|
SignalKind::SignerUnset => {
|
||||||
// Setup the onboarding layout for current workspace
|
// Setup the onboarding layout for current workspace
|
||||||
view.update(cx, |this, cx| {
|
view.update(cx, |this, cx| {
|
||||||
this.set_onboarding_layout(window, cx);
|
this.set_onboarding_layout(window, cx);
|
||||||
@@ -492,7 +541,7 @@ impl ChatSpace {
|
|||||||
this.reset(cx);
|
this.reset(cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Signal::Auth(req) => {
|
SignalKind::Auth(req) => {
|
||||||
let url = &req.url;
|
let url = &req.url;
|
||||||
let auto_auth = AppSettings::get_auto_auth(cx);
|
let auto_auth = AppSettings::get_auto_auth(cx);
|
||||||
let is_authenticated = AppSettings::read_global(cx).is_authenticated(url);
|
let is_authenticated = AppSettings::read_global(cx).is_authenticated(url);
|
||||||
@@ -510,7 +559,7 @@ impl ChatSpace {
|
|||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
Signal::ProxyDown => {
|
SignalKind::ProxyDown => {
|
||||||
if !is_open_proxy_modal {
|
if !is_open_proxy_modal {
|
||||||
is_open_proxy_modal = true;
|
is_open_proxy_modal = true;
|
||||||
|
|
||||||
@@ -520,28 +569,28 @@ impl ChatSpace {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Signal::GiftWrapProcess(status) => {
|
SignalKind::GiftWrapStatus(status) => {
|
||||||
registry.update(cx, |this, cx| {
|
registry.update(cx, |this, cx| {
|
||||||
this.set_unwrapping_status(status, cx);
|
this.set_unwrapping_status(status, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Signal::Metadata(profile) => {
|
SignalKind::NewProfile(profile) => {
|
||||||
registry.update(cx, |this, cx| {
|
registry.update(cx, |this, cx| {
|
||||||
this.insert_or_update_person(profile, cx);
|
this.insert_or_update_person(profile, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Signal::Message((gift_wrap_id, event)) => {
|
SignalKind::NewMessage((gift_wrap_id, event)) => {
|
||||||
registry.update(cx, |this, cx| {
|
registry.update(cx, |this, cx| {
|
||||||
this.event_to_message(gift_wrap_id, event, window, cx);
|
this.event_to_message(gift_wrap_id, event, window, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Signal::DmRelayNotFound => {
|
SignalKind::RelaysNotFound => {
|
||||||
view.update(cx, |this, cx| {
|
view.update(cx, |this, cx| {
|
||||||
this.set_required_relays(cx);
|
this.set_required_relays(cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
Signal::Notice(msg) => {
|
SignalKind::Notice(msg) => {
|
||||||
window.push_notification(msg.as_str(), cx);
|
window.push_notification(msg.as_str(), cx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -570,49 +619,7 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch_nip17_relays(public_key: PublicKey) {
|
/// Fetches gift wrap events for a given public key and relays
|
||||||
let client = nostr_client();
|
|
||||||
let ingester = ingester();
|
|
||||||
let filter = Filter::new()
|
|
||||||
.kind(Kind::InboxRelays)
|
|
||||||
.author(public_key)
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
match client.stream_events(filter, Duration::from_secs(5)).await {
|
|
||||||
Ok(mut stream) => {
|
|
||||||
let mut processed_ids = HashSet::new();
|
|
||||||
|
|
||||||
if let Some(event) = stream.next().await {
|
|
||||||
if processed_ids.insert(event.id) {
|
|
||||||
let relays = nip17::extract_relay_list(&event).collect_vec();
|
|
||||||
|
|
||||||
if !relays.is_empty() {
|
|
||||||
for relay in relays.clone().into_iter() {
|
|
||||||
if client.add_relay(relay).await.is_err() {
|
|
||||||
let notice = Notice::RelayFailed(relay.clone());
|
|
||||||
ingester.send(Signal::Notice(notice)).await;
|
|
||||||
}
|
|
||||||
if client.connect_relay(relay).await.is_err() {
|
|
||||||
let notice = Notice::RelayFailed(relay.clone());
|
|
||||||
ingester.send(Signal::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 {
|
|
||||||
ingester.send(Signal::DmRelayNotFound).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Error fetching NIP-17 Relay: {e:?}");
|
|
||||||
ingester.send(Signal::DmRelayNotFound).await;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn fetch_gift_wrap(relays: Vec<&RelayUrl>, public_key: PublicKey) {
|
pub async fn fetch_gift_wrap(relays: Vec<&RelayUrl>, public_key: PublicKey) {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let sub_id = css().gift_wrap_sub_id.clone();
|
let sub_id = css().gift_wrap_sub_id.clone();
|
||||||
@@ -689,9 +696,8 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Unwraps a gift-wrapped event and processes its contents.
|
/// Unwraps a gift-wrapped event and processes its contents.
|
||||||
async fn unwrap_gift_wrap(target: &Event, pubkey_tx: &Sender<PublicKey>) {
|
async fn unwrap_gift_wrap(target: &Event) {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let ingester = ingester();
|
|
||||||
let css = css();
|
let css = css();
|
||||||
let mut message: Option<Event> = None;
|
let mut message: Option<Event> = None;
|
||||||
|
|
||||||
@@ -712,14 +718,17 @@ impl ChatSpace {
|
|||||||
if let Some(event) = message {
|
if let Some(event) = message {
|
||||||
// Send all pubkeys to the metadata batch to sync data
|
// Send all pubkeys to the metadata batch to sync data
|
||||||
for public_key in event.all_pubkeys() {
|
for public_key in event.all_pubkeys() {
|
||||||
pubkey_tx.send_async(public_key).await.ok();
|
css.ingester.send(public_key).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
match event.created_at >= css.init_at {
|
match event.created_at >= css.init_at {
|
||||||
// New message: send a signal to notify the UI
|
// New message: send a signal to notify the UI
|
||||||
true => {
|
true => {
|
||||||
|
// A small delay to prevent UI flickering
|
||||||
smol::Timer::after(Duration::from_millis(200)).await;
|
smol::Timer::after(Duration::from_millis(200)).await;
|
||||||
ingester.send(Signal::Message((target.id, event))).await;
|
css.signal
|
||||||
|
.send(SignalKind::NewMessage((target.id, event)))
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
// Old message: Coop is probably processing the user's messages during initial load
|
// Old message: Coop is probably processing the user's messages during initial load
|
||||||
false => {
|
false => {
|
||||||
@@ -1122,7 +1131,7 @@ impl ChatSpace {
|
|||||||
fn on_sign_out(&mut self, _e: &Logout, _window: &mut Window, cx: &mut Context<Self>) {
|
fn on_sign_out(&mut self, _e: &Logout, _window: &mut Window, cx: &mut Context<Self>) {
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let ingester = ingester();
|
let css = css();
|
||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
.kind(Kind::ApplicationSpecificData)
|
.kind(Kind::ApplicationSpecificData)
|
||||||
@@ -1135,7 +1144,7 @@ impl ChatSpace {
|
|||||||
client.reset().await;
|
client.reset().await;
|
||||||
|
|
||||||
// Notify the channel about the signer being unset
|
// Notify the channel about the signer being unset
|
||||||
ingester.send(Signal::SignerUnset).await;
|
css.signal.send(SignalKind::SignerUnset).await;
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
@@ -1359,7 +1368,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
this._tasks.push(cx.background_spawn(async move {
|
this._tasks.push(cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let ingester = ingester();
|
let css = css();
|
||||||
|
|
||||||
if proxy.start().await.is_ok() {
|
if proxy.start().await.is_ok() {
|
||||||
webbrowser::open(&url).ok();
|
webbrowser::open(&url).ok();
|
||||||
@@ -1390,7 +1399,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
ingester.send(Signal::ProxyDown).await;
|
css.signal.send(SignalKind::ProxyDown).await;
|
||||||
}
|
}
|
||||||
smol::Timer::after(Duration::from_secs(1)).await;
|
smol::Timer::after(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use assets::Assets;
|
use assets::Assets;
|
||||||
use global::constants::{APP_ID, APP_NAME};
|
use global::constants::{APP_ID, APP_NAME};
|
||||||
use global::{css, ingester, nostr_client};
|
use global::{css, nostr_client};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
point, px, size, AppContext, Application, Bounds, KeyBinding, Menu, MenuItem, SharedString,
|
point, px, size, AppContext, Application, Bounds, KeyBinding, Menu, MenuItem, SharedString,
|
||||||
TitlebarOptions, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowKind,
|
TitlebarOptions, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowKind,
|
||||||
@@ -26,9 +26,6 @@ fn main() {
|
|||||||
// Initialize the Nostr client
|
// Initialize the Nostr client
|
||||||
let _client = nostr_client();
|
let _client = nostr_client();
|
||||||
|
|
||||||
// Initialize the ingester
|
|
||||||
let _ingester = ingester();
|
|
||||||
|
|
||||||
// Initialize the coop simple storage
|
// Initialize the coop simple storage
|
||||||
let _css = css();
|
let _css = css();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use client_keys::ClientKeys;
|
|||||||
use common::display::ReadableProfile;
|
use common::display::ReadableProfile;
|
||||||
use common::handle_auth::CoopAuthUrlHandler;
|
use common::handle_auth::CoopAuthUrlHandler;
|
||||||
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
|
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
|
||||||
use global::{ingester, nostr_client, Signal};
|
use global::{css, nostr_client, SignalKind};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, relative, rems, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter,
|
div, relative, rems, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter,
|
||||||
@@ -248,7 +248,7 @@ impl Account {
|
|||||||
// Reset the nostr client in the background
|
// Reset the nostr client in the background
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let ingester = ingester();
|
let css = css();
|
||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
.kind(Kind::ApplicationSpecificData)
|
.kind(Kind::ApplicationSpecificData)
|
||||||
@@ -261,7 +261,7 @@ impl Account {
|
|||||||
client.unset_signer().await;
|
client.unset_signer().await;
|
||||||
|
|
||||||
// Notify the channel about the signer being unset
|
// Notify the channel about the signer being unset
|
||||||
ingester.send(Signal::SignerUnset).await;
|
css.signal.send(SignalKind::SignerUnset).await;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use common::display::{ReadableProfile, ReadableTimestamp};
|
use common::display::{ReadableProfile, ReadableTimestamp};
|
||||||
use common::nip96::nip96_upload;
|
use common::nip96::nip96_upload;
|
||||||
@@ -24,12 +26,12 @@ use smallvec::{smallvec, SmallVec};
|
|||||||
use smol::fs;
|
use smol::fs;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::dock_area::panel::{Panel, PanelEvent};
|
use ui::dock_area::panel::{Panel, PanelEvent};
|
||||||
use ui::emoji_picker::EmojiPicker;
|
use ui::emoji_picker::EmojiPicker;
|
||||||
use ui::input::{InputEvent, InputState, TextInput};
|
use ui::input::{InputEvent, InputState, TextInput};
|
||||||
use ui::modal::ModalButtonProps;
|
use ui::modal::ModalButtonProps;
|
||||||
use ui::popup_menu::PopupMenu;
|
use ui::popup_menu::{PopupMenu, PopupMenuExt};
|
||||||
use ui::text::RenderedText;
|
use ui::text::RenderedText;
|
||||||
use ui::{
|
use ui::{
|
||||||
h_flex, v_flex, ContextModal, Disableable, Icon, IconName, InteractiveElementExt, Sizable,
|
h_flex, v_flex, ContextModal, Disableable, Icon, IconName, InteractiveElementExt, Sizable,
|
||||||
@@ -40,7 +42,7 @@ mod subject;
|
|||||||
|
|
||||||
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[action(namespace = chat, no_json)]
|
#[action(namespace = chat, no_json)]
|
||||||
pub struct ChangeSubject(pub String);
|
pub struct SeenOn(pub EventId);
|
||||||
|
|
||||||
pub fn init(room: Entity<Room>, window: &mut Window, cx: &mut App) -> Entity<Chat> {
|
pub fn init(room: Entity<Room>, window: &mut Window, cx: &mut App) -> Entity<Chat> {
|
||||||
cx.new(|cx| Chat::new(room, window, cx))
|
cx.new(|cx| Chat::new(room, window, cx))
|
||||||
@@ -49,6 +51,9 @@ pub fn init(room: Entity<Room>, window: &mut Window, cx: &mut App) -> Entity<Cha
|
|||||||
pub struct Chat {
|
pub struct Chat {
|
||||||
// Chat Room
|
// Chat Room
|
||||||
room: Entity<Room>,
|
room: Entity<Room>,
|
||||||
|
relays: Entity<HashMap<PublicKey, Vec<RelayUrl>>>,
|
||||||
|
|
||||||
|
// Messages
|
||||||
list_state: ListState,
|
list_state: ListState,
|
||||||
messages: BTreeSet<Message>,
|
messages: BTreeSet<Message>,
|
||||||
rendered_texts_by_id: BTreeMap<EventId, RenderedText>,
|
rendered_texts_by_id: BTreeMap<EventId, RenderedText>,
|
||||||
@@ -67,14 +72,20 @@ pub struct Chat {
|
|||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
image_cache: Entity<RetainAllImageCache>,
|
image_cache: Entity<RetainAllImageCache>,
|
||||||
|
|
||||||
_subscriptions: SmallVec<[Subscription; 2]>,
|
_subscriptions: SmallVec<[Subscription; 4]>,
|
||||||
_tasks: SmallVec<[Task<()>; 1]>,
|
_tasks: SmallVec<[Task<()>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Chat {
|
impl Chat {
|
||||||
pub fn new(room: Entity<Room>, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
pub fn new(room: Entity<Room>, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
let attachments = cx.new(|_| vec![]);
|
let attachments = cx.new(|_| vec![]);
|
||||||
let replies_to = cx.new(|_| vec![]);
|
let replies_to = cx.new(|_| vec![]);
|
||||||
|
|
||||||
|
let relays = cx.new(|_| {
|
||||||
|
let this: HashMap<PublicKey, Vec<RelayUrl>> = HashMap::new();
|
||||||
|
this
|
||||||
|
});
|
||||||
|
|
||||||
let input = cx.new(|cx| {
|
let input = cx.new(|cx| {
|
||||||
InputState::new(window, cx)
|
InputState::new(window, cx)
|
||||||
.placeholder(t!("chat.placeholder"))
|
.placeholder(t!("chat.placeholder"))
|
||||||
@@ -89,11 +100,35 @@ 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 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![];
|
||||||
let mut tasks = smallvec![];
|
let mut tasks = smallvec![];
|
||||||
|
|
||||||
|
tasks.push(
|
||||||
|
// Load all messages belonging to this room
|
||||||
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
|
match connect_relays.await {
|
||||||
|
Ok(relays) => {
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.relays.update(cx, |this, cx| {
|
||||||
|
*this = relays;
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
cx.update(|window, cx| {
|
||||||
|
window.push_notification(e.to_string(), cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
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| {
|
||||||
@@ -139,7 +174,7 @@ impl Chat {
|
|||||||
match signal {
|
match signal {
|
||||||
RoomSignal::NewMessage((gift_wrap_id, event)) => {
|
RoomSignal::NewMessage((gift_wrap_id, event)) => {
|
||||||
if !this.is_sent_by_coop(gift_wrap_id) {
|
if !this.is_sent_by_coop(gift_wrap_id) {
|
||||||
this.insert_message(event, false, cx);
|
this.insert_message(Message::user(event), false, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RoomSignal::Refresh => {
|
RoomSignal::Refresh => {
|
||||||
@@ -149,6 +184,33 @@ impl Chat {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
subscriptions.push(
|
||||||
|
// Observe the messaging relays of the room's members
|
||||||
|
cx.observe_in(&relays, window, |this, entity, _window, cx| {
|
||||||
|
for (public_key, urls) in entity.read(cx).clone().into_iter() {
|
||||||
|
if urls.is_empty() {
|
||||||
|
let profile = Registry::read_global(cx).get_person(&public_key, cx);
|
||||||
|
let content = t!("chat.nip17_not_found", u = profile.name());
|
||||||
|
|
||||||
|
this.insert_warning(content, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
subscriptions.push(
|
||||||
|
// Observe when user close chat panel
|
||||||
|
cx.on_release_in(window, move |this, window, cx| {
|
||||||
|
this.disconnect_relays(cx);
|
||||||
|
this.messages.clear();
|
||||||
|
this.rendered_texts_by_id.clear();
|
||||||
|
this.reports_by_id.clear();
|
||||||
|
this.image_cache.update(cx, |this, cx| {
|
||||||
|
this.clear(window, cx);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id: room.read(cx).id.to_string().into(),
|
id: room.read(cx).id.to_string().into(),
|
||||||
image_cache: RetainAllImageCache::new(cx),
|
image_cache: RetainAllImageCache::new(cx),
|
||||||
@@ -156,6 +218,7 @@ impl Chat {
|
|||||||
uploading: false,
|
uploading: false,
|
||||||
rendered_texts_by_id: BTreeMap::new(),
|
rendered_texts_by_id: BTreeMap::new(),
|
||||||
reports_by_id: BTreeMap::new(),
|
reports_by_id: BTreeMap::new(),
|
||||||
|
relays,
|
||||||
messages,
|
messages,
|
||||||
room,
|
room,
|
||||||
list_state,
|
list_state,
|
||||||
@@ -167,6 +230,20 @@ 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);
|
||||||
@@ -260,7 +337,7 @@ impl Chat {
|
|||||||
|
|
||||||
cx.defer_in(window, |this, window, cx| {
|
cx.defer_in(window, |this, window, cx| {
|
||||||
// Optimistically update message list
|
// Optimistically update message list
|
||||||
this.insert_message(temp_message, true, cx);
|
this.insert_message(Message::user(temp_message), true, cx);
|
||||||
|
|
||||||
// Remove all replies
|
// Remove all replies
|
||||||
this.remove_all_replies(cx);
|
this.remove_all_replies(cx);
|
||||||
@@ -318,6 +395,7 @@ impl Chat {
|
|||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(reports) => {
|
Ok(reports) => {
|
||||||
|
if !reports.is_empty() {
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.reports_by_id.entry(id_clone).and_modify(|this| {
|
this.reports_by_id.entry(id_clone).and_modify(|this| {
|
||||||
*this = reports;
|
*this = reports;
|
||||||
@@ -326,6 +404,7 @@ impl Chat {
|
|||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
cx.update(|window, cx| {
|
cx.update(|window, cx| {
|
||||||
window.push_notification(e.to_string(), cx);
|
window.push_notification(e.to_string(), cx);
|
||||||
@@ -339,6 +418,41 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Insert a message into the chat panel
|
||||||
|
fn insert_message<E>(&mut self, m: E, scroll: bool, cx: &mut Context<Self>)
|
||||||
|
where
|
||||||
|
E: Into<Message>,
|
||||||
|
{
|
||||||
|
let old_len = self.messages.len();
|
||||||
|
|
||||||
|
// Extend the messages list with the new events
|
||||||
|
if self.messages.insert(m.into()) {
|
||||||
|
self.list_state.splice(old_len..old_len, 1);
|
||||||
|
|
||||||
|
if scroll {
|
||||||
|
self.list_state.scroll_to(ListOffset {
|
||||||
|
item_ix: self.list_state.item_count(),
|
||||||
|
offset_in_item: px(0.0),
|
||||||
|
});
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert and insert a vector of nostr events into the chat panel
|
||||||
|
fn insert_messages(&mut self, events: Vec<Event>, cx: &mut Context<Self>) {
|
||||||
|
for event in events.into_iter() {
|
||||||
|
let m = Message::user(event);
|
||||||
|
self.insert_message(m, false, cx);
|
||||||
|
}
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn insert_warning(&mut self, content: impl Into<String>, cx: &mut Context<Self>) {
|
||||||
|
let m = Message::warning(content.into());
|
||||||
|
self.insert_message(m, true, cx);
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if a message failed to send by its ID
|
/// Check if a message failed to send by its ID
|
||||||
fn is_sent_failed(&self, id: &EventId) -> bool {
|
fn is_sent_failed(&self, id: &EventId) -> bool {
|
||||||
self.reports_by_id
|
self.reports_by_id
|
||||||
@@ -370,35 +484,6 @@ impl Chat {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert and insert a nostr event into the chat panel
|
|
||||||
fn insert_message<E>(&mut self, event: E, scroll: bool, cx: &mut Context<Self>)
|
|
||||||
where
|
|
||||||
E: Into<RenderedMessage>,
|
|
||||||
{
|
|
||||||
let old_len = self.messages.len();
|
|
||||||
|
|
||||||
// Extend the messages list with the new events
|
|
||||||
if self.messages.insert(Message::user(event)) {
|
|
||||||
self.list_state.splice(old_len..old_len, 1);
|
|
||||||
|
|
||||||
if scroll {
|
|
||||||
self.list_state.scroll_to(ListOffset {
|
|
||||||
item_ix: self.list_state.item_count(),
|
|
||||||
offset_in_item: px(0.0),
|
|
||||||
});
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert and insert a vector of nostr events into the chat panel
|
|
||||||
fn insert_messages(&mut self, events: Vec<Event>, cx: &mut Context<Self>) {
|
|
||||||
for event in events.into_iter() {
|
|
||||||
self.insert_message(event, false, cx);
|
|
||||||
}
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn profile(&self, public_key: &PublicKey, cx: &Context<Self>) -> Profile {
|
fn profile(&self, public_key: &PublicKey, cx: &Context<Self>) -> Profile {
|
||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
registry.get_person(public_key, cx)
|
registry.get_person(public_key, cx)
|
||||||
@@ -557,6 +642,34 @@ impl Chat {
|
|||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_warning(&mut self, ix: usize, content: String, cx: &mut Context<Self>) -> AnyElement {
|
||||||
|
div()
|
||||||
|
.id(ix)
|
||||||
|
.relative()
|
||||||
|
.w_full()
|
||||||
|
.py_1()
|
||||||
|
.px_3()
|
||||||
|
.bg(cx.theme().warning_background)
|
||||||
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.gap_3()
|
||||||
|
.text_sm()
|
||||||
|
.text_color(cx.theme().warning_foreground)
|
||||||
|
.child(Avatar::new("brand/system.png").size(rems(2.)))
|
||||||
|
.child(SharedString::from(content)),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.absolute()
|
||||||
|
.left_0()
|
||||||
|
.top_0()
|
||||||
|
.w(px(2.))
|
||||||
|
.h_full()
|
||||||
|
.bg(cx.theme().warning_active),
|
||||||
|
)
|
||||||
|
.into_any_element()
|
||||||
|
}
|
||||||
|
|
||||||
fn render_message_not_found(&self, ix: usize, cx: &Context<Self>) -> AnyElement {
|
fn render_message_not_found(&self, ix: usize, cx: &Context<Self>) -> AnyElement {
|
||||||
div()
|
div()
|
||||||
.id(ix)
|
.id(ix)
|
||||||
@@ -617,9 +730,7 @@ impl Chat {
|
|||||||
.flex_initial()
|
.flex_initial()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.child(
|
.child(
|
||||||
div()
|
h_flex()
|
||||||
.flex()
|
|
||||||
.items_center()
|
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.text_color(cx.theme().text_placeholder)
|
.text_color(cx.theme().text_placeholder)
|
||||||
@@ -650,7 +761,7 @@ impl Chat {
|
|||||||
.label(t!("common.resend"))
|
.label(t!("common.resend"))
|
||||||
.danger()
|
.danger()
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(cx.listener(
|
.on_click(cx.listener(
|
||||||
move |this, _, window, cx| {
|
move |this, _, window, cx| {
|
||||||
this.resend_message(&id, window, cx);
|
this.resend_message(&id, window, cx);
|
||||||
@@ -920,31 +1031,6 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_actions(&self, id: &EventId, cx: &Context<Self>) -> impl IntoElement {
|
fn render_actions(&self, id: &EventId, cx: &Context<Self>) -> impl IntoElement {
|
||||||
let groups = vec![
|
|
||||||
Button::new("reply")
|
|
||||||
.icon(IconName::Reply)
|
|
||||||
.tooltip(t!("chat.reply_button"))
|
|
||||||
.small()
|
|
||||||
.ghost()
|
|
||||||
.on_click({
|
|
||||||
let id = id.to_owned();
|
|
||||||
cx.listener(move |this, _event, _window, cx| {
|
|
||||||
this.reply_to(&id, cx);
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
Button::new("copy")
|
|
||||||
.icon(IconName::Copy)
|
|
||||||
.tooltip(t!("chat.copy_message_button"))
|
|
||||||
.small()
|
|
||||||
.ghost()
|
|
||||||
.on_click({
|
|
||||||
let id = id.to_owned();
|
|
||||||
cx.listener(move |this, _event, _window, cx| {
|
|
||||||
this.copy_message(&id, cx);
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.p_0p5()
|
.p_0p5()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
@@ -957,7 +1043,45 @@ impl Chat {
|
|||||||
.border_1()
|
.border_1()
|
||||||
.border_color(cx.theme().border)
|
.border_color(cx.theme().border)
|
||||||
.bg(cx.theme().background)
|
.bg(cx.theme().background)
|
||||||
.children(groups)
|
.child(
|
||||||
|
Button::new("reply")
|
||||||
|
.icon(IconName::Reply)
|
||||||
|
.tooltip(t!("chat.reply_button"))
|
||||||
|
.small()
|
||||||
|
.ghost()
|
||||||
|
.on_click({
|
||||||
|
let id = id.to_owned();
|
||||||
|
cx.listener(move |this, _event, _window, cx| {
|
||||||
|
this.reply_to(&id, cx);
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
Button::new("copy")
|
||||||
|
.icon(IconName::Copy)
|
||||||
|
.tooltip(t!("chat.copy_message_button"))
|
||||||
|
.small()
|
||||||
|
.ghost()
|
||||||
|
.on_click({
|
||||||
|
let id = id.to_owned();
|
||||||
|
cx.listener(move |this, _event, _window, cx| {
|
||||||
|
this.copy_message(&id, cx);
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.child(div().flex_shrink_0().h_4().w_px().bg(cx.theme().border))
|
||||||
|
.child(
|
||||||
|
Button::new("seen-on")
|
||||||
|
.icon(IconName::Ellipsis)
|
||||||
|
.small()
|
||||||
|
.ghost()
|
||||||
|
.popup_menu({
|
||||||
|
let id = id.to_owned();
|
||||||
|
move |this, _window, _cx| {
|
||||||
|
this.menu(t!("common.seen_on"), Box::new(SeenOn(id)))
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
.group_hover("", |this| this.visible())
|
.group_hover("", |this| this.visible())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,6 +1257,62 @@ impl Chat {
|
|||||||
.ok();
|
.ok();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn on_open_seen_on(&mut self, ev: &SeenOn, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
let id = ev.0;
|
||||||
|
|
||||||
|
let task: Task<Result<Vec<RelayUrl>, Error>> = cx.background_spawn(async move {
|
||||||
|
let client = nostr_client();
|
||||||
|
let css = css();
|
||||||
|
let mut relays: Vec<RelayUrl> = vec![];
|
||||||
|
|
||||||
|
let filter = Filter::new()
|
||||||
|
.kind(Kind::ApplicationSpecificData)
|
||||||
|
.event(id)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
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() {
|
||||||
|
relays.extend(urls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(relays)
|
||||||
|
});
|
||||||
|
|
||||||
|
cx.spawn_in(window, async move |_, cx| {
|
||||||
|
if let Ok(urls) = task.await {
|
||||||
|
cx.update(|window, cx| {
|
||||||
|
window.open_modal(cx, move |this, _window, cx| {
|
||||||
|
this.title(shared_t!("common.seen_on")).child(
|
||||||
|
v_flex().pb_4().gap_2().children({
|
||||||
|
let mut items = Vec::with_capacity(urls.len());
|
||||||
|
|
||||||
|
for url in urls.clone().into_iter() {
|
||||||
|
items.push(
|
||||||
|
h_flex()
|
||||||
|
.h_8()
|
||||||
|
.px_2()
|
||||||
|
.bg(cx.theme().elevated_surface_background)
|
||||||
|
.rounded(cx.theme().radius)
|
||||||
|
.font_semibold()
|
||||||
|
.text_xs()
|
||||||
|
.child(url.to_string()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
items
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Panel for Chat {
|
impl Panel for Chat {
|
||||||
@@ -1179,6 +1359,7 @@ impl Focusable for Chat {
|
|||||||
impl Render for Chat {
|
impl Render for Chat {
|
||||||
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 {
|
||||||
v_flex()
|
v_flex()
|
||||||
|
.on_action(cx.listener(Self::on_open_seen_on))
|
||||||
.image_cache(self.image_cache.clone())
|
.image_cache(self.image_cache.clone())
|
||||||
.size_full()
|
.size_full()
|
||||||
.child(
|
.child(
|
||||||
@@ -1196,6 +1377,9 @@ impl Render for Chat {
|
|||||||
|
|
||||||
this.render_message(ix, rendered, text, cx)
|
this.render_message(ix, rendered, text, cx)
|
||||||
}
|
}
|
||||||
|
Message::Warning(content, _) => {
|
||||||
|
this.render_warning(ix, content.to_owned(), cx)
|
||||||
|
}
|
||||||
Message::System(_) => this.render_announcement(ix, cx),
|
Message::System(_) => this.render_announcement(ix, cx),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use smallvec::{smallvec, SmallVec};
|
|||||||
use smol::Timer;
|
use smol::Timer;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::input::{InputEvent, InputState, TextInput};
|
use ui::input::{InputEvent, InputState, TextInput};
|
||||||
use ui::notification::Notification;
|
use ui::notification::Notification;
|
||||||
use ui::{h_flex, v_flex, ContextModal, Disableable, Icon, IconName, Sizable, StyledExt};
|
use ui::{h_flex, v_flex, ContextModal, Disableable, Icon, IconName, Sizable, StyledExt};
|
||||||
@@ -34,7 +34,7 @@ pub fn compose_button() -> impl IntoElement {
|
|||||||
.ghost_alt()
|
.ghost_alt()
|
||||||
.cta()
|
.cta()
|
||||||
.small()
|
.small()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(move |_, window, cx| {
|
.on_click(move |_, window, cx| {
|
||||||
let compose = cx.new(|cx| Compose::new(window, cx));
|
let compose = cx.new(|cx| Compose::new(window, cx));
|
||||||
let title = SharedString::new(t!("sidebar.direct_messages"));
|
let title = SharedString::new(t!("sidebar.direct_messages"));
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use settings::AppSettings;
|
|||||||
use smol::fs;
|
use smol::fs;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::dock_area::panel::{Panel, PanelEvent};
|
use ui::dock_area::panel::{Panel, PanelEvent};
|
||||||
use ui::input::{InputState, TextInput};
|
use ui::input::{InputState, TextInput};
|
||||||
use ui::modal::ModalButtonProps;
|
use ui::modal::ModalButtonProps;
|
||||||
@@ -352,7 +352,7 @@ impl Render for NewAccount {
|
|||||||
.label(t!("common.upload"))
|
.label(t!("common.upload"))
|
||||||
.ghost()
|
.ghost()
|
||||||
.small()
|
.small()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.disabled(self.submitting || self.uploading)
|
.disabled(self.submitting || self.uploading)
|
||||||
.loading(self.uploading)
|
.loading(self.uploading)
|
||||||
.on_click(cx.listener(move |this, _, window, cx| {
|
.on_click(cx.listener(move |this, _, window, cx| {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use registry::Registry;
|
|||||||
use settings::AppSettings;
|
use settings::AppSettings;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::input::{InputState, TextInput};
|
use ui::input::{InputState, TextInput};
|
||||||
use ui::modal::ModalButtonProps;
|
use ui::modal::ModalButtonProps;
|
||||||
use ui::switch::Switch;
|
use ui::switch::Switch;
|
||||||
@@ -169,7 +169,7 @@ impl Render for Preferences {
|
|||||||
.label("Messaging Relays")
|
.label("Messaging Relays")
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost_alt()
|
.ghost_alt()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
this.open_relays(window, cx);
|
this.open_relays(window, cx);
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use settings::AppSettings;
|
|||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::avatar::Avatar;
|
use ui::avatar::Avatar;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::indicator::Indicator;
|
use ui::indicator::Indicator;
|
||||||
use ui::{h_flex, v_flex, ContextModal, Icon, IconName, Sizable, StyledExt};
|
use ui::{h_flex, v_flex, ContextModal, Icon, IconName, Sizable, StyledExt};
|
||||||
|
|
||||||
@@ -29,10 +29,9 @@ pub struct Screening {
|
|||||||
profile: Profile,
|
profile: Profile,
|
||||||
verified: bool,
|
verified: bool,
|
||||||
followed: bool,
|
followed: bool,
|
||||||
dm_relays: Option<bool>,
|
|
||||||
last_active: Option<Timestamp>,
|
last_active: Option<Timestamp>,
|
||||||
mutual_contacts: Vec<Profile>,
|
mutual_contacts: Vec<Profile>,
|
||||||
_tasks: SmallVec<[Task<()>; 4]>,
|
_tasks: SmallVec<[Task<()>; 3]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Screening {
|
impl Screening {
|
||||||
@@ -83,24 +82,6 @@ impl Screening {
|
|||||||
activity
|
activity
|
||||||
});
|
});
|
||||||
|
|
||||||
let relay_check = cx.background_spawn(async move {
|
|
||||||
let client = nostr_client();
|
|
||||||
let mut relay = false;
|
|
||||||
|
|
||||||
let filter = Filter::new()
|
|
||||||
.kind(Kind::InboxRelays)
|
|
||||||
.author(public_key)
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if let Ok(mut stream) = client.stream_events(filter, Duration::from_secs(2)).await {
|
|
||||||
while stream.next().await.is_some() {
|
|
||||||
relay = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
relay
|
|
||||||
});
|
|
||||||
|
|
||||||
let addr_check = if let Some(address) = profile.metadata().nip05 {
|
let addr_check = if let Some(address) = profile.metadata().nip05 {
|
||||||
Some(Tokio::spawn(cx, async move {
|
Some(Tokio::spawn(cx, async move {
|
||||||
nip05_verify(public_key, &address).await.unwrap_or(false)
|
nip05_verify(public_key, &address).await.unwrap_or(false)
|
||||||
@@ -136,19 +117,6 @@ impl Screening {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
tasks.push(
|
|
||||||
// Run the relay check in the background
|
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
|
||||||
let relay = relay_check.await;
|
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.dm_relays = Some(relay);
|
|
||||||
cx.notify();
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
tasks.push(
|
tasks.push(
|
||||||
// Run the NIP-05 verification in the background
|
// Run the NIP-05 verification in the background
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
@@ -168,7 +136,6 @@ impl Screening {
|
|||||||
profile,
|
profile,
|
||||||
verified: false,
|
verified: false,
|
||||||
followed: false,
|
followed: false,
|
||||||
dm_relays: None,
|
|
||||||
last_active: None,
|
last_active: None,
|
||||||
mutual_contacts: vec![],
|
mutual_contacts: vec![],
|
||||||
_tasks: tasks,
|
_tasks: tasks,
|
||||||
@@ -301,7 +268,7 @@ impl Render for Screening {
|
|||||||
.label(t!("profile.njump"))
|
.label(t!("profile.njump"))
|
||||||
.secondary()
|
.secondary()
|
||||||
.small()
|
.small()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
this.open_njump(window, cx);
|
this.open_njump(window, cx);
|
||||||
})),
|
})),
|
||||||
@@ -311,7 +278,7 @@ impl Render for Screening {
|
|||||||
.tooltip(t!("screening.report"))
|
.tooltip(t!("screening.report"))
|
||||||
.icon(IconName::Report)
|
.icon(IconName::Report)
|
||||||
.danger()
|
.danger()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
this.report(window, cx);
|
this.report(window, cx);
|
||||||
})),
|
})),
|
||||||
@@ -363,7 +330,7 @@ impl Render for Screening {
|
|||||||
.icon(IconName::Info)
|
.icon(IconName::Info)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost()
|
.ghost()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.tooltip(t!("screening.active_tooltip")),
|
.tooltip(t!("screening.active_tooltip")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -435,7 +402,7 @@ impl Render for Screening {
|
|||||||
.icon(IconName::Info)
|
.icon(IconName::Info)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost()
|
.ghost()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(cx.listener(
|
.on_click(cx.listener(
|
||||||
move |this, _, window, cx| {
|
move |this, _, window, cx| {
|
||||||
this.mutual_contacts(window, cx);
|
this.mutual_contacts(window, cx);
|
||||||
@@ -456,37 +423,6 @@ impl Render for Screening {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
|
||||||
.child(
|
|
||||||
h_flex()
|
|
||||||
.items_start()
|
|
||||||
.gap_2()
|
|
||||||
.child(status_badge(self.dm_relays, cx))
|
|
||||||
.child(
|
|
||||||
v_flex()
|
|
||||||
.w_full()
|
|
||||||
.text_sm()
|
|
||||||
.child({
|
|
||||||
if self.dm_relays == Some(true) {
|
|
||||||
shared_t!("screening.relay_found")
|
|
||||||
} else {
|
|
||||||
shared_t!("screening.relay_empty")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.w_full()
|
|
||||||
.line_clamp(1)
|
|
||||||
.text_color(cx.theme().text_muted)
|
|
||||||
.child({
|
|
||||||
if self.dm_relays == Some(true) {
|
|
||||||
shared_t!("screening.relay_found_desc")
|
|
||||||
} else {
|
|
||||||
shared_t!("screening.relay_empty_desc")
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use nostr_sdk::prelude::*;
|
|||||||
use registry::Registry;
|
use registry::Registry;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::input::{InputEvent, InputState, TextInput};
|
use ui::input::{InputEvent, InputState, TextInput};
|
||||||
use ui::modal::ModalButtonProps;
|
use ui::modal::ModalButtonProps;
|
||||||
use ui::{h_flex, v_flex, ContextModal, IconName, Sizable, StyledExt};
|
use ui::{h_flex, v_flex, ContextModal, IconName, Sizable, StyledExt};
|
||||||
@@ -33,7 +33,7 @@ where
|
|||||||
.label(label)
|
.label(label)
|
||||||
.warning()
|
.warning()
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.on_click(move |_, window, cx| {
|
.on_click(move |_, window, cx| {
|
||||||
let view = cx.new(|cx| SetupRelay::new(Kind::InboxRelays, window, cx));
|
let view = cx.new(|cx| SetupRelay::new(Kind::InboxRelays, window, cx));
|
||||||
let weak_view = view.downgrade();
|
let weak_view = view.downgrade();
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ use global::constants::{BOOTSTRAP_RELAYS, SEARCH_RELAYS};
|
|||||||
use global::{css, nostr_client, UnwrappingStatus};
|
use global::{css, nostr_client, UnwrappingStatus};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, uniform_list, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle,
|
div, relative, uniform_list, AnyElement, App, AppContext, Context, Entity, EventEmitter,
|
||||||
Focusable, InteractiveElement, IntoElement, ParentElement, Render, RetainAllImageCache,
|
FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render,
|
||||||
SharedString, Styled, Subscription, Task, Window,
|
RetainAllImageCache, SharedString, Styled, Subscription, Task, Window,
|
||||||
};
|
};
|
||||||
use gpui_tokio::Tokio;
|
use gpui_tokio::Tokio;
|
||||||
use i18n::{shared_t, t};
|
use i18n::{shared_t, t};
|
||||||
@@ -23,7 +23,7 @@ use registry::{Registry, RegistryEvent};
|
|||||||
use settings::AppSettings;
|
use settings::AppSettings;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
use ui::button::{Button, ButtonVariants};
|
||||||
use ui::dock_area::panel::{Panel, PanelEvent};
|
use ui::dock_area::panel::{Panel, PanelEvent};
|
||||||
use ui::input::{InputEvent, InputState, TextInput};
|
use ui::input::{InputEvent, InputState, TextInput};
|
||||||
use ui::popup_menu::{PopupMenu, PopupMenuExt};
|
use ui::popup_menu::{PopupMenu, PopupMenuExt};
|
||||||
@@ -669,6 +669,7 @@ impl Focusable for Sidebar {
|
|||||||
impl Render for Sidebar {
|
impl Render for Sidebar {
|
||||||
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 registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
|
let loading = registry.unwrapping_status.read(cx) != &UnwrappingStatus::Complete;
|
||||||
|
|
||||||
// Get rooms from either search results or the chat registry
|
// Get rooms from either search results or the chat registry
|
||||||
let rooms = if let Some(results) = self.local_result.read(cx).as_ref() {
|
let rooms = if let Some(results) = self.local_result.read(cx).as_ref() {
|
||||||
@@ -688,7 +689,7 @@ impl Render for Sidebar {
|
|||||||
let mut total_rooms = rooms.len();
|
let mut total_rooms = rooms.len();
|
||||||
|
|
||||||
// Add 3 dummy rooms to display as skeletons
|
// Add 3 dummy rooms to display as skeletons
|
||||||
if registry.unwrapping_status.read(cx) != &UnwrappingStatus::Complete {
|
if loading {
|
||||||
total_rooms += 3
|
total_rooms += 3
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +753,7 @@ impl Render for Sidebar {
|
|||||||
.cta()
|
.cta()
|
||||||
.bold()
|
.bold()
|
||||||
.secondary()
|
.secondary()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.selected(self.filter(&RoomKind::Ongoing, cx))
|
.selected(self.filter(&RoomKind::Ongoing, cx))
|
||||||
.on_click(cx.listener(|this, _, _, cx| {
|
.on_click(cx.listener(|this, _, _, cx| {
|
||||||
this.set_filter(RoomKind::Ongoing, cx);
|
this.set_filter(RoomKind::Ongoing, cx);
|
||||||
@@ -773,7 +774,7 @@ impl Render for Sidebar {
|
|||||||
.cta()
|
.cta()
|
||||||
.bold()
|
.bold()
|
||||||
.secondary()
|
.secondary()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.selected(!self.filter(&RoomKind::Ongoing, cx))
|
.selected(!self.filter(&RoomKind::Ongoing, cx))
|
||||||
.on_click(cx.listener(|this, _, _, cx| {
|
.on_click(cx.listener(|this, _, _, cx| {
|
||||||
this.set_filter(RoomKind::default(), cx);
|
this.set_filter(RoomKind::default(), cx);
|
||||||
@@ -791,7 +792,7 @@ impl Render for Sidebar {
|
|||||||
.icon(IconName::Ellipsis)
|
.icon(IconName::Ellipsis)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost()
|
.ghost()
|
||||||
.rounded(ButtonRounded::Full)
|
.rounded()
|
||||||
.popup_menu(move |this, _window, _cx| {
|
.popup_menu(move |this, _window, _cx| {
|
||||||
this.menu(
|
this.menu(
|
||||||
t!("sidebar.reload_menu"),
|
t!("sidebar.reload_menu"),
|
||||||
@@ -805,6 +806,57 @@ impl Render for Sidebar {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.when(!loading && total_rooms == 0, |this| {
|
||||||
|
this.map(|this| {
|
||||||
|
if self.filter(&RoomKind::Ongoing, cx) {
|
||||||
|
this.child(
|
||||||
|
v_flex()
|
||||||
|
.py_2()
|
||||||
|
.gap_1p5()
|
||||||
|
.items_center()
|
||||||
|
.justify_center()
|
||||||
|
.text_center()
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.text_sm()
|
||||||
|
.font_semibold()
|
||||||
|
.line_height(relative(1.25))
|
||||||
|
.child(shared_t!("sidebar.no_conversations")),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.text_xs()
|
||||||
|
.text_color(cx.theme().text_muted)
|
||||||
|
.line_height(relative(1.25))
|
||||||
|
.child(shared_t!("sidebar.no_conversations_label")),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.child(
|
||||||
|
v_flex()
|
||||||
|
.py_2()
|
||||||
|
.gap_1p5()
|
||||||
|
.items_center()
|
||||||
|
.justify_center()
|
||||||
|
.text_center()
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.text_sm()
|
||||||
|
.font_semibold()
|
||||||
|
.line_height(relative(1.25))
|
||||||
|
.child(shared_t!("sidebar.no_requests")),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.text_xs()
|
||||||
|
.text_color(cx.theme().text_muted)
|
||||||
|
.line_height(relative(1.25))
|
||||||
|
.child(shared_t!("sidebar.no_requests_label")),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
.child(
|
.child(
|
||||||
uniform_list(
|
uniform_list(
|
||||||
"rooms",
|
"rooms",
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
div, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
div, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||||
IntoElement, ParentElement, Render, SharedString, Styled, Window,
|
InteractiveElement, IntoElement, ParentElement, Render, SharedString,
|
||||||
|
StatefulInteractiveElement, Styled, Window,
|
||||||
};
|
};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::button::Button;
|
use ui::button::Button;
|
||||||
use ui::dock_area::panel::{Panel, PanelEvent};
|
use ui::dock_area::panel::{Panel, PanelEvent};
|
||||||
use ui::popup_menu::PopupMenu;
|
use ui::popup_menu::PopupMenu;
|
||||||
use ui::StyledExt;
|
use ui::{v_flex, StyledExt};
|
||||||
|
|
||||||
pub fn init(window: &mut Window, cx: &mut App) -> Entity<Welcome> {
|
pub fn init(window: &mut Window, cx: &mut App) -> Entity<Welcome> {
|
||||||
Welcome::new(window, cx)
|
Welcome::new(window, cx)
|
||||||
@@ -14,8 +15,7 @@ pub fn init(window: &mut Window, cx: &mut App) -> Entity<Welcome> {
|
|||||||
|
|
||||||
pub struct Welcome {
|
pub struct Welcome {
|
||||||
name: SharedString,
|
name: SharedString,
|
||||||
closable: bool,
|
version: SharedString,
|
||||||
zoomable: bool,
|
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,10 +25,11 @@ impl Welcome {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn view(_window: &mut Window, cx: &mut Context<Self>) -> Self {
|
fn view(_window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
|
let version = SharedString::from(format!("Version: {}", env!("CARGO_PKG_VERSION")));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
version,
|
||||||
name: "Welcome".into(),
|
name: "Welcome".into(),
|
||||||
closable: true,
|
|
||||||
zoomable: true,
|
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,16 +40,15 @@ impl Panel for Welcome {
|
|||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn title(&self, _cx: &App) -> AnyElement {
|
fn title(&self, cx: &App) -> AnyElement {
|
||||||
"👋".into_any_element()
|
div()
|
||||||
}
|
.child(
|
||||||
|
svg()
|
||||||
fn closable(&self, _cx: &App) -> bool {
|
.path("brand/coop.svg")
|
||||||
self.closable
|
.size_4()
|
||||||
}
|
.text_color(cx.theme().element_background),
|
||||||
|
)
|
||||||
fn zoomable(&self, _cx: &App) -> bool {
|
.into_any_element()
|
||||||
self.zoomable
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn popup_menu(&self, menu: PopupMenu, _cx: &App) -> PopupMenu {
|
fn popup_menu(&self, menu: PopupMenu, _cx: &App) -> PopupMenu {
|
||||||
@@ -76,23 +76,37 @@ impl Render for Welcome {
|
|||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.child(
|
.child(
|
||||||
div()
|
v_flex()
|
||||||
.flex()
|
.gap_2()
|
||||||
.flex_col()
|
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap_1()
|
.justify_center()
|
||||||
.child(
|
.child(
|
||||||
svg()
|
svg()
|
||||||
.path("brand/coop.svg")
|
.path("brand/coop.svg")
|
||||||
.size_12()
|
.size_12()
|
||||||
.text_color(cx.theme().elevated_surface_background),
|
.text_color(cx.theme().elevated_surface_background),
|
||||||
)
|
)
|
||||||
|
.child(
|
||||||
|
v_flex()
|
||||||
|
.items_center()
|
||||||
|
.justify_center()
|
||||||
|
.text_center()
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.child("coop on nostr")
|
|
||||||
.text_color(cx.theme().text_placeholder)
|
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
.text_sm(),
|
.text_color(cx.theme().text_muted)
|
||||||
|
.child("coop on nostr"),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.id("version")
|
||||||
|
.text_color(cx.theme().text_placeholder)
|
||||||
|
.text_xs()
|
||||||
|
.child(self.version.clone())
|
||||||
|
.on_click(|_, _window, cx| {
|
||||||
|
cx.open_url("https://github.com/lumehq/coop/releases");
|
||||||
|
}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+75
-28
@@ -57,7 +57,7 @@ pub enum UnwrappingStatus {
|
|||||||
|
|
||||||
/// Signals sent through the global event channel to notify UI
|
/// Signals sent through the global event channel to notify UI
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Signal {
|
pub enum SignalKind {
|
||||||
/// A signal to notify UI that the client's signer has been set
|
/// A signal to notify UI that the client's signer has been set
|
||||||
SignerSet(PublicKey),
|
SignerSet(PublicKey),
|
||||||
|
|
||||||
@@ -71,25 +71,54 @@ pub enum Signal {
|
|||||||
ProxyDown,
|
ProxyDown,
|
||||||
|
|
||||||
/// A signal to notify UI that a new profile has been received
|
/// A signal to notify UI that a new profile has been received
|
||||||
Metadata(Profile),
|
NewProfile(Profile),
|
||||||
|
|
||||||
/// A signal to notify UI that a new gift wrap event has been received
|
/// A signal to notify UI that a new gift wrap event has been received
|
||||||
Message((EventId, Event)),
|
NewMessage((EventId, Event)),
|
||||||
|
|
||||||
/// A signal to notify UI that gift wrap process status has changed
|
/// A signal to notify UI that no DM relays for current user was found
|
||||||
GiftWrapProcess(UnwrappingStatus),
|
RelaysNotFound,
|
||||||
|
|
||||||
/// A signal to notify UI that no DM relay for current user was found
|
/// A signal to notify UI that gift wrap status has changed
|
||||||
DmRelayNotFound,
|
GiftWrapStatus(UnwrappingStatus),
|
||||||
|
|
||||||
/// A signal to notify UI that there are errors or notices occurred
|
/// A signal to notify UI that there are errors or notices occurred
|
||||||
Notice(Notice),
|
Notice(Notice),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Signal {
|
||||||
|
rx: Receiver<SignalKind>,
|
||||||
|
tx: Sender<SignalKind>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Signal {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Signal {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let (tx, rx) = flume::bounded::<SignalKind>(2048);
|
||||||
|
Self { rx, tx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn receiver(&self) -> &Receiver<SignalKind> {
|
||||||
|
&self.rx
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send(&self, kind: SignalKind) {
|
||||||
|
if let Err(e) = self.tx.send_async(kind).await {
|
||||||
|
log::error!("Failed to send signal: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Ingester {
|
pub struct Ingester {
|
||||||
rx: Receiver<Signal>,
|
rx: Receiver<PublicKey>,
|
||||||
tx: Sender<Signal>,
|
tx: Sender<PublicKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Ingester {
|
impl Default for Ingester {
|
||||||
@@ -100,31 +129,47 @@ impl Default for Ingester {
|
|||||||
|
|
||||||
impl Ingester {
|
impl Ingester {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (tx, rx) = flume::bounded::<Signal>(2048);
|
let (tx, rx) = flume::bounded::<PublicKey>(1024);
|
||||||
Self { rx, tx }
|
Self { rx, tx }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signals(&self) -> &Receiver<Signal> {
|
pub fn receiver(&self) -> &Receiver<PublicKey> {
|
||||||
&self.rx
|
&self.rx
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send(&self, signal: Signal) {
|
pub async fn send(&self, public_key: PublicKey) {
|
||||||
if let Err(e) = self.tx.send_async(signal).await {
|
if let Err(e) = self.tx.send_async(public_key).await {
|
||||||
log::error!("Failed to send signal: {e}");
|
log::error!("Failed to send public key: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A simple storage to store all runtime states that using across the application.
|
/// A simple storage to store all states that using across the application.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CoopSimpleStorage {
|
pub struct CoopSimpleStorage {
|
||||||
pub init_at: Timestamp,
|
pub init_at: Timestamp,
|
||||||
|
|
||||||
|
pub last_used_at: Option<Timestamp>,
|
||||||
|
|
||||||
|
pub is_first_run: AtomicBool,
|
||||||
|
|
||||||
pub gift_wrap_sub_id: SubscriptionId,
|
pub gift_wrap_sub_id: SubscriptionId,
|
||||||
|
|
||||||
pub gift_wrap_processing: AtomicBool,
|
pub gift_wrap_processing: AtomicBool,
|
||||||
|
|
||||||
pub auto_close_opts: Option<SubscribeAutoCloseOptions>,
|
pub auto_close_opts: Option<SubscribeAutoCloseOptions>,
|
||||||
|
|
||||||
|
pub seen_on_relays: RwLock<HashMap<EventId, HashSet<RelayUrl>>>,
|
||||||
|
|
||||||
pub sent_ids: RwLock<HashSet<EventId>>,
|
pub sent_ids: RwLock<HashSet<EventId>>,
|
||||||
|
|
||||||
pub resent_ids: RwLock<Vec<Output<EventId>>>,
|
pub resent_ids: RwLock<Vec<Output<EventId>>>,
|
||||||
|
|
||||||
pub resend_queue: RwLock<HashMap<EventId, RelayUrl>>,
|
pub resend_queue: RwLock<HashMap<EventId, RelayUrl>>,
|
||||||
|
|
||||||
|
pub signal: Signal,
|
||||||
|
|
||||||
|
pub ingester: Ingester,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CoopSimpleStorage {
|
impl Default for CoopSimpleStorage {
|
||||||
@@ -135,13 +180,23 @@ impl Default for CoopSimpleStorage {
|
|||||||
|
|
||||||
impl CoopSimpleStorage {
|
impl CoopSimpleStorage {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
let init_at = Timestamp::now();
|
||||||
|
let first_run = first_run();
|
||||||
|
let opts = SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE);
|
||||||
|
|
||||||
|
let signal = Signal::default();
|
||||||
|
let ingester = Ingester::default();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
init_at: Timestamp::now(),
|
init_at,
|
||||||
|
signal,
|
||||||
|
ingester,
|
||||||
|
last_used_at: None,
|
||||||
|
is_first_run: AtomicBool::new(first_run),
|
||||||
gift_wrap_sub_id: SubscriptionId::new("inbox"),
|
gift_wrap_sub_id: SubscriptionId::new("inbox"),
|
||||||
gift_wrap_processing: AtomicBool::new(false),
|
gift_wrap_processing: AtomicBool::new(false),
|
||||||
auto_close_opts: Some(
|
auto_close_opts: Some(opts),
|
||||||
SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE),
|
seen_on_relays: RwLock::new(HashMap::new()),
|
||||||
),
|
|
||||||
sent_ids: RwLock::new(HashSet::new()),
|
sent_ids: RwLock::new(HashSet::new()),
|
||||||
resent_ids: RwLock::new(Vec::new()),
|
resent_ids: RwLock::new(Vec::new()),
|
||||||
resend_queue: RwLock::new(HashMap::new()),
|
resend_queue: RwLock::new(HashMap::new()),
|
||||||
@@ -150,9 +205,7 @@ impl CoopSimpleStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
|
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
|
||||||
static INGESTER: OnceLock<Ingester> = OnceLock::new();
|
|
||||||
static COOP_SIMPLE_STORAGE: OnceLock<CoopSimpleStorage> = OnceLock::new();
|
static COOP_SIMPLE_STORAGE: OnceLock<CoopSimpleStorage> = OnceLock::new();
|
||||||
static FIRST_RUN: OnceLock<bool> = OnceLock::new();
|
|
||||||
|
|
||||||
pub fn nostr_client() -> &'static Client {
|
pub fn nostr_client() -> &'static Client {
|
||||||
NOSTR_CLIENT.get_or_init(|| {
|
NOSTR_CLIENT.get_or_init(|| {
|
||||||
@@ -177,16 +230,11 @@ pub fn nostr_client() -> &'static Client {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ingester() -> &'static Ingester {
|
|
||||||
INGESTER.get_or_init(Ingester::new)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn css() -> &'static CoopSimpleStorage {
|
pub fn css() -> &'static CoopSimpleStorage {
|
||||||
COOP_SIMPLE_STORAGE.get_or_init(CoopSimpleStorage::new)
|
COOP_SIMPLE_STORAGE.get_or_init(CoopSimpleStorage::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn first_run() -> &'static bool {
|
fn first_run() -> bool {
|
||||||
FIRST_RUN.get_or_init(|| {
|
|
||||||
let flag = support_dir().join(format!(".{}-first_run", env!("CARGO_PKG_VERSION")));
|
let flag = support_dir().join(format!(".{}-first_run", env!("CARGO_PKG_VERSION")));
|
||||||
|
|
||||||
if !flag.exists() {
|
if !flag.exists() {
|
||||||
@@ -197,5 +245,4 @@ pub fn first_run() -> &'static bool {
|
|||||||
} else {
|
} else {
|
||||||
false // Not first run
|
false // Not first run
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use nostr_sdk::prelude::*;
|
|||||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
User(RenderedMessage),
|
User(RenderedMessage),
|
||||||
|
Warning(String, Timestamp),
|
||||||
System(Timestamp),
|
System(Timestamp),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,6 +14,10 @@ impl Message {
|
|||||||
Self::User(user.into())
|
Self::User(user.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn warning(content: String) -> Self {
|
||||||
|
Self::Warning(content, Timestamp::now())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn system() -> Self {
|
pub fn system() -> Self {
|
||||||
Self::System(Timestamp::default())
|
Self::System(Timestamp::default())
|
||||||
}
|
}
|
||||||
@@ -25,6 +30,11 @@ impl Ord for Message {
|
|||||||
(Message::System(a), Message::System(b)) => a.cmp(b),
|
(Message::System(a), Message::System(b)) => a.cmp(b),
|
||||||
(Message::User(a), Message::System(b)) => a.created_at.cmp(b),
|
(Message::User(a), Message::System(b)) => a.created_at.cmp(b),
|
||||||
(Message::System(a), Message::User(b)) => a.cmp(&b.created_at),
|
(Message::System(a), Message::User(b)) => a.cmp(&b.created_at),
|
||||||
|
(Message::Warning(_, a), Message::Warning(_, b)) => a.cmp(b),
|
||||||
|
(Message::Warning(_, a), Message::User(b)) => a.cmp(&b.created_at),
|
||||||
|
(Message::User(a), Message::Warning(_, b)) => a.created_at.cmp(b),
|
||||||
|
(Message::Warning(_, a), Message::System(b)) => a.cmp(b),
|
||||||
|
(Message::System(a), Message::Warning(_, b)) => a.cmp(b),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+47
-18
@@ -331,15 +331,44 @@ impl Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Connects to all members' messaging relays
|
||||||
|
pub fn connect_relays(
|
||||||
|
&self,
|
||||||
|
cx: &App,
|
||||||
|
) -> Task<Result<HashMap<PublicKey, Vec<RelayUrl>>, Error>> {
|
||||||
|
let members = self.members.clone();
|
||||||
|
|
||||||
|
cx.background_spawn(async move {
|
||||||
|
let client = nostr_client();
|
||||||
|
let timeout = Duration::from_secs(3);
|
||||||
|
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.iter() {
|
||||||
|
relays.insert(member.to_owned(), vec![]);
|
||||||
|
|
||||||
|
let filter = Filter::new()
|
||||||
|
.kind(Kind::InboxRelays)
|
||||||
|
.author(member.to_owned())
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if let Ok(mut stream) = client.stream_events(filter, timeout).await {
|
||||||
|
if let Some(event) = stream.next().await {
|
||||||
|
if processed.insert(event.id) {
|
||||||
|
let urls = nip17::extract_owned_relay_list(event).collect_vec();
|
||||||
|
relays.entry(member.to_owned()).or_default().extend(urls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(relays)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Loads all messages for this room from the database
|
/// Loads all messages for this room from the database
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
///
|
|
||||||
/// * `cx` - The App context
|
|
||||||
///
|
|
||||||
/// # Returns
|
|
||||||
///
|
|
||||||
/// A Task that resolves to Result<Vec<Event>, Error> containing all messages for this room
|
|
||||||
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();
|
||||||
|
|
||||||
@@ -365,16 +394,6 @@ impl Room {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emits a new message signal to the current room
|
|
||||||
pub fn emit_message(&self, gift_wrap_id: EventId, event: Event, cx: &mut Context<Self>) {
|
|
||||||
cx.emit(RoomSignal::NewMessage((gift_wrap_id, Box::new(event))));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Emits a signal to refresh the current room's messages.
|
|
||||||
pub fn emit_refresh(&mut self, cx: &mut Context<Self>) {
|
|
||||||
cx.emit(RoomSignal::Refresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a temporary message for optimistic updates
|
/// Creates a temporary message for optimistic updates
|
||||||
///
|
///
|
||||||
/// The event must not been published to relays.
|
/// The event must not been published to relays.
|
||||||
@@ -593,4 +612,14 @@ impl Room {
|
|||||||
Ok(resend_reports)
|
Ok(resend_reports)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Emits a new message signal to the current room
|
||||||
|
pub fn emit_message(&self, gift_wrap_id: EventId, event: Event, cx: &mut Context<Self>) {
|
||||||
|
cx.emit(RoomSignal::NewMessage((gift_wrap_id, Box::new(event))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Emits a signal to refresh the current room's messages.
|
||||||
|
pub fn emit_refresh(&mut self, cx: &mut Context<Self>) {
|
||||||
|
cx.emit(RoomSignal::Refresh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
///
|
///
|
||||||
/// Magic number: There is one extra pixel of padding on the left side due to
|
/// Magic number: There is one extra pixel of padding on the left side due to
|
||||||
/// the 1px border around the window on macOS apps.
|
/// the 1px border around the window on macOS apps.
|
||||||
pub const TRAFFIC_LIGHT_PADDING: f32 = 71.;
|
pub const TRAFFIC_LIGHT_PADDING: f32 = 80.;
|
||||||
|
|||||||
+7
-12
@@ -10,11 +10,6 @@ use crate::indicator::Indicator;
|
|||||||
use crate::tooltip::Tooltip;
|
use crate::tooltip::Tooltip;
|
||||||
use crate::{h_flex, Disableable, Icon, Selectable, Sizable, Size, StyledExt};
|
use crate::{h_flex, Disableable, Icon, Selectable, Sizable, Size, StyledExt};
|
||||||
|
|
||||||
pub enum ButtonRounded {
|
|
||||||
Normal,
|
|
||||||
Full,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct ButtonCustomVariant {
|
pub struct ButtonCustomVariant {
|
||||||
color: Hsla,
|
color: Hsla,
|
||||||
@@ -130,7 +125,7 @@ pub struct Button {
|
|||||||
children: Vec<AnyElement>,
|
children: Vec<AnyElement>,
|
||||||
|
|
||||||
variant: ButtonVariant,
|
variant: ButtonVariant,
|
||||||
rounded: ButtonRounded,
|
rounded: bool,
|
||||||
size: Size,
|
size: Size,
|
||||||
|
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
@@ -163,7 +158,7 @@ impl Button {
|
|||||||
disabled: false,
|
disabled: false,
|
||||||
selected: false,
|
selected: false,
|
||||||
variant: ButtonVariant::default(),
|
variant: ButtonVariant::default(),
|
||||||
rounded: ButtonRounded::Normal,
|
rounded: false,
|
||||||
size: Size::Medium,
|
size: Size::Medium,
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
on_click: None,
|
on_click: None,
|
||||||
@@ -177,9 +172,9 @@ impl Button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the border radius of the Button.
|
/// Make the button rounded.
|
||||||
pub fn rounded(mut self, rounded: impl Into<ButtonRounded>) -> Self {
|
pub fn rounded(mut self) -> Self {
|
||||||
self.rounded = rounded.into();
|
self.rounded = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,8 +310,8 @@ impl RenderOnce for Button {
|
|||||||
.cursor_default()
|
.cursor_default()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.map(|this| match self.rounded {
|
.map(|this| match self.rounded {
|
||||||
ButtonRounded::Normal => this.rounded(cx.theme().radius),
|
false => this.rounded(cx.theme().radius),
|
||||||
ButtonRounded::Full => this.rounded_full(),
|
true => this.rounded_full(),
|
||||||
})
|
})
|
||||||
.map(|this| {
|
.map(|this| {
|
||||||
if self.label.is_none() && self.children.is_empty() {
|
if self.label.is_none() && self.children.is_empty() {
|
||||||
|
|||||||
@@ -412,16 +412,15 @@ impl TabPanel {
|
|||||||
let is_zoomed = self.is_zoomed && state.zoomable;
|
let is_zoomed = self.is_zoomed && state.zoomable;
|
||||||
let view = cx.entity().clone();
|
let view = cx.entity().clone();
|
||||||
let build_popup_menu = move |this, cx: &App| view.read(cx).popup_menu(this, cx);
|
let build_popup_menu = move |this, cx: &App| view.read(cx).popup_menu(this, cx);
|
||||||
|
let toolbar = self.toolbar_buttons(window, cx);
|
||||||
|
let has_toolbar = !toolbar.is_empty();
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
|
.p_0p5()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.occlude()
|
.occlude()
|
||||||
.items_center()
|
.rounded_full()
|
||||||
.children(
|
.children(toolbar.into_iter().map(|btn| btn.small().ghost().rounded()))
|
||||||
self.toolbar_buttons(window, cx)
|
|
||||||
.into_iter()
|
|
||||||
.map(|btn| btn.small().ghost()),
|
|
||||||
)
|
|
||||||
.when(self.is_zoomed, |this| {
|
.when(self.is_zoomed, |this| {
|
||||||
this.child(
|
this.child(
|
||||||
Button::new("zoom")
|
Button::new("zoom")
|
||||||
@@ -434,11 +433,16 @@ impl TabPanel {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.when(has_toolbar, |this| {
|
||||||
|
this.bg(cx.theme().surface_background)
|
||||||
|
.child(div().flex_shrink_0().h_4().w_px().bg(cx.theme().border))
|
||||||
|
})
|
||||||
.child(
|
.child(
|
||||||
Button::new("menu")
|
Button::new("menu")
|
||||||
.icon(IconName::Ellipsis)
|
.icon(IconName::Ellipsis)
|
||||||
.small()
|
.small()
|
||||||
.ghost()
|
.ghost()
|
||||||
|
.rounded()
|
||||||
.popup_menu({
|
.popup_menu({
|
||||||
let zoomable = state.zoomable;
|
let zoomable = state.zoomable;
|
||||||
let closable = state.closable;
|
let closable = state.closable;
|
||||||
@@ -647,7 +651,7 @@ impl TabPanel {
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.size_full()
|
.size_full()
|
||||||
.rounded_lg()
|
.rounded_xl()
|
||||||
.shadow_sm()
|
.shadow_sm()
|
||||||
.when(cx.theme().mode.is_dark(), |this| this.shadow_lg())
|
.when(cx.theme().mode.is_dark(), |this| this.shadow_lg())
|
||||||
.bg(cx.theme().panel_background)
|
.bg(cx.theme().panel_background)
|
||||||
@@ -667,7 +671,7 @@ impl TabPanel {
|
|||||||
.p_1()
|
.p_1()
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.rounded_lg()
|
.rounded_xl()
|
||||||
.border_1()
|
.border_1()
|
||||||
.border_color(cx.theme().element_disabled)
|
.border_color(cx.theme().element_disabled)
|
||||||
.bg(cx.theme().drop_target_background)
|
.bg(cx.theme().drop_target_background)
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ pub enum IconName {
|
|||||||
Signal,
|
Signal,
|
||||||
Search,
|
Search,
|
||||||
Settings,
|
Settings,
|
||||||
|
Server,
|
||||||
SortAscending,
|
SortAscending,
|
||||||
SortDescending,
|
SortDescending,
|
||||||
Sun,
|
Sun,
|
||||||
@@ -112,6 +113,7 @@ impl IconName {
|
|||||||
Self::Signal => "icons/signal.svg",
|
Self::Signal => "icons/signal.svg",
|
||||||
Self::Search => "icons/search.svg",
|
Self::Search => "icons/search.svg",
|
||||||
Self::Settings => "icons/settings.svg",
|
Self::Settings => "icons/settings.svg",
|
||||||
|
Self::Server => "icons/server.svg",
|
||||||
Self::SortAscending => "icons/sort-ascending.svg",
|
Self::SortAscending => "icons/sort-ascending.svg",
|
||||||
Self::SortDescending => "icons/sort-descending.svg",
|
Self::SortDescending => "icons/sort-descending.svg",
|
||||||
Self::Sun => "icons/sun.svg",
|
Self::Sun => "icons/sun.svg",
|
||||||
|
|||||||
@@ -405,13 +405,14 @@ impl Render for ResizablePanel {
|
|||||||
return div();
|
return div();
|
||||||
}
|
}
|
||||||
|
|
||||||
let view = cx.entity().clone();
|
|
||||||
let total_size = self
|
let total_size = self
|
||||||
.group
|
.group
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|group| group.upgrade())
|
.and_then(|group| group.upgrade())
|
||||||
.map(|group| group.read(cx).total_size());
|
.map(|group| group.read(cx).total_size());
|
||||||
|
|
||||||
|
let view = cx.entity();
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_grow()
|
.flex_grow()
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ common:
|
|||||||
en: "Recommended:"
|
en: "Recommended:"
|
||||||
resend:
|
resend:
|
||||||
en: "Resend"
|
en: "Resend"
|
||||||
|
seen_on:
|
||||||
|
en: "Seen on"
|
||||||
|
|
||||||
auto_update:
|
auto_update:
|
||||||
updating:
|
updating:
|
||||||
@@ -399,6 +401,14 @@ sidebar:
|
|||||||
en: "Incoming new conversations"
|
en: "Incoming new conversations"
|
||||||
trusted_contacts_tooltip:
|
trusted_contacts_tooltip:
|
||||||
en: "Only show rooms from trusted contacts"
|
en: "Only show rooms from trusted contacts"
|
||||||
|
no_requests:
|
||||||
|
en: "No message requests"
|
||||||
|
no_requests_label:
|
||||||
|
en: "New message requests from people you don't know will appear here."
|
||||||
|
no_conversations:
|
||||||
|
en: "No conversations"
|
||||||
|
no_conversations_label:
|
||||||
|
en: "Start a conversation with someone to get started."
|
||||||
|
|
||||||
loading:
|
loading:
|
||||||
label:
|
label:
|
||||||
|
|||||||
Reference in New Issue
Block a user