Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
853ab7a60e |
Generated
+143
-194
@@ -87,9 +87,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.100"
|
version = "1.0.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arbitrary"
|
name = "arbitrary"
|
||||||
@@ -190,7 +190,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "assets"
|
name = "assets"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -251,9 +251,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-fs"
|
name = "async-fs"
|
||||||
version = "2.2.0"
|
version = "2.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5"
|
checksum = "09f7e37c0ed80b2a977691c47dae8625cfb21e205827106c64f7c588766b2e50"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"blocking",
|
"blocking",
|
||||||
@@ -262,11 +262,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-io"
|
name = "async-io"
|
||||||
version = "2.6.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 = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
|
checksum = "19634d6336019ef220f09fd31168ce5c184b295cbf80345437cc36094ef223ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"async-lock",
|
||||||
"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.61.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -302,9 +302,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-process"
|
name = "async-process"
|
||||||
version = "2.5.0"
|
version = "2.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75"
|
checksum = "65daa13722ad51e6ab1a1b9c01299142bc75135b337923cfa10e79bbbd669f00"
|
||||||
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.13"
|
version = "0.2.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c"
|
checksum = "f567af260ef69e1d52c2b560ce0ea230763e6fbb9214a85d768760a920e3e3c1"
|
||||||
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.61.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -428,7 +428,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auto_update"
|
name = "auto_update"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo-packager-updater",
|
"cargo-packager-updater",
|
||||||
@@ -510,9 +510,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base62"
|
name = "base62"
|
||||||
version = "2.2.3"
|
version = "2.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1adf9755786e27479693dedd3271691a92b5e242ab139cacb9fb8e7fb5381111"
|
checksum = "0104d4d8d15e458f21dcd027ea350bf38e4364954909402f4da075aca8d0f136"
|
||||||
|
dependencies = [
|
||||||
|
"rustversion",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
@@ -909,9 +912,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.38"
|
version = "1.2.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "80f41ae168f955c12fb8960b057d70d0ca153fb83182b57d86380443527be7e9"
|
checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
@@ -1026,7 +1029,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client_keys"
|
name = "client_keys"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"global",
|
"global",
|
||||||
@@ -1128,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
@@ -1163,7 +1166,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -1236,7 +1239,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coop"
|
name = "coop"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assets",
|
"assets",
|
||||||
@@ -1569,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1736,14 +1739,14 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embed-resource"
|
name = "embed-resource"
|
||||||
version = "3.0.6"
|
version = "3.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "55a075fc573c64510038d7ee9abc7990635863992f83ebc52c8b433b8411a02e"
|
checksum = "4c6d81016d6c977deefb2ef8d8290da019e27cc26167e102185da528e6c0ab38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"memchr",
|
"memchr",
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
"toml 0.9.7",
|
"toml 0.9.5",
|
||||||
"vswhom",
|
"vswhom",
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
@@ -1821,12 +1824,11 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "erased-serde"
|
name = "erased-serde"
|
||||||
version = "0.4.8"
|
version = "0.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b"
|
checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_core",
|
|
||||||
"typeid",
|
"typeid",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1973,9 +1975,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "find-msvc-tools"
|
name = "find-msvc-tools"
|
||||||
version = "0.1.2"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959"
|
checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flatbuffers"
|
name = "flatbuffers"
|
||||||
@@ -2375,7 +2377,7 @@ dependencies = [
|
|||||||
"js-sys",
|
"js-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"r-efi",
|
"r-efi",
|
||||||
"wasi 0.14.7+wasi-0.2.4",
|
"wasi 0.14.5+wasi-0.2.4",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2403,7 +2405,7 @@ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "global"
|
name = "global"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
@@ -2496,7 +2498,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui"
|
name = "gpui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
@@ -2557,6 +2559,7 @@ dependencies = [
|
|||||||
"seahash",
|
"seahash",
|
||||||
"semantic_version",
|
"semantic_version",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -2568,7 +2571,6 @@ dependencies = [
|
|||||||
"thiserror 2.0.16",
|
"thiserror 2.0.16",
|
||||||
"usvg",
|
"usvg",
|
||||||
"util",
|
"util",
|
||||||
"util_macros",
|
|
||||||
"uuid",
|
"uuid",
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
@@ -2590,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2602,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -2671,12 +2673,6 @@ dependencies = [
|
|||||||
"foldhash",
|
"foldhash",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hashbrown"
|
|
||||||
version = "0.16.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@@ -2822,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2842,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-platform-verifier",
|
"rustls-platform-verifier",
|
||||||
@@ -2919,9 +2915,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper-util"
|
name = "hyper-util"
|
||||||
version = "0.1.17"
|
version = "0.1.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8"
|
checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2945,7 +2941,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "i18n"
|
name = "i18n"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rust-i18n",
|
"rust-i18n",
|
||||||
]
|
]
|
||||||
@@ -3145,14 +3141,13 @@ checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.11.4"
|
version = "2.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
|
checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.16.0",
|
"hashbrown 0.15.5",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_core",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3340,9 +3335,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.80"
|
version = "0.3.78"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e"
|
checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
@@ -3417,12 +3412,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
version = "0.8.9"
|
version = "0.8.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-link 0.2.0",
|
"windows-targets 0.53.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3433,9 +3428,9 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libredox"
|
name = "libredox"
|
||||||
version = "0.1.10"
|
version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
|
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -3566,9 +3561,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lyon_geom"
|
name = "lyon_geom"
|
||||||
version = "1.0.17"
|
version = "1.0.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e16770d760c7848b0c1c2d209101e408207a65168109509f8483837a36cf2e7"
|
checksum = "ce9333c02ea4517fd31207f126124352ad59975218c114c55dbb8f9d56fd4b45"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"euclid",
|
"euclid",
|
||||||
@@ -3634,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bindgen 0.71.1",
|
"bindgen 0.71.1",
|
||||||
@@ -3872,9 +3867,9 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "normpath"
|
name = "normpath"
|
||||||
version = "1.5.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf23ab2b905654b4cb177e30b629937b3868311d4e1cba859f899c041046e69b"
|
checksum = "c178369371fd7db523726931e50d430b560e3059665abc537ba3277e9274c9c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.61.0",
|
"windows-sys 0.61.0",
|
||||||
]
|
]
|
||||||
@@ -3882,7 +3877,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr"
|
name = "nostr"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#418e34bcab62869c80cd86bf7c6ace1b9960b09d"
|
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"base64",
|
"base64",
|
||||||
@@ -3906,7 +3901,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-connect"
|
name = "nostr-connect"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#418e34bcab62869c80cd86bf7c6ace1b9960b09d"
|
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"nostr",
|
"nostr",
|
||||||
@@ -3918,7 +3913,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-database"
|
name = "nostr-database"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#418e34bcab62869c80cd86bf7c6ace1b9960b09d"
|
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"lru",
|
"lru",
|
||||||
@@ -3929,7 +3924,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-lmdb"
|
name = "nostr-lmdb"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#418e34bcab62869c80cd86bf7c6ace1b9960b09d"
|
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"flume",
|
"flume",
|
||||||
@@ -3943,7 +3938,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-relay-pool"
|
name = "nostr-relay-pool"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#418e34bcab62869c80cd86bf7c6ace1b9960b09d"
|
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"async-wsocket",
|
"async-wsocket",
|
||||||
@@ -3960,7 +3955,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-sdk"
|
name = "nostr-sdk"
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr#418e34bcab62869c80cd86bf7c6ace1b9960b09d"
|
source = "git+https://github.com/rust-nostr/nostr#b1016f439ef1da5f8fdeae14368f5b7340414389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"nostr",
|
"nostr",
|
||||||
@@ -4474,17 +4469,6 @@ version = "2.3.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "perf"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://github.com/zed-industries/zed#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
|
||||||
dependencies = [
|
|
||||||
"collections",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"workspace-hack",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
version = "0.11.3"
|
version = "0.11.3"
|
||||||
@@ -4610,16 +4594,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "3.11.0"
|
version = "3.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
|
checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829"
|
||||||
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.61.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4692,11 +4676,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "3.4.0"
|
version = "3.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983"
|
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"toml_edit 0.23.6",
|
"toml_edit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4760,9 +4744,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pxfm"
|
name = "pxfm"
|
||||||
version = "0.1.24"
|
version = "0.1.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83f9b339b02259ada5c0f4a389b7fb472f933aa17ce176fd2ad98f28bb401fde"
|
checksum = "f55f4fedc84ed39cb7a489322318976425e42a147e2be79d8f878e2884f94e84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
@@ -5085,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_refineable",
|
"derive_refineable",
|
||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
@@ -5122,7 +5106,7 @@ checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "registry"
|
name = "registry"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -5239,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -5451,9 +5435,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.32"
|
version = "0.23.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40"
|
checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"log",
|
"log",
|
||||||
@@ -5474,7 +5458,7 @@ dependencies = [
|
|||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework 3.5.0",
|
"security-framework 3.4.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5511,7 +5495,7 @@ dependencies = [
|
|||||||
"rustls-native-certs",
|
"rustls-native-certs",
|
||||||
"rustls-platform-verifier-android",
|
"rustls-platform-verifier-android",
|
||||||
"rustls-webpki",
|
"rustls-webpki",
|
||||||
"security-framework 3.5.0",
|
"security-framework 3.4.0",
|
||||||
"security-framework-sys",
|
"security-framework-sys",
|
||||||
"webpki-root-certs 0.26.11",
|
"webpki-root-certs 0.26.11",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
@@ -5525,9 +5509,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
version = "0.103.6"
|
version = "0.103.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb"
|
checksum = "b5a37813727b78798e53c2bec3f5e8fe12a6d6f8389bf9ca7802add4c9905ad8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"ring",
|
"ring",
|
||||||
@@ -5744,9 +5728,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework"
|
name = "security-framework"
|
||||||
version = "3.5.0"
|
version = "3.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc198e42d9b7510827939c9a15f5062a0c913f3371d765977e586d2fe6c16f4a"
|
checksum = "60b369d18893388b345804dc0007963c99b7d665ae71d275812d828c6f089640"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
"core-foundation 0.10.1",
|
"core-foundation 0.10.1",
|
||||||
@@ -5774,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -5783,34 +5767,24 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.27"
|
version = "1.0.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.226"
|
version = "1.0.219"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
|
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||||
dependencies = [
|
|
||||||
"serde_core",
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_core"
|
|
||||||
version = "1.0.226"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.226"
|
version = "1.0.219"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
|
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5839,16 +5813,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.145"
|
version = "1.0.143"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_core",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5886,11 +5859,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_spanned"
|
name = "serde_spanned"
|
||||||
version = "1.0.2"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee"
|
checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5920,7 +5893,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "settings"
|
name = "settings"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"global",
|
"global",
|
||||||
@@ -5987,7 +5960,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signer_proxy"
|
name = "signer_proxy"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"atomic-destructor",
|
"atomic-destructor",
|
||||||
@@ -6226,7 +6199,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"log",
|
"log",
|
||||||
@@ -6529,7 +6502,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theme"
|
name = "theme"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -6601,12 +6574,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.44"
|
version = "0.3.43"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d"
|
checksum = "83bde6f1ec10e72d583d91623c939f623002284ef622b87de38cfd546cbf2031"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"itoa",
|
|
||||||
"num-conv",
|
"num-conv",
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -6692,7 +6664,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "title_bar"
|
name = "title_bar"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -6750,9 +6722,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-rustls"
|
name = "tokio-rustls"
|
||||||
version = "0.26.3"
|
version = "0.26.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd"
|
checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"tokio",
|
"tokio",
|
||||||
@@ -6808,19 +6780,19 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_spanned 0.6.9",
|
"serde_spanned 0.6.9",
|
||||||
"toml_datetime 0.6.11",
|
"toml_datetime 0.6.11",
|
||||||
"toml_edit 0.22.27",
|
"toml_edit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.9.7"
|
version = "0.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0"
|
checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde_core",
|
"serde",
|
||||||
"serde_spanned 1.0.2",
|
"serde_spanned 1.0.0",
|
||||||
"toml_datetime 0.7.2",
|
"toml_datetime 0.7.0",
|
||||||
"toml_parser",
|
"toml_parser",
|
||||||
"toml_writer",
|
"toml_writer",
|
||||||
"winnow",
|
"winnow",
|
||||||
@@ -6837,11 +6809,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "0.7.2"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1"
|
checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -6858,23 +6830,11 @@ dependencies = [
|
|||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "toml_edit"
|
|
||||||
version = "0.23.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b"
|
|
||||||
dependencies = [
|
|
||||||
"indexmap",
|
|
||||||
"toml_datetime 0.7.2",
|
|
||||||
"toml_parser",
|
|
||||||
"winnow",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_parser"
|
name = "toml_parser"
|
||||||
version = "1.0.3"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627"
|
checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
@@ -6887,9 +6847,9 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_writer"
|
name = "toml_writer"
|
||||||
version = "1.0.3"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109"
|
checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower"
|
name = "tower"
|
||||||
@@ -7075,7 +7035,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ui"
|
name = "ui"
|
||||||
version = "0.2.9"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -7269,7 +7229,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#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
source = "git+https://github.com/zed-industries/zed#ded646760467d653fd57ee3ef4fc1edcfafba6ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-fs",
|
"async-fs",
|
||||||
@@ -7301,17 +7261,6 @@ dependencies = [
|
|||||||
"workspace-hack",
|
"workspace-hack",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "util_macros"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://github.com/zed-industries/zed#681a4adc42df0c93b95fd1a36a3ad47eaca086c0"
|
|
||||||
dependencies = [
|
|
||||||
"perf",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.106",
|
|
||||||
"workspace-hack",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.18.1"
|
version = "1.18.1"
|
||||||
@@ -7449,18 +7398,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.14.7+wasi-0.2.4"
|
version = "0.14.5+wasi-0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
|
checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wasip2",
|
"wasip2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasip2"
|
name = "wasip2"
|
||||||
version = "1.0.1+wasi-0.2.4"
|
version = "1.0.0+wasi-0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
|
checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wit-bindgen",
|
"wit-bindgen",
|
||||||
]
|
]
|
||||||
@@ -7473,9 +7422,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.103"
|
version = "0.2.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819"
|
checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@@ -7486,9 +7435,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.103"
|
version = "0.2.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c"
|
checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"log",
|
"log",
|
||||||
@@ -7500,9 +7449,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-futures"
|
name = "wasm-bindgen-futures"
|
||||||
version = "0.4.53"
|
version = "0.4.51"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0b221ff421256839509adbb55998214a70d829d3a28c69b4a6672e9d2a42f67"
|
checksum = "0ca85039a9b469b38336411d6d6ced91f3fc87109a2a27b0c197663f5144dffe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
@@ -7513,9 +7462,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.103"
|
version = "0.2.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0"
|
checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
@@ -7523,9 +7472,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.103"
|
version = "0.2.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32"
|
checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -7536,9 +7485,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.103"
|
version = "0.2.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf"
|
checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -7643,9 +7592,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.80"
|
version = "0.3.78"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fbe734895e869dc429d78c4b433f8d17d95f8d05317440b4fad5ab2d33e596dc"
|
checksum = "77e4b637749ff0d92b8fad63aa1f7cff3cbe125fd49c175cd6345e7272638b12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
@@ -8333,9 +8282,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen"
|
name = "wit-bindgen"
|
||||||
version = "0.46.0"
|
version = "0.45.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "workspace-hack"
|
name = "workspace-hack"
|
||||||
@@ -8391,9 +8340,9 @@ checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xattr"
|
name = "xattr"
|
||||||
version = "1.6.1"
|
version = "1.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156"
|
checksum = "af3a19837351dc82ba89f8a125e22a3c475f05aba604acc023d62b2739ae2909"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
|
|||||||
+1
-5
@@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||||||
default-members = ["crates/coop"]
|
default-members = ["crates/coop"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.9"
|
version = "0.2.7"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
@@ -58,7 +58,3 @@ opt-level = "z"
|
|||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[profile.profiling]
|
|
||||||
inherits = "release"
|
|
||||||
debug = true
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,4 +0,0 @@
|
|||||||
<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>
|
|
||||||
|
Before Width: | Height: | Size: 486 B |
@@ -1,7 +1,5 @@
|
|||||||
use std::sync::atomic::Ordering;
|
|
||||||
|
|
||||||
use global::app_state;
|
|
||||||
use global::constants::KEYRING_URL;
|
use global::constants::KEYRING_URL;
|
||||||
|
use global::first_run;
|
||||||
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};
|
||||||
@@ -61,7 +59,6 @@ impl ClientKeys {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let app_state = app_state();
|
|
||||||
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| {
|
||||||
@@ -76,7 +73,7 @@ impl ClientKeys {
|
|||||||
this.set_keys(Some(keys), false, true, cx);
|
this.set_keys(Some(keys), false, true, cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
} else if app_state.is_first_run.load(Ordering::Acquire) {
|
} else if *first_run() {
|
||||||
// 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);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use chrono::{Local, TimeZone};
|
use chrono::{Local, TimeZone};
|
||||||
use global::constants::IMAGE_RESIZE_SERVICE;
|
use global::constants::IMAGE_RESIZE_SERVICE;
|
||||||
use gpui::{Image, ImageFormat, SharedString, SharedUri};
|
use gpui::{Image, ImageFormat};
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use qrcode::render::svg;
|
use qrcode::render::svg;
|
||||||
use qrcode::QrCode;
|
use qrcode::QrCode;
|
||||||
@@ -15,92 +15,87 @@ const HOURS_IN_DAY: i64 = 24;
|
|||||||
const DAYS_IN_MONTH: i64 = 30;
|
const DAYS_IN_MONTH: i64 = 30;
|
||||||
const FALLBACK_IMG: &str = "https://image.nostr.build/c30703b48f511c293a9003be8100cdad37b8798b77a1dc3ec6eb8a20443d5dea.png";
|
const FALLBACK_IMG: &str = "https://image.nostr.build/c30703b48f511c293a9003be8100cdad37b8798b77a1dc3ec6eb8a20443d5dea.png";
|
||||||
|
|
||||||
pub trait RenderedProfile {
|
pub trait ReadableProfile {
|
||||||
fn avatar(&self, proxy: bool) -> SharedUri;
|
fn avatar_url(&self, proxy: bool) -> String;
|
||||||
fn display_name(&self) -> SharedString;
|
fn display_name(&self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderedProfile for Profile {
|
impl ReadableProfile for Profile {
|
||||||
fn avatar(&self, proxy: bool) -> SharedUri {
|
fn avatar_url(&self, proxy: bool) -> String {
|
||||||
self.metadata()
|
self.metadata()
|
||||||
.picture
|
.picture
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.filter(|picture| !picture.is_empty())
|
.filter(|picture| !picture.is_empty())
|
||||||
.map(|picture| {
|
.map(|picture| {
|
||||||
if proxy {
|
if proxy {
|
||||||
let url = format!(
|
format!(
|
||||||
"{IMAGE_RESIZE_SERVICE}/?url={picture}&w=100&h=100&fit=cover&mask=circle&default={FALLBACK_IMG}&n=-1"
|
"{IMAGE_RESIZE_SERVICE}/?url={picture}&w=100&h=100&fit=cover&mask=circle&default={FALLBACK_IMG}&n=-1"
|
||||||
);
|
)
|
||||||
|
|
||||||
SharedUri::from(url)
|
|
||||||
} else {
|
} else {
|
||||||
SharedUri::from(picture)
|
picture.into()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| SharedUri::from("brand/avatar.png"))
|
.unwrap_or_else(|| "brand/avatar.png".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_name(&self) -> SharedString {
|
fn display_name(&self) -> String {
|
||||||
if let Some(display_name) = self.metadata().display_name.as_ref() {
|
if let Some(display_name) = self.metadata().display_name.as_ref() {
|
||||||
if !display_name.is_empty() {
|
if !display_name.is_empty() {
|
||||||
return SharedString::from(display_name);
|
return display_name.into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = self.metadata().name.as_ref() {
|
if let Some(name) = self.metadata().name.as_ref() {
|
||||||
if !name.is_empty() {
|
if !name.is_empty() {
|
||||||
return SharedString::from(name);
|
return name.into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedString::from(shorten_pubkey(self.public_key(), 4))
|
shorten_pubkey(self.public_key(), 4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait RenderedTimestamp {
|
pub trait ReadableTimestamp {
|
||||||
fn to_human_time(&self) -> SharedString;
|
fn to_human_time(&self) -> String;
|
||||||
fn to_ago(&self) -> SharedString;
|
fn to_ago(&self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderedTimestamp for Timestamp {
|
impl ReadableTimestamp for Timestamp {
|
||||||
fn to_human_time(&self) -> SharedString {
|
fn to_human_time(&self) -> String {
|
||||||
let input_time = match Local.timestamp_opt(self.as_u64() as i64, 0) {
|
let input_time = match Local.timestamp_opt(self.as_u64() as i64, 0) {
|
||||||
chrono::LocalResult::Single(time) => time,
|
chrono::LocalResult::Single(time) => time,
|
||||||
_ => return SharedString::from("9999"),
|
_ => return "9999".into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let input_date = input_time.date_naive();
|
let input_date = input_time.date_naive();
|
||||||
let now_date = now.date_naive();
|
let now_date = now.date_naive();
|
||||||
let yesterday_date = (now - chrono::Duration::days(1)).date_naive();
|
let yesterday_date = (now - chrono::Duration::days(1)).date_naive();
|
||||||
|
|
||||||
let time_format = input_time.format("%H:%M %p");
|
let time_format = input_time.format("%H:%M %p");
|
||||||
|
|
||||||
match input_date {
|
match input_date {
|
||||||
date if date == now_date => SharedString::from(format!("Today at {time_format}")),
|
date if date == now_date => format!("Today at {time_format}"),
|
||||||
date if date == yesterday_date => {
|
date if date == yesterday_date => format!("Yesterday at {time_format}"),
|
||||||
SharedString::from(format!("Yesterday at {time_format}"))
|
_ => format!("{}, {time_format}", input_time.format("%d/%m/%y")),
|
||||||
}
|
|
||||||
_ => SharedString::from(format!("{}, {time_format}", input_time.format("%d/%m/%y"))),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_ago(&self) -> SharedString {
|
fn to_ago(&self) -> String {
|
||||||
let input_time = match Local.timestamp_opt(self.as_u64() as i64, 0) {
|
let input_time = match Local.timestamp_opt(self.as_u64() as i64, 0) {
|
||||||
chrono::LocalResult::Single(time) => time,
|
chrono::LocalResult::Single(time) => time,
|
||||||
_ => return SharedString::from("1m"),
|
_ => return "1m".into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let duration = now.signed_duration_since(input_time);
|
let duration = now.signed_duration_since(input_time);
|
||||||
|
|
||||||
match duration {
|
match duration {
|
||||||
d if d.num_seconds() < SECONDS_IN_MINUTE => SharedString::from(NOW),
|
d if d.num_seconds() < SECONDS_IN_MINUTE => NOW.into(),
|
||||||
d if d.num_minutes() < MINUTES_IN_HOUR => {
|
d if d.num_minutes() < MINUTES_IN_HOUR => format!("{}m", d.num_minutes()),
|
||||||
SharedString::from(format!("{}m", d.num_minutes()))
|
d if d.num_hours() < HOURS_IN_DAY => format!("{}h", d.num_hours()),
|
||||||
}
|
d if d.num_days() < DAYS_IN_MONTH => format!("{}d", d.num_days()),
|
||||||
d if d.num_hours() < HOURS_IN_DAY => SharedString::from(format!("{}h", d.num_hours())),
|
_ => input_time.format("%b %d").to_string(),
|
||||||
d if d.num_days() < DAYS_IN_MONTH => SharedString::from(format!("{}d", d.num_days())),
|
|
||||||
_ => SharedString::from(input_time.format("%b %d").to_string()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,39 +45,3 @@ impl EventUtils for Event {
|
|||||||
a == b
|
a == b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventUtils for UnsignedEvent {
|
|
||||||
fn uniq_id(&self) -> u64 {
|
|
||||||
let mut hasher = DefaultHasher::new();
|
|
||||||
let mut pubkeys: Vec<PublicKey> = vec![];
|
|
||||||
|
|
||||||
// Add all public keys from event
|
|
||||||
pubkeys.push(self.pubkey);
|
|
||||||
pubkeys.extend(self.tags.public_keys().collect::<Vec<_>>());
|
|
||||||
|
|
||||||
// Generate unique hash
|
|
||||||
pubkeys
|
|
||||||
.into_iter()
|
|
||||||
.unique()
|
|
||||||
.sorted()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.hash(&mut hasher);
|
|
||||||
|
|
||||||
hasher.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn all_pubkeys(&self) -> Vec<PublicKey> {
|
|
||||||
let mut public_keys: Vec<PublicKey> = self.tags.public_keys().copied().collect();
|
|
||||||
public_keys.push(self.pubkey);
|
|
||||||
|
|
||||||
public_keys
|
|
||||||
}
|
|
||||||
|
|
||||||
fn compare_pubkeys(&self, other: &[PublicKey]) -> bool {
|
|
||||||
let pubkeys = self.all_pubkeys();
|
|
||||||
let a: HashSet<_> = pubkeys.iter().collect();
|
|
||||||
let b: HashSet<_> = other.iter().collect();
|
|
||||||
|
|
||||||
a == b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
use nostr_connect::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct CoopAuthUrlHandler;
|
||||||
|
|
||||||
|
impl AuthUrlHandler for CoopAuthUrlHandler {
|
||||||
|
fn on_auth_url(&self, auth_url: Url) -> BoxedFuture<Result<()>> {
|
||||||
|
Box::pin(async move {
|
||||||
|
log::info!("Received Auth URL: {auth_url}");
|
||||||
|
webbrowser::open(auth_url.as_str())?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod debounced_delay;
|
pub mod debounced_delay;
|
||||||
pub mod display;
|
pub mod display;
|
||||||
pub mod event;
|
pub mod event;
|
||||||
|
pub mod handle_auth;
|
||||||
pub mod nip05;
|
pub mod nip05;
|
||||||
pub mod nip96;
|
pub mod nip96;
|
||||||
|
|||||||
@@ -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.9"
|
version = "0.2.7"
|
||||||
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"]
|
||||||
@@ -62,5 +62,5 @@ oneshot.workspace = true
|
|||||||
flume.workspace = true
|
flume.workspace = true
|
||||||
webbrowser.workspace = true
|
webbrowser.workspace = true
|
||||||
|
|
||||||
indexset = "0.12.3"
|
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
|
tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
|
||||||
|
indexset = "0.12.3"
|
||||||
|
|||||||
@@ -1,24 +1,10 @@
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use gpui::{actions, App};
|
use gpui::{actions, App};
|
||||||
use nostr_connect::prelude::*;
|
|
||||||
|
|
||||||
actions!(coop, [ReloadMetadata, DarkMode, Settings, Logout, Quit]);
|
actions!(coop, [ReloadMetadata, DarkMode, Settings, Logout, Quit]);
|
||||||
actions!(sidebar, [Reload, RelayStatus]);
|
actions!(sidebar, [Reload, RelayStatus]);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct CoopAuthUrlHandler;
|
|
||||||
|
|
||||||
impl AuthUrlHandler for CoopAuthUrlHandler {
|
|
||||||
fn on_auth_url(&self, auth_url: Url) -> BoxedFuture<Result<()>> {
|
|
||||||
Box::pin(async move {
|
|
||||||
log::info!("Received Auth URL: {auth_url}");
|
|
||||||
webbrowser::open(auth_url.as_str())?;
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn load_embedded_fonts(cx: &App) {
|
pub fn load_embedded_fonts(cx: &App) {
|
||||||
let asset_source = cx.asset_source();
|
let asset_source = cx.asset_source();
|
||||||
let font_paths = asset_source.list("fonts").unwrap();
|
let font_paths = asset_source.list("fonts").unwrap();
|
||||||
|
|||||||
+151
-191
@@ -7,18 +7,19 @@ use std::time::Duration;
|
|||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use auto_update::AutoUpdater;
|
use auto_update::AutoUpdater;
|
||||||
use client_keys::ClientKeys;
|
use client_keys::ClientKeys;
|
||||||
use common::display::RenderedProfile;
|
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::{app_state, nostr_client, AuthRequest, Notice, SignalKind, UnwrappingStatus};
|
use global::{css, ingester, nostr_client, AuthRequest, Notice, Signal, UnwrappingStatus};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
deferred, div, px, rems, App, AppContext, AsyncWindowContext, Axis, Context, Entity,
|
div, px, rems, App, AppContext, AsyncWindowContext, Axis, Context, Entity, InteractiveElement,
|
||||||
InteractiveElement, IntoElement, ParentElement, Render, SharedString,
|
IntoElement, ParentElement, Render, SharedString, StatefulInteractiveElement, Styled,
|
||||||
StatefulInteractiveElement, Styled, Subscription, Task, WeakEntity, Window,
|
Subscription, Task, WeakEntity, Window,
|
||||||
};
|
};
|
||||||
use i18n::{shared_t, t};
|
use i18n::{shared_t, t};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@@ -70,13 +71,13 @@ pub struct ChatSpace {
|
|||||||
dock: Entity<DockArea>,
|
dock: Entity<DockArea>,
|
||||||
|
|
||||||
// All authentication requests
|
// All authentication requests
|
||||||
auth_requests: Entity<HashMap<RelayUrl, AuthRequest>>,
|
auth_requests: HashMap<RelayUrl, AuthRequest>,
|
||||||
|
|
||||||
// Local state to determine if the user has set up NIP-17 relays
|
// Local state to determine if the user has set up NIP-17 relays
|
||||||
nip17_relays: bool,
|
nip17_relays: bool,
|
||||||
|
|
||||||
// All subscriptions for observing the app state
|
// All subscriptions for observing the app state
|
||||||
_subscriptions: SmallVec<[Subscription; 4]>,
|
_subscriptions: SmallVec<[Subscription; 3]>,
|
||||||
|
|
||||||
// All long running tasks
|
// All long running tasks
|
||||||
_tasks: SmallVec<[Task<()>; 5]>,
|
_tasks: SmallVec<[Task<()>; 5]>,
|
||||||
@@ -90,18 +91,11 @@ 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 auth_requests = cx.new(|_| HashMap::new());
|
|
||||||
|
|
||||||
|
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![];
|
||||||
|
|
||||||
subscriptions.push(
|
|
||||||
// Automatically sync theme with system appearance
|
|
||||||
window.observe_window_appearance(|window, cx| {
|
|
||||||
Theme::sync_system_appearance(Some(window), cx);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
subscriptions.push(
|
subscriptions.push(
|
||||||
// Observe the client keys and show an alert modal if they fail to initialize
|
// Observe the client keys and show an alert modal if they fail to initialize
|
||||||
cx.observe_in(&client_keys, window, |this, keys, window, cx| {
|
cx.observe_in(&client_keys, window, |this, keys, window, cx| {
|
||||||
@@ -153,7 +147,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()
|
Self::process_nostr_events(&pubkey_tx)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to handle nostr events. Please restart the application.");
|
.expect("Failed to handle nostr events. Please restart the application.");
|
||||||
}),
|
}),
|
||||||
@@ -177,7 +171,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().await;
|
Self::process_batching_metadata(&pubkey_rx).await;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -191,7 +185,7 @@ impl ChatSpace {
|
|||||||
Self {
|
Self {
|
||||||
dock,
|
dock,
|
||||||
title_bar,
|
title_bar,
|
||||||
auth_requests,
|
auth_requests: HashMap::new(),
|
||||||
nip17_relays: true,
|
nip17_relays: true,
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
_tasks: tasks,
|
_tasks: tasks,
|
||||||
@@ -221,7 +215,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
async fn observe_signer() {
|
async fn observe_signer() {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let ingester = ingester();
|
||||||
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);
|
||||||
|
|
||||||
@@ -237,10 +231,7 @@ impl ChatSpace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Notify the app that the signer has been set.
|
// Notify the app that the signer has been set.
|
||||||
app_state
|
ingester.send(Signal::SignerSet(public_key)).await;
|
||||||
.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()
|
||||||
@@ -248,56 +239,44 @@ 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) => {
|
||||||
if stream.next().await.is_some() {
|
let mut processed_ids = HashSet::new();
|
||||||
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 {
|
||||||
// Timeout
|
ingester.send(Signal::DmRelayNotFound).await;
|
||||||
app_state.signal.send(SignalKind::RelaysNotFound).await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Error fetching NIP-65 Relay: {e:?}");
|
log::error!("Error fetching NIP-17 Relay: {e:?}");
|
||||||
app_state.signal.send(SignalKind::RelaysNotFound).await;
|
ingester.send(Signal::DmRelayNotFound).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
|
|
||||||
app_state.signal.send(SignalKind::RelaysNotFound).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Error fetching NIP-17 Relay: {e:?}");
|
|
||||||
app_state.signal.send(SignalKind::RelaysNotFound).await;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn observe_giftwrap() {
|
async fn observe_giftwrap() {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
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;
|
||||||
@@ -306,25 +285,25 @@ impl ChatSpace {
|
|||||||
if client.has_signer().await {
|
if client.has_signer().await {
|
||||||
total_loops += 1;
|
total_loops += 1;
|
||||||
|
|
||||||
if app_state.gift_wrap_processing.load(Ordering::Acquire) {
|
if css.gift_wrap_processing.load(Ordering::Acquire) {
|
||||||
is_start_processing = true;
|
is_start_processing = true;
|
||||||
|
|
||||||
// Reset gift wrap processing flag
|
// Reset gift wrap processing flag
|
||||||
let _ = app_state.gift_wrap_processing.compare_exchange(
|
let _ = css.gift_wrap_processing.compare_exchange(
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Ordering::Release,
|
Ordering::Release,
|
||||||
Ordering::Relaxed,
|
Ordering::Relaxed,
|
||||||
);
|
);
|
||||||
|
|
||||||
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Processing);
|
let signal = Signal::GiftWrapProcess(UnwrappingStatus::Processing);
|
||||||
app_state.signal.send(signal).await;
|
ingester.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 = SignalKind::GiftWrapStatus(UnwrappingStatus::Complete);
|
let signal = Signal::GiftWrapProcess(UnwrappingStatus::Complete);
|
||||||
app_state.signal.send(signal).await;
|
ingester.send(signal).await;
|
||||||
|
|
||||||
// Reset the counter
|
// Reset the counter
|
||||||
is_start_processing = false;
|
is_start_processing = false;
|
||||||
@@ -337,8 +316,7 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_batching_metadata() {
|
async fn process_batching_metadata(rx: &Receiver<PublicKey>) {
|
||||||
let app_state = app_state();
|
|
||||||
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();
|
||||||
@@ -353,7 +331,7 @@ impl ChatSpace {
|
|||||||
loop {
|
loop {
|
||||||
let futs = smol::future::or(
|
let futs = smol::future::or(
|
||||||
async move {
|
async move {
|
||||||
if let Ok(public_key) = app_state.ingester.receiver().recv_async().await {
|
if let Ok(public_key) = rx.recv_async().await {
|
||||||
BatchEvent::PublicKey(public_key)
|
BatchEvent::PublicKey(public_key)
|
||||||
} else {
|
} else {
|
||||||
BatchEvent::Closed
|
BatchEvent::Closed
|
||||||
@@ -388,9 +366,10 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_nostr_events() -> Result<(), Error> {
|
async fn process_nostr_events(pubkey_tx: &Sender<PublicKey>) -> Result<(), Error> {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let ingester = ingester();
|
||||||
|
let css = css();
|
||||||
|
|
||||||
let mut processed_events: HashSet<EventId> = HashSet::new();
|
let mut processed_events: HashSet<EventId> = HashSet::new();
|
||||||
let mut challenges: HashSet<Cow<'_, str>> = HashSet::new();
|
let mut challenges: HashSet<Cow<'_, str>> = HashSet::new();
|
||||||
@@ -403,53 +382,12 @@ impl ChatSpace {
|
|||||||
|
|
||||||
match message {
|
match message {
|
||||||
RelayMessage::Event { event, .. } => {
|
RelayMessage::Event { event, .. } => {
|
||||||
// Keep track of which relays have seen this event
|
|
||||||
app_state
|
|
||||||
.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());
|
|
||||||
app_state.signal.send(SignalKind::Notice(notice)).await;
|
|
||||||
}
|
|
||||||
if client.connect_relay(relay).await.is_err() {
|
|
||||||
let notice = Notice::RelayFailed(relay.clone());
|
|
||||||
app_state.signal.send(SignalKind::Notice(notice)).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subscribe to gift wrap events only in the current user's NIP-17 relays
|
|
||||||
Self::fetch_gift_wrap(relays, event.pubkey).await;
|
|
||||||
} else {
|
|
||||||
app_state.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();
|
||||||
@@ -459,54 +397,46 @@ impl ChatSpace {
|
|||||||
Filter::new().limit(limit).authors(public_keys).kinds(kinds);
|
Filter::new().limit(limit).authors(public_keys).kinds(kinds);
|
||||||
|
|
||||||
client
|
client
|
||||||
.subscribe_to(
|
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
|
||||||
BOOTSTRAP_RELAYS,
|
|
||||||
filter,
|
|
||||||
app_state.auto_close_opts,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Kind::Metadata => {
|
Kind::Metadata => {
|
||||||
let metadata = Metadata::from_json(&event.content).unwrap_or_default();
|
if let Ok(metadata) = Metadata::from_json(&event.content) {
|
||||||
let profile = Profile::new(event.pubkey, metadata);
|
let profile = Profile::new(event.pubkey, metadata);
|
||||||
|
ingester.send(Signal::Metadata(profile)).await;
|
||||||
app_state.signal.send(SignalKind::NewProfile(profile)).await;
|
}
|
||||||
}
|
}
|
||||||
Kind::GiftWrap => {
|
Kind::GiftWrap => {
|
||||||
Self::unwrap_gift_wrap(&event).await;
|
Self::unwrap_gift_wrap(&event, pubkey_tx).await;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelayMessage::EndOfStoredEvents(subscription_id) => {
|
RelayMessage::EndOfStoredEvents(subscription_id) => {
|
||||||
if *subscription_id == app_state.gift_wrap_sub_id {
|
if *subscription_id == css.gift_wrap_sub_id {
|
||||||
let signal = SignalKind::GiftWrapStatus(UnwrappingStatus::Processing);
|
let signal = Signal::GiftWrapProcess(UnwrappingStatus::Processing);
|
||||||
app_state.signal.send(signal).await;
|
ingester.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
|
||||||
app_state.signal.send(SignalKind::Auth(req)).await;
|
ingester.send(Signal::Auth(req)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelayMessage::Ok {
|
RelayMessage::Ok {
|
||||||
event_id, message, ..
|
event_id, message, ..
|
||||||
} => {
|
} => {
|
||||||
// Keep track of events sent by Coop
|
// Keep track of events sent by Coop
|
||||||
app_state.sent_ids.write().await.insert(event_id);
|
css.sent_ids.write().await.insert(event_id);
|
||||||
|
|
||||||
// Keep track of events that need to be resent
|
// Keep track of events that need to be resent
|
||||||
match MachineReadablePrefix::parse(&message) {
|
match MachineReadablePrefix::parse(&message) {
|
||||||
Some(MachineReadablePrefix::AuthRequired) => {
|
Some(MachineReadablePrefix::AuthRequired) => {
|
||||||
app_state
|
css.resend_queue.write().await.insert(event_id, relay_url);
|
||||||
.resend_queue
|
|
||||||
.write()
|
|
||||||
.await
|
|
||||||
.insert(event_id, relay_url);
|
|
||||||
}
|
}
|
||||||
Some(_) => {}
|
Some(_) => {}
|
||||||
None => {}
|
None => {}
|
||||||
@@ -520,16 +450,17 @@ 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 app_state = app_state();
|
let ingester = ingester();
|
||||||
|
let signals = ingester.signals();
|
||||||
let mut is_open_proxy_modal = false;
|
let mut is_open_proxy_modal = false;
|
||||||
|
|
||||||
while let Ok(signal) = app_state.signal.receiver().recv_async().await {
|
while let Ok(signal) = signals.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 {
|
||||||
SignalKind::SignerSet(public_key) => {
|
Signal::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
|
||||||
@@ -549,7 +480,7 @@ impl ChatSpace {
|
|||||||
this.load_rooms(window, cx);
|
this.load_rooms(window, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SignalKind::SignerUnset => {
|
Signal::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);
|
||||||
@@ -561,7 +492,7 @@ impl ChatSpace {
|
|||||||
this.reset(cx);
|
this.reset(cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SignalKind::Auth(req) => {
|
Signal::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);
|
||||||
@@ -579,7 +510,7 @@ impl ChatSpace {
|
|||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
SignalKind::ProxyDown => {
|
Signal::ProxyDown => {
|
||||||
if !is_open_proxy_modal {
|
if !is_open_proxy_modal {
|
||||||
is_open_proxy_modal = true;
|
is_open_proxy_modal = true;
|
||||||
|
|
||||||
@@ -589,28 +520,28 @@ impl ChatSpace {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SignalKind::GiftWrapStatus(status) => {
|
Signal::GiftWrapProcess(status) => {
|
||||||
registry.update(cx, |this, cx| {
|
registry.update(cx, |this, cx| {
|
||||||
this.set_unwrapping_status(status, cx);
|
this.set_unwrapping_status(status, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SignalKind::NewProfile(profile) => {
|
Signal::Metadata(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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SignalKind::NewMessage((gift_wrap_id, event)) => {
|
Signal::Message((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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SignalKind::RelaysNotFound => {
|
Signal::DmRelayNotFound => {
|
||||||
view.update(cx, |this, cx| {
|
view.update(cx, |this, cx| {
|
||||||
this.set_required_relays(cx);
|
this.set_required_relays(cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
SignalKind::Notice(msg) => {
|
Signal::Notice(msg) => {
|
||||||
window.push_notification(msg.as_str(), cx);
|
window.push_notification(msg.as_str(), cx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -631,22 +562,64 @@ impl ChatSpace {
|
|||||||
/// Fetches a single event by kind and public key
|
/// Fetches a single event by kind and public key
|
||||||
pub async fn fetch_single_event(kind: Kind, public_key: PublicKey) {
|
pub async fn fetch_single_event(kind: Kind, public_key: PublicKey) {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let css = css();
|
||||||
let filter = Filter::new().kind(kind).author(public_key).limit(1);
|
let filter = Filter::new().kind(kind).author(public_key).limit(1);
|
||||||
|
|
||||||
if let Err(e) = client.subscribe(filter, app_state.auto_close_opts).await {
|
if let Err(e) = client.subscribe(filter, css.auto_close_opts).await {
|
||||||
log::info!("Failed to subscribe: {e}");
|
log::info!("Failed to subscribe: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetches gift wrap events for a given public key and relays
|
pub async fn fetch_nip17_relays(public_key: PublicKey) {
|
||||||
|
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 id = app_state().gift_wrap_sub_id.clone();
|
let sub_id = css().gift_wrap_sub_id.clone();
|
||||||
let filter = Filter::new().kind(Kind::GiftWrap).pubkey(public_key);
|
let filter = Filter::new().kind(Kind::GiftWrap).pubkey(public_key);
|
||||||
|
|
||||||
if client
|
if client
|
||||||
.subscribe_with_id_to(relays.clone(), id, filter, None)
|
.subscribe_with_id_to(relays.clone(), sub_id, filter, None)
|
||||||
.await
|
.await
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
@@ -661,7 +634,7 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let css = css();
|
||||||
|
|
||||||
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
|
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
|
||||||
let limit = public_keys.len() * kinds.len() + 20;
|
let limit = public_keys.len() * kinds.len() + 20;
|
||||||
@@ -670,7 +643,7 @@ impl ChatSpace {
|
|||||||
let filter = Filter::new().authors(public_keys).kinds(kinds).limit(limit);
|
let filter = Filter::new().authors(public_keys).kinds(kinds).limit(limit);
|
||||||
|
|
||||||
client
|
client
|
||||||
.subscribe_to(BOOTSTRAP_RELAYS, filter, app_state.auto_close_opts)
|
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -716,9 +689,10 @@ 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) {
|
async fn unwrap_gift_wrap(target: &Event, pubkey_tx: &Sender<PublicKey>) {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let ingester = ingester();
|
||||||
|
let css = css();
|
||||||
let mut message: Option<Event> = None;
|
let mut message: Option<Event> = None;
|
||||||
|
|
||||||
if let Ok(event) = Self::get_unwrapped_event(target.id).await {
|
if let Ok(event) = Self::get_unwrapped_event(target.id).await {
|
||||||
@@ -738,24 +712,18 @@ 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() {
|
||||||
app_state.ingester.send(public_key).await;
|
pubkey_tx.send_async(public_key).await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
match event.created_at >= app_state.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;
|
||||||
app_state
|
ingester.send(Signal::Message((target.id, event))).await;
|
||||||
.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 => {
|
||||||
app_state
|
css.gift_wrap_processing.store(true, Ordering::Release);
|
||||||
.gift_wrap_processing
|
|
||||||
.store(true, Ordering::Release);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -806,7 +774,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let css = css();
|
||||||
let signer = client.signer().await?;
|
let signer = client.signer().await?;
|
||||||
|
|
||||||
// Construct event
|
// Construct event
|
||||||
@@ -837,7 +805,7 @@ impl ChatSpace {
|
|||||||
relay.resubscribe().await?;
|
relay.resubscribe().await?;
|
||||||
|
|
||||||
// Get all failed events that need to be resent
|
// Get all failed events that need to be resent
|
||||||
let mut queue = app_state.resend_queue.write().await;
|
let mut queue = css.resend_queue.write().await;
|
||||||
|
|
||||||
let ids: Vec<EventId> = queue
|
let ids: Vec<EventId> = queue
|
||||||
.iter()
|
.iter()
|
||||||
@@ -856,8 +824,8 @@ impl ChatSpace {
|
|||||||
success: HashSet::from([relay_url]),
|
success: HashSet::from([relay_url]),
|
||||||
};
|
};
|
||||||
|
|
||||||
app_state.sent_ids.write().await.insert(event_id);
|
css.sent_ids.write().await.insert(event_id);
|
||||||
app_state.resent_ids.write().await.push(output);
|
css.resent_ids.write().await.push(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -962,33 +930,28 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reopen_auth_request(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn reopen_auth_request(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
for (_, request) in self.auth_requests.read(cx).clone() {
|
for (_, request) in self.auth_requests.clone().into_iter() {
|
||||||
self.open_auth_request(request, window, cx);
|
self.open_auth_request(request, window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_auth_request(&mut self, req: &AuthRequest, cx: &mut Context<Self>) {
|
fn push_auth_request(&mut self, req: &AuthRequest, cx: &mut Context<Self>) {
|
||||||
self.auth_requests.update(cx, |this, cx| {
|
self.auth_requests.insert(req.url.clone(), req.to_owned());
|
||||||
this.insert(req.url.clone(), req.to_owned());
|
cx.notify();
|
||||||
cx.notify();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sending_auth_request(&mut self, challenge: &str, cx: &mut Context<Self>) {
|
fn sending_auth_request(&mut self, challenge: &str, cx: &mut Context<Self>) {
|
||||||
self.auth_requests.update(cx, |this, cx| {
|
for (_, req) in self.auth_requests.iter_mut() {
|
||||||
for (_, req) in this.iter_mut() {
|
if req.challenge == challenge {
|
||||||
if req.challenge == challenge {
|
req.sending = true;
|
||||||
req.sending = true;
|
cx.notify();
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_sending_auth_request(&self, challenge: &str, cx: &App) -> bool {
|
fn is_sending_auth_request(&self, challenge: &str, _cx: &App) -> bool {
|
||||||
if let Some(req) = self
|
if let Some(req) = self
|
||||||
.auth_requests
|
.auth_requests
|
||||||
.read(cx)
|
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, req)| req.challenge == challenge)
|
.find(|(_, req)| req.challenge == challenge)
|
||||||
{
|
{
|
||||||
@@ -999,10 +962,8 @@ impl ChatSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn remove_auth_request(&mut self, challenge: &str, cx: &mut Context<Self>) {
|
fn remove_auth_request(&mut self, challenge: &str, cx: &mut Context<Self>) {
|
||||||
self.auth_requests.update(cx, |this, cx| {
|
self.auth_requests.retain(|_, r| r.challenge != challenge);
|
||||||
this.retain(|_, r| r.challenge != challenge);
|
cx.notify();
|
||||||
cx.notify();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_onboarding_layout(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn set_onboarding_layout(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
@@ -1022,7 +983,7 @@ impl ChatSpace {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let panel = Arc::new(account::init(profile, secret, window, cx));
|
let panel = Arc::new(account::init(secret, profile, window, cx));
|
||||||
let center = DockItem::panel(panel);
|
let center = DockItem::panel(panel);
|
||||||
|
|
||||||
self.dock.update(cx, |this, cx| {
|
self.dock.update(cx, |this, cx| {
|
||||||
@@ -1122,7 +1083,7 @@ impl ChatSpace {
|
|||||||
) {
|
) {
|
||||||
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let css = css();
|
||||||
|
|
||||||
let filter = Filter::new().kind(Kind::PrivateDirectMessage);
|
let filter = Filter::new().kind(Kind::PrivateDirectMessage);
|
||||||
|
|
||||||
@@ -1141,7 +1102,7 @@ impl ChatSpace {
|
|||||||
.authors(pubkeys);
|
.authors(pubkeys);
|
||||||
|
|
||||||
client
|
client
|
||||||
.subscribe_to(BOOTSTRAP_RELAYS, filter, app_state.auto_close_opts)
|
.subscribe_to(BOOTSTRAP_RELAYS, filter, css.auto_close_opts)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1161,7 +1122,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 app_state = app_state();
|
let ingester = ingester();
|
||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
.kind(Kind::ApplicationSpecificData)
|
.kind(Kind::ApplicationSpecificData)
|
||||||
@@ -1174,7 +1135,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
|
||||||
app_state.signal.send(SignalKind::SignerUnset).await;
|
ingester.send(Signal::SignerUnset).await;
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
@@ -1284,7 +1245,7 @@ impl ChatSpace {
|
|||||||
.w_full()
|
.w_full()
|
||||||
.child(compose_button())
|
.child(compose_button())
|
||||||
.when(status != &UnwrappingStatus::Complete, |this| {
|
.when(status != &UnwrappingStatus::Complete, |this| {
|
||||||
this.child(deferred(
|
this.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.px_2()
|
.px_2()
|
||||||
.h_6()
|
.h_6()
|
||||||
@@ -1293,7 +1254,7 @@ impl ChatSpace {
|
|||||||
.rounded_full()
|
.rounded_full()
|
||||||
.bg(cx.theme().surface_background)
|
.bg(cx.theme().surface_background)
|
||||||
.child(shared_t!("loading.label")),
|
.child(shared_t!("loading.label")),
|
||||||
))
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1306,7 +1267,7 @@ impl ChatSpace {
|
|||||||
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
||||||
let updating = AutoUpdater::read_global(cx).status.is_updating();
|
let updating = AutoUpdater::read_global(cx).status.is_updating();
|
||||||
let updated = AutoUpdater::read_global(cx).status.is_updated();
|
let updated = AutoUpdater::read_global(cx).status.is_updated();
|
||||||
let auth_requests = self.auth_requests.read(cx).len();
|
let auth_requests = self.auth_requests.len();
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
@@ -1371,7 +1332,7 @@ impl ChatSpace {
|
|||||||
.reverse()
|
.reverse()
|
||||||
.transparent()
|
.transparent()
|
||||||
.icon(IconName::CaretDown)
|
.icon(IconName::CaretDown)
|
||||||
.child(Avatar::new(profile.avatar(proxy)).size(rems(1.49)))
|
.child(Avatar::new(profile.avatar_url(proxy)).size(rems(1.49)))
|
||||||
.popup_menu(|this, _window, _cx| {
|
.popup_menu(|this, _window, _cx| {
|
||||||
this.menu(t!("user.dark_mode"), Box::new(DarkMode))
|
this.menu(t!("user.dark_mode"), Box::new(DarkMode))
|
||||||
.menu(t!("user.settings"), Box::new(Settings))
|
.menu(t!("user.settings"), Box::new(Settings))
|
||||||
@@ -1398,7 +1359,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 app_state = app_state();
|
let ingester = ingester();
|
||||||
|
|
||||||
if proxy.start().await.is_ok() {
|
if proxy.start().await.is_ok() {
|
||||||
webbrowser::open(&url).ok();
|
webbrowser::open(&url).ok();
|
||||||
@@ -1429,7 +1390,7 @@ impl ChatSpace {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
app_state.signal.send(SignalKind::ProxyDown).await;
|
ingester.send(Signal::ProxyDown).await;
|
||||||
}
|
}
|
||||||
smol::Timer::after(Duration::from_secs(1)).await;
|
smol::Timer::after(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
@@ -1494,7 +1455,6 @@ impl Render for ChatSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.id(SharedString::from("chatspace"))
|
|
||||||
.on_action(cx.listener(Self::on_settings))
|
.on_action(cx.listener(Self::on_settings))
|
||||||
.on_action(cx.listener(Self::on_dark_mode))
|
.on_action(cx.listener(Self::on_dark_mode))
|
||||||
.on_action(cx.listener(Self::on_sign_out))
|
.on_action(cx.listener(Self::on_sign_out))
|
||||||
|
|||||||
+13
-2
@@ -2,12 +2,13 @@ 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::{app_state, nostr_client};
|
use global::{css, ingester, 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,
|
||||||
WindowOptions,
|
WindowOptions,
|
||||||
};
|
};
|
||||||
|
use theme::Theme;
|
||||||
use ui::Root;
|
use ui::Root;
|
||||||
|
|
||||||
use crate::actions::{load_embedded_fonts, quit, Quit};
|
use crate::actions::{load_embedded_fonts, quit, Quit};
|
||||||
@@ -25,8 +26,11 @@ 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 _app_state = app_state();
|
let _css = css();
|
||||||
|
|
||||||
// Initialize the Application
|
// Initialize the Application
|
||||||
let app = Application::new()
|
let app = Application::new()
|
||||||
@@ -78,6 +82,13 @@ fn main() {
|
|||||||
// Bring the app to the foreground
|
// Bring the app to the foreground
|
||||||
cx.activate(true);
|
cx.activate(true);
|
||||||
|
|
||||||
|
// Automatically sync theme with system appearance
|
||||||
|
window
|
||||||
|
.observe_window_appearance(|window, cx| {
|
||||||
|
Theme::sync_system_appearance(Some(window), cx);
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
|
||||||
// Root Entity
|
// Root Entity
|
||||||
cx.new(|cx| {
|
cx.new(|cx| {
|
||||||
// Initialize the tokio runtime
|
// Initialize the tokio runtime
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use client_keys::ClientKeys;
|
use client_keys::ClientKeys;
|
||||||
use common::display::RenderedProfile;
|
use common::display::ReadableProfile;
|
||||||
|
use common::handle_auth::CoopAuthUrlHandler;
|
||||||
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
|
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
|
||||||
use global::{app_state, nostr_client, SignalKind};
|
use global::{ingester, nostr_client, Signal};
|
||||||
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,
|
||||||
FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render,
|
FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render, SharedString,
|
||||||
RetainAllImageCache, SharedString, StatefulInteractiveElement, Styled, Subscription, Task,
|
StatefulInteractiveElement, Styled, Task, WeakEntity, Window,
|
||||||
WeakEntity, Window,
|
|
||||||
};
|
};
|
||||||
use i18n::{shared_t, t};
|
use i18n::{shared_t, t};
|
||||||
use nostr_connect::prelude::*;
|
use nostr_connect::prelude::*;
|
||||||
@@ -22,20 +22,18 @@ use ui::button::{Button, ButtonVariants};
|
|||||||
use ui::dock_area::panel::{Panel, PanelEvent};
|
use ui::dock_area::panel::{Panel, PanelEvent};
|
||||||
use ui::indicator::Indicator;
|
use ui::indicator::Indicator;
|
||||||
use ui::input::{InputState, TextInput};
|
use ui::input::{InputState, TextInput};
|
||||||
use ui::notification::Notification;
|
|
||||||
use ui::popup_menu::PopupMenu;
|
use ui::popup_menu::PopupMenu;
|
||||||
use ui::{h_flex, v_flex, ContextModal, Sizable, StyledExt};
|
use ui::{h_flex, v_flex, ContextModal, Disableable, Sizable, StyledExt};
|
||||||
|
|
||||||
use crate::actions::CoopAuthUrlHandler;
|
|
||||||
use crate::chatspace::ChatSpace;
|
use crate::chatspace::ChatSpace;
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
profile: Profile,
|
|
||||||
secret: String,
|
secret: String,
|
||||||
|
profile: Profile,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Entity<Account> {
|
) -> Entity<Account> {
|
||||||
cx.new(|cx| Account::new(secret, profile, window, cx))
|
Account::new(secret, profile, window, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Account {
|
pub struct Account {
|
||||||
@@ -44,33 +42,18 @@ pub struct Account {
|
|||||||
is_bunker: bool,
|
is_bunker: bool,
|
||||||
is_extension: bool,
|
is_extension: bool,
|
||||||
loading: bool,
|
loading: bool,
|
||||||
|
// Panel
|
||||||
name: SharedString,
|
name: SharedString,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
image_cache: Entity<RetainAllImageCache>,
|
|
||||||
|
|
||||||
_subscriptions: SmallVec<[Subscription; 1]>,
|
|
||||||
_tasks: SmallVec<[Task<()>; 1]>,
|
_tasks: SmallVec<[Task<()>; 1]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Account {
|
impl Account {
|
||||||
fn new(secret: String, profile: Profile, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
fn new(secret: String, profile: Profile, _window: &mut Window, cx: &mut App) -> Entity<Self> {
|
||||||
let is_bunker = secret.starts_with("bunker://");
|
let is_bunker = secret.starts_with("bunker://");
|
||||||
let is_extension = secret.starts_with("extension");
|
let is_extension = secret.starts_with("extension");
|
||||||
|
|
||||||
let mut subscriptions = smallvec![];
|
cx.new(|cx| Self {
|
||||||
|
|
||||||
subscriptions.push(
|
|
||||||
// Clear the local state when user closes the account panel
|
|
||||||
cx.on_release_in(window, move |this, window, cx| {
|
|
||||||
this.stored_secret.clear();
|
|
||||||
this.image_cache.update(cx, |this, cx| {
|
|
||||||
this.clear(window, cx);
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
Self {
|
|
||||||
profile,
|
profile,
|
||||||
is_bunker,
|
is_bunker,
|
||||||
is_extension,
|
is_extension,
|
||||||
@@ -78,10 +61,8 @@ impl Account {
|
|||||||
loading: false,
|
loading: false,
|
||||||
name: "Account".into(),
|
name: "Account".into(),
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
image_cache: RetainAllImageCache::new(cx),
|
|
||||||
_subscriptions: subscriptions,
|
|
||||||
_tasks: smallvec![],
|
_tasks: smallvec![],
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn login(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn login(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
@@ -112,8 +93,8 @@ impl Account {
|
|||||||
signer.auth_url_handler(CoopAuthUrlHandler);
|
signer.auth_url_handler(CoopAuthUrlHandler);
|
||||||
|
|
||||||
self._tasks.push(
|
self._tasks.push(
|
||||||
// Handle connection in the background
|
// Handle connection
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |_this, cx| {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
|
|
||||||
match signer.bunker_uri().await {
|
match signer.bunker_uri().await {
|
||||||
@@ -122,9 +103,8 @@ impl Account {
|
|||||||
client.set_signer(signer).await;
|
client.set_signer(signer).await;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update_in(cx, |this, window, cx| {
|
cx.update(|window, cx| {
|
||||||
this.set_loading(false, cx);
|
window.push_notification(e.to_string(), cx);
|
||||||
window.push_notification(Notification::error(e.to_string()), cx);
|
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -268,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 app_state = app_state();
|
let ingester = ingester();
|
||||||
|
|
||||||
let filter = Filter::new()
|
let filter = Filter::new()
|
||||||
.kind(Kind::ApplicationSpecificData)
|
.kind(Kind::ApplicationSpecificData)
|
||||||
@@ -281,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
|
||||||
app_state.signal.send(SignalKind::SignerUnset).await;
|
ingester.send(Signal::SignerUnset).await;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -321,7 +301,6 @@ impl Focusable for Account {
|
|||||||
impl Render for Account {
|
impl Render for Account {
|
||||||
fn render(&mut self, _window: &mut gpui::Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut gpui::Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
v_flex()
|
v_flex()
|
||||||
.image_cache(self.image_cache.clone())
|
|
||||||
.relative()
|
.relative()
|
||||||
.size_full()
|
.size_full()
|
||||||
.gap_10()
|
.gap_10()
|
||||||
@@ -363,72 +342,46 @@ impl Render for Account {
|
|||||||
.id("account")
|
.id("account")
|
||||||
.h_10()
|
.h_10()
|
||||||
.w_72()
|
.w_72()
|
||||||
.bg(cx.theme().elevated_surface_background)
|
.bg(cx.theme().element_background)
|
||||||
|
.text_color(cx.theme().element_foreground)
|
||||||
.rounded_lg()
|
.rounded_lg()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.when(self.loading, |this| {
|
.map(|this| {
|
||||||
this.child(
|
if self.loading {
|
||||||
div()
|
this.child(
|
||||||
.size_full()
|
div()
|
||||||
.flex()
|
.size_full()
|
||||||
.items_center()
|
.flex()
|
||||||
.justify_center()
|
.items_center()
|
||||||
.child(Indicator::new().small()),
|
.justify_center()
|
||||||
)
|
.child(Indicator::new().small()),
|
||||||
})
|
)
|
||||||
.when(!self.loading, |this| {
|
} else {
|
||||||
let avatar = self.profile.avatar(true);
|
this.child(
|
||||||
let name = self.profile.display_name();
|
div()
|
||||||
|
.h_full()
|
||||||
this.child(
|
.flex()
|
||||||
h_flex()
|
.items_center()
|
||||||
.h_full()
|
.justify_center()
|
||||||
.justify_center()
|
.gap_2()
|
||||||
.gap_2()
|
.child(shared_t!("onboarding.choose_account"))
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(Avatar::new(avatar).size(rems(1.5)))
|
.child(
|
||||||
.child(div().pb_px().font_semibold().child(name)),
|
Avatar::new(self.profile.avatar_url(true))
|
||||||
)
|
.size(rems(1.5)),
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.when(self.is_bunker, |this| {
|
|
||||||
let label = SharedString::from("Nostr Connect");
|
|
||||||
|
|
||||||
this.child(
|
|
||||||
div()
|
|
||||||
.py_0p5()
|
|
||||||
.px_2()
|
|
||||||
.text_xs()
|
|
||||||
.bg(cx.theme().secondary_active)
|
|
||||||
.text_color(
|
|
||||||
cx.theme().secondary_foreground,
|
|
||||||
)
|
|
||||||
.rounded_full()
|
|
||||||
.child(label),
|
|
||||||
)
|
)
|
||||||
})
|
.child(
|
||||||
.when(self.is_extension, |this| {
|
|
||||||
let label = SharedString::from("Extension");
|
|
||||||
|
|
||||||
this.child(
|
|
||||||
div()
|
div()
|
||||||
.py_0p5()
|
.pb_px()
|
||||||
.px_2()
|
.font_semibold()
|
||||||
.text_xs()
|
.child(self.profile.display_name()),
|
||||||
.bg(cx.theme().secondary_active)
|
),
|
||||||
.text_color(
|
),
|
||||||
cx.theme().secondary_foreground,
|
)
|
||||||
)
|
}
|
||||||
.rounded_full()
|
|
||||||
.child(label),
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.active(|this| this.bg(cx.theme().element_active))
|
|
||||||
.hover(|this| this.bg(cx.theme().element_hover))
|
.hover(|this| this.bg(cx.theme().element_hover))
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
this.login(window, cx);
|
this.login(window, cx);
|
||||||
@@ -438,6 +391,7 @@ impl Render for Account {
|
|||||||
Button::new("logout")
|
Button::new("logout")
|
||||||
.label(t!("user.sign_out"))
|
.label(t!("user.sign_out"))
|
||||||
.ghost()
|
.ghost()
|
||||||
|
.disabled(self.loading)
|
||||||
.on_click(cx.listener(move |this, _e, window, cx| {
|
.on_click(cx.listener(move |this, _e, window, cx| {
|
||||||
this.logout(window, cx);
|
this.logout(window, cx);
|
||||||
})),
|
})),
|
||||||
|
|||||||
+157
-345
@@ -1,14 +1,13 @@
|
|||||||
use std::collections::HashMap;
|
use anyhow::anyhow;
|
||||||
|
use common::display::{ReadableProfile, ReadableTimestamp};
|
||||||
use common::display::{RenderedProfile, RenderedTimestamp};
|
|
||||||
use common::nip96::nip96_upload;
|
use common::nip96::nip96_upload;
|
||||||
use global::{app_state, nostr_client};
|
use global::{css, nostr_client};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, img, list, px, red, relative, rems, svg, white, Action, AnyElement, App, AppContext,
|
div, img, list, px, red, relative, rems, svg, white, Action, AnyElement, App, AppContext,
|
||||||
ClipboardItem, Context, Element, Entity, EventEmitter, Flatten, FocusHandle, Focusable,
|
ClipboardItem, Context, Element, Entity, EventEmitter, Flatten, FocusHandle, Focusable,
|
||||||
InteractiveElement, IntoElement, ListAlignment, ListOffset, ListState, MouseButton, ObjectFit,
|
InteractiveElement, IntoElement, ListAlignment, ListOffset, ListState, MouseButton, ObjectFit,
|
||||||
ParentElement, PathPromptOptions, Render, RetainAllImageCache, SharedString, SharedUri,
|
ParentElement, PathPromptOptions, Render, RetainAllImageCache, SharedString,
|
||||||
StatefulInteractiveElement, Styled, StyledImage, Subscription, Task, Window,
|
StatefulInteractiveElement, Styled, StyledImage, Subscription, Task, Window,
|
||||||
};
|
};
|
||||||
use gpui_tokio::Tokio;
|
use gpui_tokio::Tokio;
|
||||||
@@ -25,13 +24,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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, 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::notification::Notification;
|
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,
|
||||||
@@ -42,7 +40,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 SeenOn(pub EventId);
|
pub struct ChangeSubject(pub String);
|
||||||
|
|
||||||
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))
|
||||||
@@ -51,9 +49,6 @@ 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>,
|
||||||
@@ -72,20 +67,14 @@ pub struct Chat {
|
|||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
image_cache: Entity<RetainAllImageCache>,
|
image_cache: Entity<RetainAllImageCache>,
|
||||||
|
|
||||||
_subscriptions: SmallVec<[Subscription; 4]>,
|
_subscriptions: SmallVec<[Subscription; 2]>,
|
||||||
_tasks: SmallVec<[Task<()>; 2]>,
|
_tasks: SmallVec<[Task<()>; 1]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
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"))
|
||||||
@@ -100,35 +89,11 @@ 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| {
|
||||||
@@ -174,7 +139,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(Message::user(event), false, cx);
|
this.insert_message(event, false, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RoomSignal::Refresh => {
|
RoomSignal::Refresh => {
|
||||||
@@ -184,66 +149,24 @@ 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),
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
|
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,
|
||||||
input,
|
input,
|
||||||
replies_to,
|
replies_to,
|
||||||
attachments,
|
attachments,
|
||||||
uploading: false,
|
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
_tasks: tasks,
|
_tasks: tasks,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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);
|
||||||
@@ -282,17 +205,15 @@ impl Chat {
|
|||||||
let attachments = self.attachments.read(cx);
|
let attachments = self.attachments.read(cx);
|
||||||
|
|
||||||
if !attachments.is_empty() {
|
if !attachments.is_empty() {
|
||||||
let urls = attachments
|
content = format!(
|
||||||
.iter()
|
"{}\n{}",
|
||||||
.map(|url| url.to_string())
|
content,
|
||||||
.collect_vec()
|
attachments
|
||||||
.join("\n");
|
.iter()
|
||||||
|
.map(|url| url.to_string())
|
||||||
if content.is_empty() {
|
.collect_vec()
|
||||||
content = urls;
|
.join("\n")
|
||||||
} else {
|
)
|
||||||
content = format!("{content}\n{urls}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content
|
content
|
||||||
@@ -300,7 +221,7 @@ impl Chat {
|
|||||||
|
|
||||||
/// Check if the event is sent by Coop
|
/// Check if the event is sent by Coop
|
||||||
fn is_sent_by_coop(&self, gift_wrap_id: &EventId) -> bool {
|
fn is_sent_by_coop(&self, gift_wrap_id: &EventId) -> bool {
|
||||||
app_state().sent_ids.read_blocking().contains(gift_wrap_id)
|
css().sent_ids.read_blocking().contains(gift_wrap_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a message to all members of the chat
|
/// Send a message to all members of the chat
|
||||||
@@ -339,14 +260,11 @@ 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(Message::user(temp_message), true, cx);
|
this.insert_message(temp_message, true, cx);
|
||||||
|
|
||||||
// Remove all replies
|
// Remove all replies
|
||||||
this.remove_all_replies(cx);
|
this.remove_all_replies(cx);
|
||||||
|
|
||||||
// remove all attachments
|
|
||||||
this.remove_all_attachments(cx);
|
|
||||||
|
|
||||||
// Reset the input state
|
// Reset the input state
|
||||||
this.input.update(cx, |this, cx| {
|
this.input.update(cx, |this, cx| {
|
||||||
this.set_loading(false, cx);
|
this.set_loading(false, cx);
|
||||||
@@ -400,15 +318,13 @@ 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;
|
});
|
||||||
});
|
cx.notify();
|
||||||
cx.notify();
|
})
|
||||||
})
|
.ok();
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
cx.update(|window, cx| {
|
cx.update(|window, cx| {
|
||||||
@@ -423,41 +339,6 @@ 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
|
||||||
@@ -489,6 +370,35 @@ 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)
|
||||||
@@ -538,74 +448,73 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn upload(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn upload(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
if self.uploading {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Block the upload button to until current task is resolved
|
||||||
|
self.uploading(true, cx);
|
||||||
|
|
||||||
// Get the user's configured NIP96 server
|
// Get the user's configured NIP96 server
|
||||||
let nip96_server = AppSettings::get_media_server(cx);
|
let nip96_server = AppSettings::get_media_server(cx);
|
||||||
|
|
||||||
let path = cx.prompt_for_paths(PathPromptOptions {
|
// Open native file dialog
|
||||||
|
let paths = cx.prompt_for_paths(PathPromptOptions {
|
||||||
files: true,
|
files: true,
|
||||||
directories: false,
|
directories: false,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
prompt: None,
|
prompt: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
let task = Tokio::spawn(cx, async move {
|
||||||
let mut paths = path.await.ok()?.ok()??;
|
match Flatten::flatten(paths.await.map_err(|e| e.into())) {
|
||||||
let path = paths.pop()?;
|
Ok(Some(mut paths)) => {
|
||||||
|
if let Some(path) = paths.pop() {
|
||||||
|
let file = fs::read(path).await?;
|
||||||
|
let url = nip96_upload(nostr_client(), &nip96_server, file).await?;
|
||||||
|
|
||||||
let upload = Tokio::spawn(cx, async move {
|
Ok(url)
|
||||||
let client = nostr_client();
|
} else {
|
||||||
let file = fs::read(path).await.ok()?;
|
Err(anyhow!("Path not found"))
|
||||||
let url = nip96_upload(client, &nip96_server, file).await.ok()?;
|
|
||||||
|
|
||||||
Some(url)
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Ok(task) = upload {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.set_uploading(true, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
|
|
||||||
match Flatten::flatten(task.await.map_err(|e| e.into())) {
|
|
||||||
Ok(Some(url)) => {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.add_attachment(url, cx);
|
|
||||||
this.set_uploading(false, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
Ok(None) => {
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
|
||||||
window.push_notification("Failed to upload file", cx);
|
|
||||||
this.set_uploading(false, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
|
||||||
window.push_notification(Notification::error(e.to_string()), cx);
|
|
||||||
this.set_uploading(false, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(None) => Err(anyhow!("User cancelled")),
|
||||||
|
Err(e) => Err(anyhow!("File dialog error: {e}")),
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Some(())
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
|
match Flatten::flatten(task.await.map_err(|e| e.into())) {
|
||||||
|
Ok(Ok(url)) => {
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.add_attachment(url, cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
Ok(Err(e)) => {
|
||||||
|
log::warn!("User cancelled: {e}");
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.uploading(false, cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
this.update_in(cx, |this, window, cx| {
|
||||||
|
window.push_notification(e.to_string(), cx);
|
||||||
|
this.uploading(false, cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_uploading(&mut self, uploading: bool, cx: &mut Context<Self>) {
|
|
||||||
self.uploading = uploading;
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_attachment(&mut self, url: Url, cx: &mut Context<Self>) {
|
fn add_attachment(&mut self, url: Url, cx: &mut Context<Self>) {
|
||||||
self.attachments.update(cx, |this, cx| {
|
self.attachments.update(cx, |this, cx| {
|
||||||
this.push(url);
|
this.push(url);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
|
self.uploading(false, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_attachment(&mut self, url: &Url, _window: &mut Window, cx: &mut Context<Self>) {
|
fn remove_attachment(&mut self, url: &Url, _window: &mut Window, cx: &mut Context<Self>) {
|
||||||
@@ -617,11 +526,9 @@ impl Chat {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_all_attachments(&mut self, cx: &mut Context<Self>) {
|
fn uploading(&mut self, status: bool, cx: &mut Context<Self>) {
|
||||||
self.attachments.update(cx, |this, cx| {
|
self.uploading = status;
|
||||||
this.clear();
|
cx.notify();
|
||||||
cx.notify();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_announcement(&mut self, ix: usize, cx: &mut Context<Self>) -> AnyElement {
|
fn render_announcement(&mut self, ix: usize, cx: &mut Context<Self>) -> AnyElement {
|
||||||
@@ -650,34 +557,6 @@ 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)
|
||||||
@@ -729,7 +608,7 @@ impl Chat {
|
|||||||
.flex()
|
.flex()
|
||||||
.gap_3()
|
.gap_3()
|
||||||
.when(!hide_avatar, |this| {
|
.when(!hide_avatar, |this| {
|
||||||
this.child(Avatar::new(author.avatar(proxy)).size(rems(2.)))
|
this.child(Avatar::new(author.avatar_url(proxy)).size(rems(2.)))
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
@@ -738,7 +617,9 @@ impl Chat {
|
|||||||
.flex_initial()
|
.flex_initial()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
div()
|
||||||
|
.flex()
|
||||||
|
.items_center()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.text_color(cx.theme().text_placeholder)
|
.text_color(cx.theme().text_placeholder)
|
||||||
@@ -748,7 +629,7 @@ impl Chat {
|
|||||||
.text_color(cx.theme().text)
|
.text_color(cx.theme().text)
|
||||||
.child(author.display_name()),
|
.child(author.display_name()),
|
||||||
)
|
)
|
||||||
.child(message.created_at.to_human_time())
|
.child(div().child(message.created_at.to_human_time()))
|
||||||
.when_some(is_sent_success, |this, status| {
|
.when_some(is_sent_success, |this, status| {
|
||||||
this.when(status, |this| {
|
this.when(status, |this| {
|
||||||
this.child(self.render_message_sent(&id, cx))
|
this.child(self.render_message_sent(&id, cx))
|
||||||
@@ -769,7 +650,7 @@ impl Chat {
|
|||||||
.label(t!("common.resend"))
|
.label(t!("common.resend"))
|
||||||
.danger()
|
.danger()
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
@@ -784,12 +665,14 @@ impl Chat {
|
|||||||
.child(self.render_actions(&id, cx))
|
.child(self.render_actions(&id, cx))
|
||||||
.on_mouse_down(
|
.on_mouse_down(
|
||||||
MouseButton::Middle,
|
MouseButton::Middle,
|
||||||
cx.listener(move |this, _, _window, cx| {
|
cx.listener(move |this, _event, _window, cx| {
|
||||||
this.copy_message(&id, cx);
|
this.copy_message(&id, cx);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.on_double_click(cx.listener(move |this, _, _window, cx| {
|
.on_double_click(cx.listener({
|
||||||
this.reply_to(&id, cx);
|
move |this, _event, _window, cx| {
|
||||||
|
this.reply_to(&id, cx);
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.hover(|this| this.bg(cx.theme().surface_background))
|
.hover(|this| this.bg(cx.theme().surface_background))
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
@@ -826,7 +709,7 @@ impl Chat {
|
|||||||
.w_full()
|
.w_full()
|
||||||
.text_ellipsis()
|
.text_ellipsis()
|
||||||
.line_clamp(1)
|
.line_clamp(1)
|
||||||
.child(SharedString::from(&message.content)),
|
.child(message.content.clone()),
|
||||||
)
|
)
|
||||||
.hover(|this| this.bg(cx.theme().elevated_surface_background))
|
.hover(|this| this.bg(cx.theme().elevated_surface_background))
|
||||||
.on_click({
|
.on_click({
|
||||||
@@ -900,7 +783,7 @@ impl Chat {
|
|||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
let profile = registry.get_person(&report.receiver, cx);
|
let profile = registry.get_person(&report.receiver, cx);
|
||||||
let name = profile.display_name();
|
let name = profile.display_name();
|
||||||
let avatar = profile.avatar(true);
|
let avatar = profile.avatar_url(true);
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
@@ -1037,6 +920,31 @@ 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()
|
||||||
@@ -1049,55 +957,20 @@ impl Chat {
|
|||||||
.border_1()
|
.border_1()
|
||||||
.border_color(cx.theme().border)
|
.border_color(cx.theme().border)
|
||||||
.bg(cx.theme().background)
|
.bg(cx.theme().background)
|
||||||
.child(
|
.children(groups)
|
||||||
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())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_attachment(&self, url: &Url, cx: &Context<Self>) -> impl IntoElement {
|
fn render_attachment(&self, url: &Url, cx: &Context<Self>) -> impl IntoElement {
|
||||||
|
let url = url.clone();
|
||||||
|
let path: SharedString = url.to_string().into();
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.id(SharedString::from(url.to_string()))
|
.id(SharedString::from(url.to_string()))
|
||||||
.relative()
|
.relative()
|
||||||
.w_16()
|
.w_16()
|
||||||
.child(
|
.child(
|
||||||
img(SharedUri::from(url.to_string()))
|
img(path.clone())
|
||||||
.size_16()
|
.size_16()
|
||||||
.shadow_lg()
|
.shadow_lg()
|
||||||
.rounded(cx.theme().radius)
|
.rounded(cx.theme().radius)
|
||||||
@@ -1116,12 +989,9 @@ impl Chat {
|
|||||||
.bg(red())
|
.bg(red())
|
||||||
.child(Icon::new(IconName::Close).size_2().text_color(white())),
|
.child(Icon::new(IconName::Close).size_2().text_color(white())),
|
||||||
)
|
)
|
||||||
.on_click({
|
.on_click(cx.listener(move |this, _, window, cx| {
|
||||||
let url = url.clone();
|
this.remove_attachment(&url, window, cx);
|
||||||
cx.listener(move |this, _, window, cx| {
|
}))
|
||||||
this.remove_attachment(&url, window, cx);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_attachment_list(
|
fn render_attachment_list(
|
||||||
@@ -1186,7 +1056,7 @@ impl Chat {
|
|||||||
.text_sm()
|
.text_sm()
|
||||||
.text_ellipsis()
|
.text_ellipsis()
|
||||||
.line_clamp(1)
|
.line_clamp(1)
|
||||||
.child(SharedString::from(&text.content)),
|
.child(text.content.clone()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
div()
|
div()
|
||||||
@@ -1263,62 +1133,6 @@ 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 app_state = app_state();
|
|
||||||
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) = app_state.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 {
|
||||||
@@ -1365,7 +1179,6 @@ 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(
|
||||||
@@ -1383,9 +1196,6 @@ 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 {
|
||||||
@@ -1403,7 +1213,9 @@ impl Render for Chat {
|
|||||||
.px_3()
|
.px_3()
|
||||||
.py_2()
|
.py_2()
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
div()
|
||||||
|
.flex()
|
||||||
|
.flex_col()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
.children(self.render_attachment_list(window, cx))
|
.children(self.render_attachment_list(window, cx))
|
||||||
.children(self.render_reply_list(window, cx))
|
.children(self.render_reply_list(window, cx))
|
||||||
@@ -1422,10 +1234,10 @@ impl Render for Chat {
|
|||||||
.child(
|
.child(
|
||||||
Button::new("upload")
|
Button::new("upload")
|
||||||
.icon(IconName::Upload)
|
.icon(IconName::Upload)
|
||||||
.loading(self.uploading)
|
|
||||||
.disabled(self.uploading)
|
|
||||||
.ghost()
|
.ghost()
|
||||||
.large()
|
.large()
|
||||||
|
.disabled(self.uploading)
|
||||||
|
.loading(self.uploading)
|
||||||
.on_click(cx.listener(
|
.on_click(cx.listener(
|
||||||
move |this, _, window, cx| {
|
move |this, _, window, cx| {
|
||||||
this.upload(window, cx);
|
this.upload(window, cx);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use gpui::{
|
|||||||
div, App, AppContext, Context, Entity, IntoElement, ParentElement, Render, SharedString,
|
div, App, AppContext, Context, Entity, IntoElement, ParentElement, Render, SharedString,
|
||||||
Styled, Window,
|
Styled, Window,
|
||||||
};
|
};
|
||||||
use i18n::{shared_t, t};
|
use i18n::t;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::input::{InputState, TextInput};
|
use ui::input::{InputState, TextInput};
|
||||||
use ui::{v_flex, Sizable};
|
use ui::{v_flex, Sizable};
|
||||||
@@ -41,7 +41,7 @@ impl Render for Subject {
|
|||||||
div()
|
div()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.text_color(cx.theme().text_muted)
|
.text_color(cx.theme().text_muted)
|
||||||
.child(shared_t!("subject.title")),
|
.child(SharedString::new(t!("subject.title"))),
|
||||||
)
|
)
|
||||||
.child(TextInput::new(&self.input).small())
|
.child(TextInput::new(&self.input).small())
|
||||||
.child(
|
.child(
|
||||||
@@ -49,7 +49,7 @@ impl Render for Subject {
|
|||||||
.text_xs()
|
.text_xs()
|
||||||
.italic()
|
.italic()
|
||||||
.text_color(cx.theme().text_placeholder)
|
.text_color(cx.theme().text_placeholder)
|
||||||
.child(shared_t!("subject.help_text")),
|
.child(SharedString::new(t!("subject.help_text"))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+291
-260
@@ -2,29 +2,28 @@ use std::ops::Range;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use common::display::{RenderedProfile, TextUtils};
|
use common::display::{ReadableProfile, TextUtils};
|
||||||
use common::nip05::nip05_profile;
|
use common::nip05::nip05_profile;
|
||||||
use global::constants::BOOTSTRAP_RELAYS;
|
use global::constants::BOOTSTRAP_RELAYS;
|
||||||
use global::{app_state, nostr_client};
|
use global::nostr_client;
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, relative, rems, uniform_list, App, AppContext, Context, Entity, InteractiveElement,
|
div, px, relative, rems, uniform_list, AppContext, Context, Entity, InteractiveElement,
|
||||||
IntoElement, ParentElement, Render, RetainAllImageCache, SharedString,
|
IntoElement, ParentElement, Render, SharedString, StatefulInteractiveElement, Styled,
|
||||||
StatefulInteractiveElement, Styled, Subscription, Task, Window,
|
Subscription, Task, Window,
|
||||||
};
|
};
|
||||||
use gpui_tokio::Tokio;
|
use i18n::t;
|
||||||
use i18n::{shared_t, t};
|
use itertools::Itertools;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use registry::room::Room;
|
use registry::room::{Room, RoomKind};
|
||||||
use registry::Registry;
|
use registry::Registry;
|
||||||
use settings::AppSettings;
|
use settings::AppSettings;
|
||||||
use smallvec::{smallvec, SmallVec};
|
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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, ButtonVariants};
|
||||||
use ui::input::{InputEvent, InputState, TextInput};
|
use ui::input::{InputEvent, InputState, TextInput};
|
||||||
use ui::modal::ModalButtonProps;
|
|
||||||
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};
|
||||||
|
|
||||||
@@ -35,46 +34,22 @@ pub fn compose_button() -> impl IntoElement {
|
|||||||
.ghost_alt()
|
.ghost_alt()
|
||||||
.cta()
|
.cta()
|
||||||
.small()
|
.small()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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 weak_view = compose.downgrade();
|
let title = SharedString::new(t!("sidebar.direct_messages"));
|
||||||
|
|
||||||
window.open_modal(cx, move |modal, _window, cx| {
|
window.open_modal(cx, move |modal, _window, _cx| {
|
||||||
let weak_view = weak_view.clone();
|
modal.title(title.clone()).child(compose.clone())
|
||||||
let label = if compose.read(cx).selected(cx).len() > 1 {
|
|
||||||
shared_t!("compose.create_group_dm_button")
|
|
||||||
} else {
|
|
||||||
shared_t!("compose.create_dm_button")
|
|
||||||
};
|
|
||||||
|
|
||||||
modal
|
|
||||||
.alert()
|
|
||||||
.overlay_closable(true)
|
|
||||||
.keyboard(true)
|
|
||||||
.show_close(true)
|
|
||||||
.button_props(ModalButtonProps::default().ok_text(label))
|
|
||||||
.title(shared_t!("sidebar.direct_messages"))
|
|
||||||
.child(compose.clone())
|
|
||||||
.on_ok(move |_, window, cx| {
|
|
||||||
weak_view
|
|
||||||
.update(cx, |this, cx| {
|
|
||||||
this.submit(window, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
|
|
||||||
// false to prevent the modal from closing
|
|
||||||
false
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug)]
|
||||||
struct Contact {
|
struct Contact {
|
||||||
public_key: PublicKey,
|
public_key: PublicKey,
|
||||||
selected: bool,
|
select: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<PublicKey> for Contact {
|
impl AsRef<PublicKey> for Contact {
|
||||||
@@ -87,12 +62,12 @@ impl Contact {
|
|||||||
pub fn new(public_key: PublicKey) -> Self {
|
pub fn new(public_key: PublicKey) -> Self {
|
||||||
Self {
|
Self {
|
||||||
public_key,
|
public_key,
|
||||||
selected: false,
|
select: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selected(mut self) -> Self {
|
pub fn select(mut self) -> Self {
|
||||||
self.selected = true;
|
self.select = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,209 +75,188 @@ impl Contact {
|
|||||||
pub struct Compose {
|
pub struct Compose {
|
||||||
/// Input for the room's subject
|
/// Input for the room's subject
|
||||||
title_input: Entity<InputState>,
|
title_input: Entity<InputState>,
|
||||||
|
|
||||||
/// Input for the room's members
|
/// Input for the room's members
|
||||||
user_input: Entity<InputState>,
|
user_input: Entity<InputState>,
|
||||||
|
/// The current user's contacts
|
||||||
/// User's contacts
|
contacts: Vec<Entity<Contact>>,
|
||||||
contacts: Entity<Vec<Contact>>,
|
/// Input error message
|
||||||
|
|
||||||
/// Error message
|
|
||||||
error_message: Entity<Option<SharedString>>,
|
error_message: Entity<Option<SharedString>>,
|
||||||
|
adding: bool,
|
||||||
image_cache: Entity<RetainAllImageCache>,
|
submitting: bool,
|
||||||
_subscriptions: SmallVec<[Subscription; 2]>,
|
#[allow(dead_code)]
|
||||||
_tasks: SmallVec<[Task<()>; 1]>,
|
subscriptions: SmallVec<[Subscription; 1]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Compose {
|
impl Compose {
|
||||||
pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self {
|
pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self {
|
||||||
let contacts = cx.new(|_| vec![]);
|
|
||||||
let error_message = cx.new(|_| None);
|
|
||||||
|
|
||||||
let user_input =
|
let user_input =
|
||||||
cx.new(|cx| InputState::new(window, cx).placeholder("npub or nprofile..."));
|
cx.new(|cx| InputState::new(window, cx).placeholder(t!("compose.placeholder_npub")));
|
||||||
|
|
||||||
let title_input =
|
let title_input =
|
||||||
cx.new(|cx| InputState::new(window, cx).placeholder("Family...(Optional)"));
|
cx.new(|cx| InputState::new(window, cx).placeholder(t!("compose.placeholder_title")));
|
||||||
|
|
||||||
|
let error_message = cx.new(|_| None);
|
||||||
let mut subscriptions = smallvec![];
|
let mut subscriptions = smallvec![];
|
||||||
let mut tasks = smallvec![];
|
|
||||||
|
// Handle Enter event for user input
|
||||||
|
subscriptions.push(cx.subscribe_in(
|
||||||
|
&user_input,
|
||||||
|
window,
|
||||||
|
move |this, _input, event, window, cx| {
|
||||||
|
if let InputEvent::PressEnter { .. } = event {
|
||||||
|
this.add_and_select_contact(window, cx)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
let get_contacts: Task<Result<Vec<Contact>, Error>> = cx.background_spawn(async move {
|
let get_contacts: Task<Result<Vec<Contact>, Error>> = cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let signer = client.signer().await?;
|
let signer = client.signer().await?;
|
||||||
let public_key = signer.get_public_key().await?;
|
let public_key = signer.get_public_key().await?;
|
||||||
let profiles = client.database().contacts(public_key).await?;
|
let profiles = client.database().contacts(public_key).await?;
|
||||||
let contacts: Vec<Contact> = profiles
|
let contacts = profiles
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|profile| Contact::new(profile.public_key()))
|
.map(|profile| Contact::new(profile.public_key()))
|
||||||
.collect();
|
.collect_vec();
|
||||||
|
|
||||||
Ok(contacts)
|
Ok(contacts)
|
||||||
});
|
});
|
||||||
|
|
||||||
tasks.push(
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
// Load all contacts
|
match get_contacts.await {
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
Ok(contacts) => {
|
||||||
match get_contacts.await {
|
this.update(cx, |this, cx| {
|
||||||
Ok(contacts) => {
|
this.extend_contacts(contacts, cx);
|
||||||
this.update(cx, |this, cx| {
|
})
|
||||||
this.extend_contacts(contacts, cx);
|
.ok();
|
||||||
})
|
}
|
||||||
.ok();
|
Err(e) => {
|
||||||
}
|
cx.update(|window, cx| {
|
||||||
Err(e) => {
|
window.push_notification(Notification::error(e.to_string()), cx);
|
||||||
cx.update(|window, cx| {
|
})
|
||||||
window.push_notification(Notification::error(e.to_string()), cx);
|
.ok();
|
||||||
})
|
}
|
||||||
.ok();
|
};
|
||||||
}
|
})
|
||||||
};
|
.detach();
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
subscriptions.push(
|
|
||||||
// Clear the image cache when sidebar is closed
|
|
||||||
cx.on_release_in(window, move |this, window, cx| {
|
|
||||||
this.image_cache.update(cx, |this, cx| {
|
|
||||||
this.clear(window, cx);
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
subscriptions.push(
|
|
||||||
// Handle Enter event for user input
|
|
||||||
cx.subscribe_in(
|
|
||||||
&user_input,
|
|
||||||
window,
|
|
||||||
move |this, _input, event, window, cx| {
|
|
||||||
if let InputEvent::PressEnter { .. } = event {
|
|
||||||
this.add_and_select_contact(window, cx)
|
|
||||||
};
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
adding: false,
|
||||||
|
submitting: false,
|
||||||
|
contacts: vec![],
|
||||||
title_input,
|
title_input,
|
||||||
user_input,
|
user_input,
|
||||||
error_message,
|
error_message,
|
||||||
contacts,
|
subscriptions,
|
||||||
image_cache: RetainAllImageCache::new(cx),
|
|
||||||
_subscriptions: subscriptions,
|
|
||||||
_tasks: tasks,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn request_metadata(public_key: PublicKey) -> Result<(), Error> {
|
async fn request_metadata(client: &Client, public_key: PublicKey) -> Result<(), Error> {
|
||||||
let client = nostr_client();
|
let opts = SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE);
|
||||||
let app_state = app_state();
|
|
||||||
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
|
let kinds = vec![Kind::Metadata, Kind::ContactList, Kind::RelayList];
|
||||||
let filter = Filter::new().author(public_key).kinds(kinds).limit(10);
|
let filter = Filter::new().author(public_key).kinds(kinds).limit(10);
|
||||||
|
|
||||||
client
|
client
|
||||||
.subscribe_to(BOOTSTRAP_RELAYS, filter, app_state.auto_close_opts)
|
.subscribe_to(BOOTSTRAP_RELAYS, filter, Some(opts))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
let public_keys: Vec<PublicKey> = self.selected(cx);
|
||||||
|
|
||||||
|
if public_keys.is_empty() {
|
||||||
|
self.set_error(Some(t!("compose.receiver_required").into()), cx);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Show loading spinner
|
||||||
|
self.set_submitting(true, cx);
|
||||||
|
|
||||||
|
// Convert selected pubkeys into Nostr tags
|
||||||
|
let mut tag_list: Vec<Tag> = public_keys.iter().map(|pk| Tag::public_key(*pk)).collect();
|
||||||
|
|
||||||
|
// Add subject if it is present
|
||||||
|
if !self.title_input.read(cx).value().is_empty() {
|
||||||
|
tag_list.push(Tag::custom(
|
||||||
|
TagKind::Subject,
|
||||||
|
vec![self.title_input.read(cx).value().to_string()],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let event: Task<Result<Room, Error>> = cx.background_spawn(async move {
|
||||||
|
let signer = nostr_client().signer().await?;
|
||||||
|
let public_key = signer.get_public_key().await?;
|
||||||
|
|
||||||
|
let room = EventBuilder::private_msg_rumor(public_keys[0], "")
|
||||||
|
.tags(Tags::from_list(tag_list))
|
||||||
|
.build(public_key)
|
||||||
|
.sign(&Keys::generate())
|
||||||
|
.await
|
||||||
|
.map(|event| Room::new(&event).kind(RoomKind::Ongoing))?;
|
||||||
|
|
||||||
|
Ok(room)
|
||||||
|
});
|
||||||
|
|
||||||
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
|
match event.await {
|
||||||
|
Ok(room) => {
|
||||||
|
cx.update(|window, cx| {
|
||||||
|
let registry = Registry::global(cx);
|
||||||
|
// Reset local state
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.set_submitting(false, cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
// Create and insert the new room into the registry
|
||||||
|
registry.update(cx, |this, cx| {
|
||||||
|
this.push_room(cx.new(|_| room), cx);
|
||||||
|
});
|
||||||
|
// Close the current modal
|
||||||
|
window.close_modal(cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.set_error(Some(e.to_string().into()), cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
|
|
||||||
fn extend_contacts<I>(&mut self, contacts: I, cx: &mut Context<Self>)
|
fn extend_contacts<I>(&mut self, contacts: I, cx: &mut Context<Self>)
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = Contact>,
|
I: IntoIterator<Item = Contact>,
|
||||||
{
|
{
|
||||||
self.contacts.update(cx, |this, cx| {
|
self.contacts
|
||||||
this.extend(contacts);
|
.extend(contacts.into_iter().map(|contact| cx.new(|_| contact)));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_contact(&mut self, contact: Contact, window: &mut Window, cx: &mut Context<Self>) {
|
fn push_contact(&mut self, contact: Contact, cx: &mut Context<Self>) {
|
||||||
let pk = contact.public_key;
|
if !self
|
||||||
|
.contacts
|
||||||
if !self.contacts.read(cx).iter().any(|c| c.public_key == pk) {
|
.iter()
|
||||||
self._tasks.push(cx.background_spawn(async move {
|
.any(|e| e.read(cx).public_key == contact.public_key)
|
||||||
Self::request_metadata(pk).await.ok();
|
{
|
||||||
}));
|
self.contacts.insert(0, cx.new(|_| contact));
|
||||||
|
cx.notify();
|
||||||
cx.defer_in(window, |this, window, cx| {
|
|
||||||
this.contacts.update(cx, |this, cx| {
|
|
||||||
this.insert(0, contact);
|
|
||||||
cx.notify();
|
|
||||||
});
|
|
||||||
this.user_input.update(cx, |this, cx| {
|
|
||||||
this.set_value("", window, cx);
|
|
||||||
this.set_loading(false, cx);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
self.set_error(Some(t!("compose.contact_existed").into()), cx);
|
self.set_error(Some(t!("compose.contact_existed").into()), cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_contact(&mut self, public_key: PublicKey, cx: &mut Context<Self>) {
|
fn selected(&self, cx: &Context<Self>) -> Vec<PublicKey> {
|
||||||
self.contacts.update(cx, |this, cx| {
|
|
||||||
if let Some(contact) = this.iter_mut().find(|c| c.public_key == public_key) {
|
|
||||||
contact.selected = true;
|
|
||||||
}
|
|
||||||
cx.notify();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_and_select_contact(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
|
||||||
let content = self.user_input.read(cx).value().to_string();
|
|
||||||
|
|
||||||
// Show loading indicator in the input
|
|
||||||
self.user_input.update(cx, |this, cx| {
|
|
||||||
this.set_loading(true, cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Ok(public_key) = content.to_public_key() {
|
|
||||||
let contact = Contact::new(public_key).selected();
|
|
||||||
self.push_contact(contact, window, cx);
|
|
||||||
} else if content.contains("@") {
|
|
||||||
let task = Tokio::spawn(cx, async move {
|
|
||||||
if let Ok(profile) = nip05_profile(&content).await {
|
|
||||||
let public_key = profile.public_key;
|
|
||||||
let contact = Contact::new(public_key).selected();
|
|
||||||
|
|
||||||
Ok(contact)
|
|
||||||
} else {
|
|
||||||
Err(anyhow!("Not found"))
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
|
||||||
match task.await {
|
|
||||||
Ok(Ok(contact)) => {
|
|
||||||
this.update_in(cx, |this, window, cx| {
|
|
||||||
this.push_contact(contact, window, cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
Ok(Err(e)) => {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.set_error(Some(e.to_string().into()), cx);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Tokio error: {e}");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn selected(&self, cx: &App) -> Vec<PublicKey> {
|
|
||||||
self.contacts
|
self.contacts
|
||||||
.read(cx)
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|contact| {
|
.filter_map(|contact| {
|
||||||
if contact.selected {
|
if contact.read(cx).select {
|
||||||
Some(contact.public_key)
|
Some(contact.read(cx).public_key)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@@ -310,49 +264,84 @@ impl Compose {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn add_and_select_contact(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let registry = Registry::global(cx);
|
let content = self.user_input.read(cx).value().to_string();
|
||||||
let public_keys: Vec<PublicKey> = self.selected(cx);
|
|
||||||
|
|
||||||
if !self.user_input.read(cx).value().is_empty() {
|
// Prevent multiple requests
|
||||||
self.add_and_select_contact(window, cx);
|
self.set_adding(true, cx);
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if public_keys.is_empty() {
|
// Show loading indicator in the input
|
||||||
self.set_error(Some(t!("compose.receiver_required").into()), cx);
|
self.user_input.update(cx, |this, cx| {
|
||||||
return;
|
this.set_loading(true, cx);
|
||||||
};
|
|
||||||
|
|
||||||
// Convert selected pubkeys into Nostr tags
|
|
||||||
let mut tags: Tags = Tags::from_list(
|
|
||||||
public_keys
|
|
||||||
.iter()
|
|
||||||
.map(|pubkey| Tag::public_key(pubkey.to_owned()))
|
|
||||||
.collect(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add subject if it is present
|
|
||||||
if !self.title_input.read(cx).value().is_empty() {
|
|
||||||
tags.push(Tag::custom(
|
|
||||||
TagKind::Subject,
|
|
||||||
vec![self.title_input.read(cx).value().to_string()],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new room
|
|
||||||
let room = Room::new(public_keys[0], tags, cx);
|
|
||||||
|
|
||||||
// Insert the new room into the registry
|
|
||||||
registry.update(cx, |this, cx| {
|
|
||||||
this.push_room(cx.new(|_| room), cx);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close the current modal
|
let task: Task<Result<Contact, Error>> = if content.contains("@") {
|
||||||
window.close_modal(cx);
|
cx.background_spawn(async move {
|
||||||
|
let (tx, rx) = oneshot::channel::<Option<Nip05Profile>>();
|
||||||
|
|
||||||
|
nostr_sdk::async_utility::task::spawn(async move {
|
||||||
|
let profile = nip05_profile(&content).await.ok();
|
||||||
|
tx.send(profile).ok();
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Ok(Some(profile)) = rx.await {
|
||||||
|
let client = nostr_client();
|
||||||
|
let public_key = profile.public_key;
|
||||||
|
let contact = Contact::new(public_key).select();
|
||||||
|
|
||||||
|
Self::request_metadata(client, public_key).await?;
|
||||||
|
|
||||||
|
Ok(contact)
|
||||||
|
} else {
|
||||||
|
Err(anyhow!(t!("common.not_found")))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if let Ok(public_key) = content.to_public_key() {
|
||||||
|
cx.background_spawn(async move {
|
||||||
|
let client = nostr_client();
|
||||||
|
let contact = Contact::new(public_key).select();
|
||||||
|
|
||||||
|
Self::request_metadata(client, public_key).await?;
|
||||||
|
|
||||||
|
Ok(contact)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
self.set_error(Some(t!("common.pubkey_invalid").into()), cx);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
|
match task.await {
|
||||||
|
Ok(contact) => {
|
||||||
|
cx.update(|window, cx| {
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.push_contact(contact, cx);
|
||||||
|
this.set_adding(false, cx);
|
||||||
|
this.user_input.update(cx, |this, cx| {
|
||||||
|
this.set_value("", window, cx);
|
||||||
|
this.set_loading(false, cx);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
this.update(cx, |this, cx| {
|
||||||
|
this.set_error(Some(e.to_string().into()), cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_error(&mut self, error: impl Into<Option<SharedString>>, cx: &mut Context<Self>) {
|
fn set_error(&mut self, error: impl Into<Option<SharedString>>, cx: &mut Context<Self>) {
|
||||||
|
if self.adding {
|
||||||
|
self.set_adding(false, cx);
|
||||||
|
}
|
||||||
|
|
||||||
// Unlock the user input
|
// Unlock the user input
|
||||||
self.user_input.update(cx, |this, cx| {
|
self.user_input.update(cx, |this, cx| {
|
||||||
this.set_loading(false, cx);
|
this.set_loading(false, cx);
|
||||||
@@ -375,35 +364,48 @@ impl Compose {
|
|||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_adding(&mut self, status: bool, cx: &mut Context<Self>) {
|
||||||
|
self.adding = status;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_submitting(&mut self, status: bool, cx: &mut Context<Self>) {
|
||||||
|
self.submitting = status;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
fn list_items(&self, range: Range<usize>, cx: &Context<Self>) -> Vec<impl IntoElement> {
|
fn list_items(&self, range: Range<usize>, cx: &Context<Self>) -> Vec<impl IntoElement> {
|
||||||
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
let mut items = Vec::with_capacity(self.contacts.read(cx).len());
|
let mut items = Vec::with_capacity(self.contacts.len());
|
||||||
|
|
||||||
for ix in range {
|
for ix in range {
|
||||||
let Some(contact) = self.contacts.read(cx).get(ix) else {
|
let Some(entity) = self.contacts.get(ix).cloned() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let public_key = contact.public_key;
|
let public_key = entity.read(cx).as_ref();
|
||||||
let profile = registry.get_person(&public_key, cx);
|
let profile = registry.get_person(public_key, cx);
|
||||||
|
let selected = entity.read(cx).select;
|
||||||
|
|
||||||
items.push(
|
items.push(
|
||||||
h_flex()
|
h_flex()
|
||||||
.id(ix)
|
.id(ix)
|
||||||
.px_2()
|
.px_1()
|
||||||
.h_11()
|
.h_9()
|
||||||
.w_full()
|
.w_full()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.rounded(cx.theme().radius)
|
.rounded(cx.theme().radius)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
div()
|
||||||
|
.flex()
|
||||||
|
.items_center()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.child(Avatar::new(profile.avatar(proxy)).size(rems(1.75)))
|
.child(Avatar::new(profile.avatar_url(proxy)).size(rems(1.75)))
|
||||||
.child(profile.display_name()),
|
.child(profile.display_name()),
|
||||||
)
|
)
|
||||||
.when(contact.selected, |this| {
|
.when(selected, |this| {
|
||||||
this.child(
|
this.child(
|
||||||
Icon::new(IconName::CheckCircleFill)
|
Icon::new(IconName::CheckCircleFill)
|
||||||
.small()
|
.small()
|
||||||
@@ -411,8 +413,11 @@ impl Compose {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.hover(|this| this.bg(cx.theme().elevated_surface_background))
|
.hover(|this| this.bg(cx.theme().elevated_surface_background))
|
||||||
.on_click(cx.listener(move |this, _, _window, cx| {
|
.on_click(cx.listener(move |_this, _event, _window, cx| {
|
||||||
this.select_contact(public_key, cx);
|
entity.update(cx, |this, cx| {
|
||||||
|
this.select = !this.select;
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -423,18 +428,24 @@ impl Compose {
|
|||||||
|
|
||||||
impl Render for Compose {
|
impl Render for Compose {
|
||||||
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 label = if self.submitting {
|
||||||
|
t!("compose.creating_dm_button")
|
||||||
|
} else if self.selected(cx).len() > 1 {
|
||||||
|
t!("compose.create_group_dm_button")
|
||||||
|
} else {
|
||||||
|
t!("compose.create_dm_button")
|
||||||
|
};
|
||||||
|
|
||||||
let error = self.error_message.read(cx).as_ref();
|
let error = self.error_message.read(cx).as_ref();
|
||||||
let loading = self.user_input.read(cx).loading(cx);
|
|
||||||
let contacts = self.contacts.read(cx);
|
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.image_cache(self.image_cache.clone())
|
.mb_4()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.text_color(cx.theme().text_muted)
|
.text_color(cx.theme().text_muted)
|
||||||
.child(shared_t!("compose.description")),
|
.child(SharedString::new(t!("compose.description"))),
|
||||||
)
|
)
|
||||||
.when_some(error, |this, msg| {
|
.when_some(error, |this, msg| {
|
||||||
this.child(
|
this.child(
|
||||||
@@ -455,13 +466,13 @@ impl Render for Compose {
|
|||||||
div()
|
div()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
.child(shared_t!("compose.subject_label")),
|
.child(SharedString::new(t!("compose.subject_label"))),
|
||||||
)
|
)
|
||||||
.child(TextInput::new(&self.title_input).small().appearance(false)),
|
.child(TextInput::new(&self.title_input).small().appearance(false)),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.pt_1()
|
.my_1()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
@@ -470,18 +481,22 @@ impl Render for Compose {
|
|||||||
div()
|
div()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
.child(shared_t!("compose.to_label")),
|
.child(SharedString::new(t!("compose.to_label"))),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextInput::new(&self.user_input)
|
h_flex()
|
||||||
.small()
|
.gap_1()
|
||||||
.disabled(loading)
|
.child(
|
||||||
.suffix(
|
TextInput::new(&self.user_input)
|
||||||
|
.small()
|
||||||
|
.disabled(self.adding),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
Button::new("add")
|
Button::new("add")
|
||||||
.icon(IconName::PlusCircleFill)
|
.icon(IconName::PlusCircleFill)
|
||||||
.transparent()
|
.ghost()
|
||||||
.small()
|
.loading(self.adding)
|
||||||
.disabled(loading)
|
.disabled(self.adding)
|
||||||
.on_click(cx.listener(move |this, _, window, cx| {
|
.on_click(cx.listener(move |this, _, window, cx| {
|
||||||
this.add_and_select_contact(window, cx);
|
this.add_and_select_contact(window, cx);
|
||||||
})),
|
})),
|
||||||
@@ -489,7 +504,7 @@ impl Render for Compose {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.map(|this| {
|
.map(|this| {
|
||||||
if contacts.is_empty() {
|
if self.contacts.is_empty() {
|
||||||
this.child(
|
this.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.h_24()
|
.h_24()
|
||||||
@@ -497,32 +512,48 @@ impl Render for Compose {
|
|||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.text_center()
|
.text_center()
|
||||||
.text_xs()
|
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
.text_xs()
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
.line_height(relative(1.2))
|
.line_height(relative(1.2))
|
||||||
.child(shared_t!("compose.no_contacts_message")),
|
.child(SharedString::new(t!(
|
||||||
|
"compose.no_contacts_message"
|
||||||
|
))),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div().text_xs().text_color(cx.theme().text_muted).child(
|
||||||
.text_color(cx.theme().text_muted)
|
SharedString::new(t!(
|
||||||
.child(shared_t!("compose.no_contacts_description")),
|
"compose.no_contacts_description"
|
||||||
|
)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.child(
|
this.child(
|
||||||
uniform_list(
|
uniform_list(
|
||||||
"contacts",
|
"contacts",
|
||||||
contacts.len(),
|
self.contacts.len(),
|
||||||
cx.processor(move |this, range, _window, cx| {
|
cx.processor(move |this, range, _window, cx| {
|
||||||
this.list_items(range, cx)
|
this.list_items(range, cx)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.h(px(300.)),
|
.min_h(px(300.)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
.child(
|
||||||
|
Button::new("create_dm_btn")
|
||||||
|
.label(label)
|
||||||
|
.primary()
|
||||||
|
.small()
|
||||||
|
.w_full()
|
||||||
|
.loading(self.submitting)
|
||||||
|
.disabled(self.submitting || self.adding)
|
||||||
|
.on_click(cx.listener(move |this, _event, window, cx| {
|
||||||
|
this.submit(window, cx);
|
||||||
|
})),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use gpui::{
|
|||||||
div, img, App, AppContext, Context, Entity, Flatten, IntoElement, ParentElement,
|
div, img, App, AppContext, Context, Entity, Flatten, IntoElement, ParentElement,
|
||||||
PathPromptOptions, Render, SharedString, Styled, Task, Window,
|
PathPromptOptions, Render, SharedString, Styled, Task, Window,
|
||||||
};
|
};
|
||||||
use i18n::{shared_t, t};
|
use i18n::t;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use settings::AppSettings;
|
use settings::AppSettings;
|
||||||
use smol::fs;
|
use smol::fs;
|
||||||
@@ -260,7 +260,7 @@ impl Render for EditProfile {
|
|||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.child(shared_t!("profile.label_name"))
|
.child(SharedString::new(t!("profile.label_name")))
|
||||||
.child(TextInput::new(&self.name_input).small()),
|
.child(TextInput::new(&self.name_input).small()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
@@ -269,7 +269,7 @@ impl Render for EditProfile {
|
|||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.child(shared_t!("profile.label_website"))
|
.child(SharedString::new(t!("profile.label_website")))
|
||||||
.child(TextInput::new(&self.website_input).small()),
|
.child(TextInput::new(&self.website_input).small()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
@@ -278,7 +278,7 @@ impl Render for EditProfile {
|
|||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.child(shared_t!("profile.label_bio"))
|
.child(SharedString::new(t!("profile.label_bio")))
|
||||||
.child(TextInput::new(&self.bio_input).small()),
|
.child(TextInput::new(&self.bio_input).small()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use client_keys::ClientKeys;
|
use client_keys::ClientKeys;
|
||||||
|
use common::handle_auth::CoopAuthUrlHandler;
|
||||||
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
|
use global::constants::{ACCOUNT_IDENTIFIER, BUNKER_TIMEOUT};
|
||||||
use global::nostr_client;
|
use global::nostr_client;
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
@@ -18,8 +19,6 @@ use ui::input::{InputEvent, InputState, TextInput};
|
|||||||
use ui::popup_menu::PopupMenu;
|
use ui::popup_menu::PopupMenu;
|
||||||
use ui::{v_flex, ContextModal, Disableable, Sizable, StyledExt};
|
use ui::{v_flex, ContextModal, Disableable, Sizable, StyledExt};
|
||||||
|
|
||||||
use crate::actions::CoopAuthUrlHandler;
|
|
||||||
|
|
||||||
pub fn init(window: &mut Window, cx: &mut App) -> Entity<Login> {
|
pub fn init(window: &mut Window, cx: &mut App) -> Entity<Login> {
|
||||||
Login::new(window, cx)
|
Login::new(window, cx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, 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()
|
.rounded(ButtonRounded::Full)
|
||||||
.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| {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use common::display::RenderedProfile;
|
use common::display::ReadableProfile;
|
||||||
use gpui::http_client::Url;
|
use gpui::http_client::Url;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, relative, rems, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
|
div, px, relative, rems, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
|
||||||
@@ -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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, 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;
|
||||||
@@ -141,7 +141,7 @@ impl Render for Preferences {
|
|||||||
h_flex()
|
h_flex()
|
||||||
.id("user")
|
.id("user")
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(Avatar::new(profile.avatar(proxy)).size(rems(2.4)))
|
.child(Avatar::new(profile.avatar_url(proxy)).size(rems(2.4)))
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
@@ -169,7 +169,7 @@ impl Render for Preferences {
|
|||||||
.label("Messaging Relays")
|
.label("Messaging Relays")
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost_alt()
|
.ghost_alt()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use common::display::{shorten_pubkey, RenderedProfile, RenderedTimestamp};
|
use common::display::{shorten_pubkey, ReadableProfile, ReadableTimestamp};
|
||||||
use common::nip05::nip05_verify;
|
use common::nip05::nip05_verify;
|
||||||
use global::constants::BOOTSTRAP_RELAYS;
|
use global::constants::BOOTSTRAP_RELAYS;
|
||||||
use global::nostr_client;
|
use global::nostr_client;
|
||||||
@@ -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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, 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,9 +29,10 @@ 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<()>; 3]>,
|
_tasks: SmallVec<[Task<()>; 4]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Screening {
|
impl Screening {
|
||||||
@@ -82,6 +83,24 @@ 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)
|
||||||
@@ -117,6 +136,19 @@ 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| {
|
||||||
@@ -136,6 +168,7 @@ 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,
|
||||||
@@ -202,7 +235,9 @@ impl Screening {
|
|||||||
.hover(|this| {
|
.hover(|this| {
|
||||||
this.bg(cx.theme().elevated_surface_background)
|
this.bg(cx.theme().elevated_surface_background)
|
||||||
})
|
})
|
||||||
.child(Avatar::new(contact.avatar(true)).size(rems(1.75)))
|
.child(
|
||||||
|
Avatar::new(contact.avatar_url(true)).size(rems(1.75)),
|
||||||
|
)
|
||||||
.child(contact.display_name()),
|
.child(contact.display_name()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -232,7 +267,7 @@ impl Render for Screening {
|
|||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.text_center()
|
.text_center()
|
||||||
.child(Avatar::new(self.profile.avatar(proxy)).size(rems(4.)))
|
.child(Avatar::new(self.profile.avatar_url(proxy)).size(rems(4.)))
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
@@ -266,7 +301,7 @@ impl Render for Screening {
|
|||||||
.label(t!("profile.njump"))
|
.label(t!("profile.njump"))
|
||||||
.secondary()
|
.secondary()
|
||||||
.small()
|
.small()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
})),
|
})),
|
||||||
@@ -276,7 +311,7 @@ impl Render for Screening {
|
|||||||
.tooltip(t!("screening.report"))
|
.tooltip(t!("screening.report"))
|
||||||
.icon(IconName::Report)
|
.icon(IconName::Report)
|
||||||
.danger()
|
.danger()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
})),
|
})),
|
||||||
@@ -328,7 +363,7 @@ impl Render for Screening {
|
|||||||
.icon(IconName::Info)
|
.icon(IconName::Info)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost()
|
.ghost()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.tooltip(t!("screening.active_tooltip")),
|
.tooltip(t!("screening.active_tooltip")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -400,7 +435,7 @@ impl Render for Screening {
|
|||||||
.icon(IconName::Info)
|
.icon(IconName::Info)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost()
|
.ghost()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
@@ -421,6 +456,37 @@ 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")
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use global::constants::NIP17_RELAYS;
|
use global::constants::NIP17_RELAYS;
|
||||||
use global::{app_state, nostr_client};
|
use global::{css, nostr_client};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, uniform_list, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
|
div, px, uniform_list, App, AppContext, Context, Entity, InteractiveElement, IntoElement,
|
||||||
@@ -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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, 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()
|
.rounded(ButtonRounded::Full)
|
||||||
.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();
|
||||||
@@ -218,7 +218,7 @@ impl SetupRelay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch gift wrap events
|
// Fetch gift wrap events
|
||||||
let sub_id = app_state().gift_wrap_sub_id.clone();
|
let sub_id = css().gift_wrap_sub_id.clone();
|
||||||
let filter = Filter::new().kind(Kind::GiftWrap).pubkey(public_key);
|
let filter = Filter::new().kind(Kind::GiftWrap).pubkey(public_key);
|
||||||
|
|
||||||
if client
|
if client
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::rc::Rc;
|
|||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, rems, App, ClickEvent, InteractiveElement, IntoElement, ParentElement as _, RenderOnce,
|
div, rems, App, ClickEvent, InteractiveElement, IntoElement, ParentElement as _, RenderOnce,
|
||||||
SharedString, SharedUri, StatefulInteractiveElement, Styled, Window,
|
SharedString, StatefulInteractiveElement, Styled, Window,
|
||||||
};
|
};
|
||||||
use i18n::t;
|
use i18n::t;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
@@ -24,7 +24,7 @@ pub struct RoomListItem {
|
|||||||
room_id: Option<u64>,
|
room_id: Option<u64>,
|
||||||
public_key: Option<PublicKey>,
|
public_key: Option<PublicKey>,
|
||||||
name: Option<SharedString>,
|
name: Option<SharedString>,
|
||||||
avatar: Option<SharedUri>,
|
avatar: Option<SharedString>,
|
||||||
created_at: Option<SharedString>,
|
created_at: Option<SharedString>,
|
||||||
kind: Option<RoomKind>,
|
kind: Option<RoomKind>,
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
@@ -60,7 +60,7 @@ impl RoomListItem {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn avatar(mut self, avatar: impl Into<SharedUri>) -> Self {
|
pub fn avatar(mut self, avatar: impl Into<SharedString>) -> Self {
|
||||||
self.avatar = Some(avatar.into());
|
self.avatar = Some(avatar.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use common::debounced_delay::DebouncedDelay;
|
use common::debounced_delay::DebouncedDelay;
|
||||||
use common::display::{RenderedTimestamp, TextUtils};
|
use common::display::{ReadableTimestamp, TextUtils};
|
||||||
use global::constants::{BOOTSTRAP_RELAYS, SEARCH_RELAYS};
|
use global::constants::{BOOTSTRAP_RELAYS, SEARCH_RELAYS};
|
||||||
use global::{app_state, nostr_client, UnwrappingStatus};
|
use global::{css, nostr_client, UnwrappingStatus};
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
deferred, div, relative, uniform_list, AnyElement, App, AppContext, Context, Entity,
|
div, uniform_list, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle,
|
||||||
EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render,
|
Focusable, InteractiveElement, IntoElement, ParentElement, Render, RetainAllImageCache,
|
||||||
RetainAllImageCache, SharedString, Styled, Subscription, Task, Window,
|
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, ButtonVariants};
|
use ui::button::{Button, ButtonRounded, 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};
|
||||||
@@ -56,7 +56,7 @@ pub struct Sidebar {
|
|||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
image_cache: Entity<RetainAllImageCache>,
|
image_cache: Entity<RetainAllImageCache>,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
subscriptions: SmallVec<[Subscription; 3]>,
|
subscriptions: SmallVec<[Subscription; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sidebar {
|
impl Sidebar {
|
||||||
@@ -77,30 +77,23 @@ impl Sidebar {
|
|||||||
let registry = Registry::global(cx);
|
let registry = Registry::global(cx);
|
||||||
let mut subscriptions = smallvec![];
|
let mut subscriptions = smallvec![];
|
||||||
|
|
||||||
subscriptions.push(
|
subscriptions.push(cx.subscribe_in(
|
||||||
// Clear the image cache when sidebar is closed
|
®istry,
|
||||||
cx.on_release_in(window, move |this, window, cx| {
|
window,
|
||||||
this.image_cache.update(cx, |this, cx| {
|
move |this, _, event, _window, cx| {
|
||||||
this.clear(window, cx);
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
subscriptions.push(
|
|
||||||
// Subscribe for registry new events
|
|
||||||
cx.subscribe_in(®istry, window, move |this, _, event, _window, cx| {
|
|
||||||
if let RegistryEvent::NewRequest(kind) = event {
|
if let RegistryEvent::NewRequest(kind) = event {
|
||||||
this.indicator.update(cx, |this, cx| {
|
this.indicator.update(cx, |this, cx| {
|
||||||
*this = Some(kind.to_owned());
|
*this = Some(kind.to_owned());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
);
|
));
|
||||||
|
|
||||||
subscriptions.push(
|
subscriptions.push(cx.subscribe_in(
|
||||||
// Subscribe for find input events
|
&find_input,
|
||||||
cx.subscribe_in(&find_input, window, |this, _state, event, window, cx| {
|
window,
|
||||||
|
|this, _state, event, window, cx| {
|
||||||
match event {
|
match event {
|
||||||
InputEvent::PressEnter { .. } => this.search(window, cx),
|
InputEvent::PressEnter { .. } => this.search(window, cx),
|
||||||
InputEvent::Change(text) => {
|
InputEvent::Change(text) => {
|
||||||
@@ -119,8 +112,8 @@ impl Sidebar {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
);
|
));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
name: "Sidebar".into(),
|
name: "Sidebar".into(),
|
||||||
@@ -162,7 +155,7 @@ impl Sidebar {
|
|||||||
Self::request_metadata(client, public_key).await?;
|
Self::request_metadata(client, public_key).await?;
|
||||||
|
|
||||||
// Create a temporary room
|
// Create a temporary room
|
||||||
let room = Room::from(&event).current_user(identity);
|
let room = Room::new(&event).rearrange_by(identity);
|
||||||
|
|
||||||
Ok(room)
|
Ok(room)
|
||||||
}
|
}
|
||||||
@@ -537,8 +530,8 @@ impl Sidebar {
|
|||||||
fn on_manage(&mut self, _ev: &RelayStatus, window: &mut Window, cx: &mut Context<Self>) {
|
fn on_manage(&mut self, _ev: &RelayStatus, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let task: Task<Result<Vec<Relay>, Error>> = cx.background_spawn(async move {
|
let task: Task<Result<Vec<Relay>, Error>> = cx.background_spawn(async move {
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let app_state = app_state();
|
let css = css();
|
||||||
let subscription = client.subscription(&app_state.gift_wrap_sub_id).await;
|
let subscription = client.subscription(&css.gift_wrap_sub_id).await;
|
||||||
let mut relays: Vec<Relay> = vec![];
|
let mut relays: Vec<Relay> = vec![];
|
||||||
|
|
||||||
for (url, _filter) in subscription.into_iter() {
|
for (url, _filter) in subscription.into_iter() {
|
||||||
@@ -676,7 +669,6 @@ 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() {
|
||||||
@@ -696,7 +688,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 loading {
|
if registry.unwrapping_status.read(cx) != &UnwrappingStatus::Complete {
|
||||||
total_rooms += 3
|
total_rooms += 3
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,16 +743,16 @@ impl Render for Sidebar {
|
|||||||
.tooltip(t!("sidebar.all_conversations_tooltip"))
|
.tooltip(t!("sidebar.all_conversations_tooltip"))
|
||||||
.when_some(self.indicator.read(cx).as_ref(), |this, kind| {
|
.when_some(self.indicator.read(cx).as_ref(), |this, kind| {
|
||||||
this.when(kind == &RoomKind::Ongoing, |this| {
|
this.when(kind == &RoomKind::Ongoing, |this| {
|
||||||
this.child(deferred(
|
this.child(
|
||||||
div().size_1().rounded_full().bg(cx.theme().cursor),
|
div().size_1().rounded_full().bg(cx.theme().cursor),
|
||||||
))
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.small()
|
.small()
|
||||||
.cta()
|
.cta()
|
||||||
.bold()
|
.bold()
|
||||||
.secondary()
|
.secondary()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
@@ -772,16 +764,16 @@ impl Render for Sidebar {
|
|||||||
.tooltip(t!("sidebar.requests_tooltip"))
|
.tooltip(t!("sidebar.requests_tooltip"))
|
||||||
.when_some(self.indicator.read(cx).as_ref(), |this, kind| {
|
.when_some(self.indicator.read(cx).as_ref(), |this, kind| {
|
||||||
this.when(kind != &RoomKind::Ongoing, |this| {
|
this.when(kind != &RoomKind::Ongoing, |this| {
|
||||||
this.child(deferred(
|
this.child(
|
||||||
div().size_1().rounded_full().bg(cx.theme().cursor),
|
div().size_1().rounded_full().bg(cx.theme().cursor),
|
||||||
))
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.small()
|
.small()
|
||||||
.cta()
|
.cta()
|
||||||
.bold()
|
.bold()
|
||||||
.secondary()
|
.secondary()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.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);
|
||||||
@@ -799,7 +791,7 @@ impl Render for Sidebar {
|
|||||||
.icon(IconName::Ellipsis)
|
.icon(IconName::Ellipsis)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.ghost()
|
.ghost()
|
||||||
.rounded()
|
.rounded(ButtonRounded::Full)
|
||||||
.popup_menu(move |this, _window, _cx| {
|
.popup_menu(move |this, _window, _cx| {
|
||||||
this.menu(
|
this.menu(
|
||||||
t!("sidebar.reload_menu"),
|
t!("sidebar.reload_menu"),
|
||||||
@@ -813,57 +805,6 @@ impl Render for Sidebar {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.when(!loading && total_rooms == 0, |this| {
|
|
||||||
this.map(|this| {
|
|
||||||
if self.filter(&RoomKind::Ongoing, cx) {
|
|
||||||
this.child(deferred(
|
|
||||||
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(deferred(
|
|
||||||
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,6 +1,6 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use common::display::RenderedProfile;
|
use common::display::ReadableProfile;
|
||||||
use common::nip05::nip05_verify;
|
use common::nip05::nip05_verify;
|
||||||
use global::nostr_client;
|
use global::nostr_client;
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
@@ -128,8 +128,9 @@ impl UserProfile {
|
|||||||
impl Render for UserProfile {
|
impl Render for UserProfile {
|
||||||
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 proxy = AppSettings::get_proxy_user_avatars(cx);
|
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
||||||
let bech32 = self.profile.public_key().to_bech32().unwrap();
|
|
||||||
let shared_bech32 = SharedString::from(bech32);
|
let Ok(bech32) = self.profile.public_key().to_bech32();
|
||||||
|
let shared_bech32 = SharedString::new(bech32);
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
@@ -139,7 +140,7 @@ impl Render for UserProfile {
|
|||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.text_center()
|
.text_center()
|
||||||
.child(Avatar::new(self.profile.avatar(proxy)).size(rems(4.)))
|
.child(Avatar::new(self.profile.avatar_url(proxy)).size(rems(4.)))
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.child(
|
.child(
|
||||||
@@ -193,7 +194,7 @@ impl Render for UserProfile {
|
|||||||
div()
|
div()
|
||||||
.block()
|
.block()
|
||||||
.text_color(cx.theme().text_muted)
|
.text_color(cx.theme().text_muted)
|
||||||
.child(SharedString::from("Public Key:")),
|
.child("Public Key:"),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
@@ -244,8 +245,7 @@ impl Render for UserProfile {
|
|||||||
self.profile
|
self.profile
|
||||||
.metadata()
|
.metadata()
|
||||||
.about
|
.about
|
||||||
.map(SharedString::from)
|
.unwrap_or(t!("profile.no_bio").to_string()),
|
||||||
.unwrap_or(shared_t!("profile.no_bio")),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
div, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
div, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||||
InteractiveElement, IntoElement, ParentElement, Render, SharedString,
|
IntoElement, ParentElement, Render, SharedString, Styled, Window,
|
||||||
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::{v_flex, StyledExt};
|
use ui::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)
|
||||||
@@ -15,7 +14,8 @@ pub fn init(window: &mut Window, cx: &mut App) -> Entity<Welcome> {
|
|||||||
|
|
||||||
pub struct Welcome {
|
pub struct Welcome {
|
||||||
name: SharedString,
|
name: SharedString,
|
||||||
version: SharedString,
|
closable: bool,
|
||||||
|
zoomable: bool,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,11 +25,10 @@ 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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,15 +39,16 @@ impl Panel for Welcome {
|
|||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn title(&self, cx: &App) -> AnyElement {
|
fn title(&self, _cx: &App) -> AnyElement {
|
||||||
div()
|
"👋".into_any_element()
|
||||||
.child(
|
}
|
||||||
svg()
|
|
||||||
.path("brand/coop.svg")
|
fn closable(&self, _cx: &App) -> bool {
|
||||||
.size_4()
|
self.closable
|
||||||
.text_color(cx.theme().element_background),
|
}
|
||||||
)
|
|
||||||
.into_any_element()
|
fn zoomable(&self, _cx: &App) -> bool {
|
||||||
|
self.zoomable
|
||||||
}
|
}
|
||||||
|
|
||||||
fn popup_menu(&self, menu: PopupMenu, _cx: &App) -> PopupMenu {
|
fn popup_menu(&self, menu: PopupMenu, _cx: &App) -> PopupMenu {
|
||||||
@@ -76,10 +76,11 @@ impl Render for Welcome {
|
|||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
div()
|
||||||
.gap_2()
|
.flex()
|
||||||
|
.flex_col()
|
||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.gap_1()
|
||||||
.child(
|
.child(
|
||||||
svg()
|
svg()
|
||||||
.path("brand/coop.svg")
|
.path("brand/coop.svg")
|
||||||
@@ -87,26 +88,11 @@ impl Render for Welcome {
|
|||||||
.text_color(cx.theme().elevated_surface_background),
|
.text_color(cx.theme().elevated_surface_background),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
div()
|
||||||
.items_center()
|
.child("coop on nostr")
|
||||||
.justify_center()
|
.text_color(cx.theme().text_placeholder)
|
||||||
.text_center()
|
.font_semibold()
|
||||||
.child(
|
.text_sm(),
|
||||||
div()
|
|
||||||
.font_semibold()
|
|
||||||
.text_color(cx.theme().text_muted)
|
|
||||||
.child(SharedString::from("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");
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-90
@@ -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 SignalKind {
|
pub enum Signal {
|
||||||
/// 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,54 +71,25 @@ pub enum SignalKind {
|
|||||||
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
|
||||||
NewProfile(Profile),
|
Metadata(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
|
||||||
NewMessage((EventId, Event)),
|
Message((EventId, Event)),
|
||||||
|
|
||||||
/// A signal to notify UI that no DM relays for current user was found
|
/// A signal to notify UI that gift wrap process status has changed
|
||||||
RelaysNotFound,
|
GiftWrapProcess(UnwrappingStatus),
|
||||||
|
|
||||||
/// A signal to notify UI that gift wrap status has changed
|
/// A signal to notify UI that no DM relay for current user was found
|
||||||
GiftWrapStatus(UnwrappingStatus),
|
DmRelayNotFound,
|
||||||
|
|
||||||
/// 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<PublicKey>,
|
rx: Receiver<Signal>,
|
||||||
tx: Sender<PublicKey>,
|
tx: Sender<Signal>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Ingester {
|
impl Default for Ingester {
|
||||||
@@ -129,74 +100,48 @@ impl Default for Ingester {
|
|||||||
|
|
||||||
impl Ingester {
|
impl Ingester {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (tx, rx) = flume::bounded::<PublicKey>(1024);
|
let (tx, rx) = flume::bounded::<Signal>(2048);
|
||||||
Self { rx, tx }
|
Self { rx, tx }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn receiver(&self) -> &Receiver<PublicKey> {
|
pub fn signals(&self) -> &Receiver<Signal> {
|
||||||
&self.rx
|
&self.rx
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send(&self, public_key: PublicKey) {
|
pub async fn send(&self, signal: Signal) {
|
||||||
if let Err(e) = self.tx.send_async(public_key).await {
|
if let Err(e) = self.tx.send_async(signal).await {
|
||||||
log::error!("Failed to send public key: {e}");
|
log::error!("Failed to send signal: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A simple storage to store all states that using across the application.
|
/// A simple storage to store all runtime states that using across the application.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AppState {
|
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 AppState {
|
impl Default for CoopSimpleStorage {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
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,
|
init_at: Timestamp::now(),
|
||||||
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(opts),
|
auto_close_opts: Some(
|
||||||
seen_on_relays: RwLock::new(HashMap::new()),
|
SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE),
|
||||||
|
),
|
||||||
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()),
|
||||||
@@ -205,7 +150,9 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
|
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
|
||||||
static APP_STATE: OnceLock<AppState> = OnceLock::new();
|
static INGESTER: OnceLock<Ingester> = 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(|| {
|
||||||
@@ -223,26 +170,32 @@ pub fn nostr_client() -> &'static Client {
|
|||||||
.automatic_authentication(false)
|
.automatic_authentication(false)
|
||||||
.verify_subscriptions(false)
|
.verify_subscriptions(false)
|
||||||
.sleep_when_idle(SleepWhenIdle::Enabled {
|
.sleep_when_idle(SleepWhenIdle::Enabled {
|
||||||
timeout: Duration::from_secs(300),
|
timeout: Duration::from_secs(30),
|
||||||
});
|
});
|
||||||
|
|
||||||
ClientBuilder::default().database(lmdb).opts(opts).build()
|
ClientBuilder::default().database(lmdb).opts(opts).build()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn app_state() -> &'static AppState {
|
pub fn ingester() -> &'static Ingester {
|
||||||
APP_STATE.get_or_init(AppState::new)
|
INGESTER.get_or_init(Ingester::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_run() -> bool {
|
pub fn css() -> &'static CoopSimpleStorage {
|
||||||
let flag = support_dir().join(format!(".{}-first_run", env!("CARGO_PKG_VERSION")));
|
COOP_SIMPLE_STORAGE.get_or_init(CoopSimpleStorage::new)
|
||||||
|
}
|
||||||
|
|
||||||
if !flag.exists() {
|
pub fn first_run() -> &'static bool {
|
||||||
if std::fs::write(&flag, "").is_err() {
|
FIRST_RUN.get_or_init(|| {
|
||||||
return false;
|
let flag = support_dir().join(format!(".{}-first_run", env!("CARGO_PKG_VERSION")));
|
||||||
|
|
||||||
|
if !flag.exists() {
|
||||||
|
if std::fs::write(&flag, "").is_err() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
true // First run
|
||||||
|
} else {
|
||||||
|
false // Not first run
|
||||||
}
|
}
|
||||||
true // First run
|
})
|
||||||
} else {
|
|
||||||
false // Not first run
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ macro_rules! init {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! shared_t {
|
macro_rules! shared_t {
|
||||||
($key:expr) => {
|
($key:expr) => {
|
||||||
SharedString::from(t!($key))
|
SharedString::new(t!($key))
|
||||||
};
|
};
|
||||||
($key:expr, $($param:ident = $value:expr),+) => {
|
($key:expr, $($param:ident = $value:expr),+) => {
|
||||||
SharedString::from(t!($key, $($param = $value),+))
|
SharedString::new(t!($key, $($param = $value),+))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ impl Registry {
|
|||||||
let is_ongoing = client.database().count(filter).await.unwrap_or(1) >= 1;
|
let is_ongoing = client.database().count(filter).await.unwrap_or(1) >= 1;
|
||||||
|
|
||||||
// Create a new room
|
// Create a new room
|
||||||
let room = Room::from(&event).current_user(public_key);
|
let room = Room::new(&event).rearrange_by(public_key);
|
||||||
|
|
||||||
if is_ongoing || bypassed {
|
if is_ongoing || bypassed {
|
||||||
rooms.insert(room.kind(RoomKind::Ongoing));
|
rooms.insert(room.kind(RoomKind::Ongoing));
|
||||||
@@ -458,7 +458,9 @@ impl Registry {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let room = Room::from(&event).current_user(identity);
|
let room = Room::new(&event)
|
||||||
|
.kind(RoomKind::default())
|
||||||
|
.rearrange_by(identity);
|
||||||
|
|
||||||
// Push the new room to the front of the list
|
// Push the new room to the front of the list
|
||||||
self.add_room(cx.new(|_| room), cx);
|
self.add_room(cx.new(|_| room), cx);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,10 +13,6 @@ 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())
|
||||||
}
|
}
|
||||||
@@ -30,11 +25,6 @@ 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),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+147
-163
@@ -4,11 +4,11 @@ use std::hash::{Hash, Hasher};
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use common::display::RenderedProfile;
|
use common::display::ReadableProfile;
|
||||||
use common::event::EventUtils;
|
use common::event::EventUtils;
|
||||||
use global::constants::SEND_RETRY;
|
use global::constants::SEND_RETRY;
|
||||||
use global::{app_state, nostr_client};
|
use global::{css, nostr_client};
|
||||||
use gpui::{App, AppContext, Context, EventEmitter, SharedString, SharedUri, Task};
|
use gpui::{App, AppContext, Context, EventEmitter, SharedString, Task};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
|
|
||||||
@@ -124,118 +124,83 @@ impl Eq for Room {}
|
|||||||
|
|
||||||
impl EventEmitter<RoomSignal> for Room {}
|
impl EventEmitter<RoomSignal> for Room {}
|
||||||
|
|
||||||
impl From<&Event> for Room {
|
|
||||||
fn from(val: &Event) -> Self {
|
|
||||||
let id = val.uniq_id();
|
|
||||||
let created_at = val.created_at;
|
|
||||||
|
|
||||||
// Get the members from the event's tags and event's pubkey
|
|
||||||
let members = val
|
|
||||||
.all_pubkeys()
|
|
||||||
.into_iter()
|
|
||||||
.unique()
|
|
||||||
.sorted()
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
// Get the subject from the event's tags
|
|
||||||
let subject = if let Some(tag) = val.tags.find(TagKind::Subject) {
|
|
||||||
tag.content().map(|s| s.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the picture from the event's tags
|
|
||||||
let picture = if let Some(tag) = val.tags.find(TagKind::custom("picture")) {
|
|
||||||
tag.content().map(|s| s.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Room {
|
|
||||||
id,
|
|
||||||
created_at,
|
|
||||||
subject,
|
|
||||||
picture,
|
|
||||||
members,
|
|
||||||
kind: RoomKind::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&UnsignedEvent> for Room {
|
|
||||||
fn from(val: &UnsignedEvent) -> Self {
|
|
||||||
let id = val.uniq_id();
|
|
||||||
let created_at = val.created_at;
|
|
||||||
|
|
||||||
// Get the members from the event's tags and event's pubkey
|
|
||||||
let members = val
|
|
||||||
.all_pubkeys()
|
|
||||||
.into_iter()
|
|
||||||
.unique()
|
|
||||||
.sorted()
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
// Get the subject from the event's tags
|
|
||||||
let subject = if let Some(tag) = val.tags.find(TagKind::Subject) {
|
|
||||||
tag.content().map(|s| s.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the picture from the event's tags
|
|
||||||
let picture = if let Some(tag) = val.tags.find(TagKind::custom("picture")) {
|
|
||||||
tag.content().map(|s| s.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Room {
|
|
||||||
id,
|
|
||||||
created_at,
|
|
||||||
subject,
|
|
||||||
picture,
|
|
||||||
members,
|
|
||||||
kind: RoomKind::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Room {
|
impl Room {
|
||||||
/// Constructs a new room instance with a given receiver.
|
pub fn new(event: &Event) -> Self {
|
||||||
pub fn new(receiver: PublicKey, tags: Tags, cx: &App) -> Self {
|
let id = event.uniq_id();
|
||||||
let identity = Registry::read_global(cx).identity(cx);
|
let created_at = event.created_at;
|
||||||
|
|
||||||
let mut event = EventBuilder::private_msg_rumor(receiver, "")
|
// Get the members from the event's tags and event's pubkey
|
||||||
.tags(tags)
|
let members = event
|
||||||
.build(identity.public_key());
|
.all_pubkeys()
|
||||||
|
.into_iter()
|
||||||
|
.unique()
|
||||||
|
.sorted()
|
||||||
|
.collect_vec();
|
||||||
|
|
||||||
// Ensure event ID is generated
|
// Get the subject from the event's tags
|
||||||
event.ensure_id();
|
let subject = if let Some(tag) = event.tags.find(TagKind::Subject) {
|
||||||
|
tag.content().map(|s| s.to_owned())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
Room::from(&event).current_user(identity.public_key())
|
// Get the picture from the event's tags
|
||||||
}
|
let picture = if let Some(tag) = event.tags.find(TagKind::custom("picture")) {
|
||||||
|
tag.content().map(|s| s.to_owned())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
/// Constructs a new room instance from an nostr event.
|
Self {
|
||||||
pub fn from(event: impl Into<Room>) -> Self {
|
id,
|
||||||
event.into()
|
created_at,
|
||||||
}
|
subject,
|
||||||
|
picture,
|
||||||
/// Call this function to ensure the current user is always at the bottom of the members list
|
members,
|
||||||
pub fn current_user(mut self, public_key: PublicKey) -> Self {
|
kind: RoomKind::default(),
|
||||||
let (not_match, matches): (Vec<PublicKey>, Vec<PublicKey>) =
|
}
|
||||||
self.members.iter().partition(|&key| key != &public_key);
|
|
||||||
self.members = not_match;
|
|
||||||
self.members.extend(matches);
|
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the kind of the room and returns the modified room
|
/// Sets the kind of the room and returns the modified room
|
||||||
|
///
|
||||||
|
/// This is a builder-style method that allows chaining room modifications.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `kind` - The RoomKind to set for this room
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// The modified Room instance with the new kind
|
||||||
pub fn kind(mut self, kind: RoomKind) -> Self {
|
pub fn kind(mut self, kind: RoomKind) -> Self {
|
||||||
self.kind = kind;
|
self.kind = kind;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the rearrange_by field of the room and returns the modified room
|
||||||
|
///
|
||||||
|
/// This is a builder-style method that allows chaining room modifications.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `rearrange_by` - The PublicKey to set for rearranging the member list
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// The modified Room instance with the new member list after rearrangement
|
||||||
|
pub fn rearrange_by(mut self, rearrange_by: PublicKey) -> Self {
|
||||||
|
let (not_match, matches): (Vec<PublicKey>, Vec<PublicKey>) =
|
||||||
|
self.members.iter().partition(|&key| key != &rearrange_by);
|
||||||
|
self.members = not_match;
|
||||||
|
self.members.extend(matches);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the room kind to ongoing
|
/// Set the room kind to ongoing
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `cx` - The context to notify about the update
|
||||||
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
|
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
|
||||||
if self.kind != RoomKind::Ongoing {
|
if self.kind != RoomKind::Ongoing {
|
||||||
self.kind = RoomKind::Ongoing;
|
self.kind = RoomKind::Ongoing;
|
||||||
@@ -244,45 +209,89 @@ impl Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the room is a group chat
|
/// Checks if the room is a group chat
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// true if the room has more than 2 members, false otherwise
|
||||||
pub fn is_group(&self) -> bool {
|
pub fn is_group(&self) -> bool {
|
||||||
self.members.len() > 2
|
self.members.len() > 2
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the creation timestamp of the room
|
/// Updates the creation timestamp of the room
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `created_at` - The new Timestamp to set
|
||||||
|
/// * `cx` - The context to notify about the update
|
||||||
pub fn created_at(&mut self, created_at: impl Into<Timestamp>, cx: &mut Context<Self>) {
|
pub fn created_at(&mut self, created_at: impl Into<Timestamp>, cx: &mut Context<Self>) {
|
||||||
self.created_at = created_at.into();
|
self.created_at = created_at.into();
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the subject of the room
|
/// Updates the subject of the room
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `subject` - The new subject to set
|
||||||
|
/// * `cx` - The context to notify about the update
|
||||||
pub fn subject(&mut self, subject: String, cx: &mut Context<Self>) {
|
pub fn subject(&mut self, subject: String, cx: &mut Context<Self>) {
|
||||||
self.subject = Some(subject);
|
self.subject = Some(subject);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the picture of the room
|
/// Updates the picture of the room
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `picture` - The new subject to set
|
||||||
|
/// * `cx` - The context to notify about the update
|
||||||
pub fn picture(&mut self, picture: String, cx: &mut Context<Self>) {
|
pub fn picture(&mut self, picture: String, cx: &mut Context<Self>) {
|
||||||
self.picture = Some(picture);
|
self.picture = Some(picture);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the display name for the room
|
/// Gets the display name for the room
|
||||||
pub fn display_name(&self, cx: &App) -> SharedString {
|
///
|
||||||
|
/// If the room has a subject set, that will be used as the display name.
|
||||||
|
/// Otherwise, it will generate a name based on the room members.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `cx` - The application context
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// A string containing the display name
|
||||||
|
pub fn display_name(&self, cx: &App) -> String {
|
||||||
if let Some(subject) = self.subject.clone() {
|
if let Some(subject) = self.subject.clone() {
|
||||||
SharedString::from(subject)
|
subject
|
||||||
} else {
|
} else {
|
||||||
self.merged_name(cx)
|
self.merge_name(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the display image for the room
|
/// Gets the display image for the room
|
||||||
pub fn display_image(&self, proxy: bool, cx: &App) -> SharedUri {
|
///
|
||||||
|
/// The image is determined by:
|
||||||
|
/// - The room's picture if set
|
||||||
|
/// - The first member's avatar for 1:1 chats
|
||||||
|
/// - A default group image for group chats
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `proxy` - Whether to use the proxy for the avatar URL
|
||||||
|
/// * `cx` - The application context
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// A string containing the image path or URL
|
||||||
|
pub fn display_image(&self, proxy: bool, cx: &App) -> String {
|
||||||
if let Some(picture) = self.picture.as_ref() {
|
if let Some(picture) = self.picture.as_ref() {
|
||||||
SharedUri::from(picture)
|
picture.clone()
|
||||||
} else if !self.is_group() {
|
} else if !self.is_group() {
|
||||||
self.first_member(cx).avatar(proxy)
|
self.first_member(cx).avatar_url(proxy)
|
||||||
} else {
|
} else {
|
||||||
SharedUri::from("brand/group.png")
|
"brand/group.png".into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +304,7 @@ impl Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Merge the names of the first two members of the room.
|
/// Merge the names of the first two members of the room.
|
||||||
pub(crate) fn merged_name(&self, cx: &App) -> SharedString {
|
pub(crate) fn merge_name(&self, cx: &App) -> String {
|
||||||
let registry = Registry::read_global(cx);
|
let registry = Registry::read_global(cx);
|
||||||
|
|
||||||
if self.is_group() {
|
if self.is_group() {
|
||||||
@@ -308,7 +317,7 @@ impl Room {
|
|||||||
let mut name = profiles
|
let mut name = profiles
|
||||||
.iter()
|
.iter()
|
||||||
.take(2)
|
.take(2)
|
||||||
.map(|p| p.name())
|
.map(|p| p.display_name())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
||||||
@@ -316,50 +325,21 @@ impl Room {
|
|||||||
name = format!("{}, +{}", name, profiles.len() - 2);
|
name = format!("{}, +{}", name, profiles.len() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedString::from(name)
|
name
|
||||||
} else {
|
} else {
|
||||||
self.first_member(cx).display_name()
|
self.first_member(cx).display_name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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();
|
||||||
|
|
||||||
@@ -385,6 +365,16 @@ 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.
|
||||||
@@ -411,7 +401,6 @@ impl Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut event = builder.tags(tags).build(receiver);
|
let mut event = builder.tags(tags).build(receiver);
|
||||||
|
|
||||||
// Ensure event ID is set
|
// Ensure event ID is set
|
||||||
event.ensure_id();
|
event.ensure_id();
|
||||||
|
|
||||||
@@ -432,7 +421,7 @@ impl Room {
|
|||||||
let mut public_keys = self.members.clone();
|
let mut public_keys = self.members.clone();
|
||||||
|
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let app_state = app_state();
|
let css = css();
|
||||||
let client = nostr_client();
|
let client = nostr_client();
|
||||||
let signer = client.signer().await?;
|
let signer = client.signer().await?;
|
||||||
let public_key = signer.get_public_key().await?;
|
let public_key = signer.get_public_key().await?;
|
||||||
@@ -492,10 +481,15 @@ impl Room {
|
|||||||
if auth_required {
|
if auth_required {
|
||||||
// Wait for authenticated and resent event successfully
|
// Wait for authenticated and resent event successfully
|
||||||
for attempt in 0..=SEND_RETRY {
|
for attempt in 0..=SEND_RETRY {
|
||||||
let ids = app_state.resent_ids.read().await;
|
|
||||||
|
|
||||||
// Check if event was successfully resent
|
// Check if event was successfully resent
|
||||||
if let Some(output) = ids.iter().find(|e| e.id() == &id).cloned() {
|
if let Some(output) = css
|
||||||
|
.resent_ids
|
||||||
|
.read()
|
||||||
|
.await
|
||||||
|
.iter()
|
||||||
|
.find(|e| e.id() == &id)
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
let output = SendReport::new(pubkey).status(output).tags(&tags);
|
let output = SendReport::new(pubkey).status(output).tags(&tags);
|
||||||
reports.push(output);
|
reports.push(output);
|
||||||
break;
|
break;
|
||||||
@@ -599,14 +593,4 @@ 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 = 80.;
|
pub const TRAFFIC_LIGHT_PADDING: f32 = 71.;
|
||||||
|
|||||||
+12
-7
@@ -10,6 +10,11 @@ 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,
|
||||||
@@ -125,7 +130,7 @@ pub struct Button {
|
|||||||
children: Vec<AnyElement>,
|
children: Vec<AnyElement>,
|
||||||
|
|
||||||
variant: ButtonVariant,
|
variant: ButtonVariant,
|
||||||
rounded: bool,
|
rounded: ButtonRounded,
|
||||||
size: Size,
|
size: Size,
|
||||||
|
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
@@ -158,7 +163,7 @@ impl Button {
|
|||||||
disabled: false,
|
disabled: false,
|
||||||
selected: false,
|
selected: false,
|
||||||
variant: ButtonVariant::default(),
|
variant: ButtonVariant::default(),
|
||||||
rounded: false,
|
rounded: ButtonRounded::Normal,
|
||||||
size: Size::Medium,
|
size: Size::Medium,
|
||||||
tooltip: None,
|
tooltip: None,
|
||||||
on_click: None,
|
on_click: None,
|
||||||
@@ -172,9 +177,9 @@ impl Button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make the button rounded.
|
/// Set the border radius of the Button.
|
||||||
pub fn rounded(mut self) -> Self {
|
pub fn rounded(mut self, rounded: impl Into<ButtonRounded>) -> Self {
|
||||||
self.rounded = true;
|
self.rounded = rounded.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,8 +315,8 @@ impl RenderOnce for Button {
|
|||||||
.cursor_default()
|
.cursor_default()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.map(|this| match self.rounded {
|
.map(|this| match self.rounded {
|
||||||
false => this.rounded(cx.theme().radius),
|
ButtonRounded::Normal => this.rounded(cx.theme().radius),
|
||||||
true => this.rounded_full(),
|
ButtonRounded::Full => 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,15 +412,16 @@ 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()
|
||||||
.rounded_full()
|
.items_center()
|
||||||
.children(toolbar.into_iter().map(|btn| btn.small().ghost().rounded()))
|
.children(
|
||||||
|
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")
|
||||||
@@ -433,16 +434,11 @@ 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;
|
||||||
@@ -651,7 +647,7 @@ impl TabPanel {
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.size_full()
|
.size_full()
|
||||||
.rounded_xl()
|
.rounded_lg()
|
||||||
.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)
|
||||||
@@ -671,7 +667,7 @@ impl TabPanel {
|
|||||||
.p_1()
|
.p_1()
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.rounded_xl()
|
.rounded_lg()
|
||||||
.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,7 +52,6 @@ pub enum IconName {
|
|||||||
Signal,
|
Signal,
|
||||||
Search,
|
Search,
|
||||||
Settings,
|
Settings,
|
||||||
Server,
|
|
||||||
SortAscending,
|
SortAscending,
|
||||||
SortDescending,
|
SortDescending,
|
||||||
Sun,
|
Sun,
|
||||||
@@ -113,7 +112,6 @@ 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",
|
||||||
|
|||||||
@@ -781,11 +781,6 @@ impl InputState {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the loading state of the input field.
|
|
||||||
pub fn loading(&self, _cx: &App) -> bool {
|
|
||||||
self.loading
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set true to show indicator at the input right.
|
/// Set true to show indicator at the input right.
|
||||||
pub fn set_loading(&mut self, loading: bool, cx: &mut Context<Self>) {
|
pub fn set_loading(&mut self, loading: bool, cx: &mut Context<Self>) {
|
||||||
self.loading = loading;
|
self.loading = loading;
|
||||||
|
|||||||
@@ -405,14 +405,13 @@ 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()
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ impl Root {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render Notification layer.
|
// Render Notification layer.
|
||||||
pub fn render_notification_layer(
|
pub fn render_notification_layer(
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use common::display::RenderedProfile;
|
use common::display::ReadableProfile;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, AnyView, App, ElementId, HighlightStyle, InteractiveText, IntoElement,
|
AnyElement, AnyView, App, ElementId, HighlightStyle, InteractiveText, IntoElement,
|
||||||
SharedString, StyledText, UnderlineStyle, Window,
|
SharedString, StyledText, UnderlineStyle, Window,
|
||||||
|
|||||||
+4
-10
@@ -51,8 +51,6 @@ common:
|
|||||||
en: "Recommended:"
|
en: "Recommended:"
|
||||||
resend:
|
resend:
|
||||||
en: "Resend"
|
en: "Resend"
|
||||||
seen_on:
|
|
||||||
en: "Seen on"
|
|
||||||
|
|
||||||
auto_update:
|
auto_update:
|
||||||
updating:
|
updating:
|
||||||
@@ -315,6 +313,10 @@ preferences:
|
|||||||
en: "Display"
|
en: "Display"
|
||||||
|
|
||||||
compose:
|
compose:
|
||||||
|
placeholder_npub:
|
||||||
|
en: "npub or nprofile..."
|
||||||
|
placeholder_title:
|
||||||
|
en: "Family...(Optional)"
|
||||||
create_dm_button:
|
create_dm_button:
|
||||||
en: "Create DM"
|
en: "Create DM"
|
||||||
creating_dm_button:
|
creating_dm_button:
|
||||||
@@ -397,14 +399,6 @@ 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