Compare commits
4 Commits
cc4174a695
...
v1.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fef2ae1c6 | ||
|
|
c2a723faa8 | ||
|
|
6b872527ad | ||
|
|
d9b16aea9a |
763
Cargo.lock
generated
763
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||||||
default-members = ["crates/coop"]
|
default-members = ["crates/coop"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "1.0.0-beta2"
|
version = "1.0.0-beta3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["fo
|
|||||||
gpui_linux = { git = "https://github.com/zed-industries/zed" }
|
gpui_linux = { git = "https://github.com/zed-industries/zed" }
|
||||||
gpui_windows = { git = "https://github.com/zed-industries/zed" }
|
gpui_windows = { git = "https://github.com/zed-industries/zed" }
|
||||||
gpui_macos = { git = "https://github.com/zed-industries/zed" }
|
gpui_macos = { git = "https://github.com/zed-industries/zed" }
|
||||||
gpui_web = { git = "https://github.com/zed-industries/zed" }
|
|
||||||
gpui_tokio = { git = "https://github.com/zed-industries/zed" }
|
gpui_tokio = { git = "https://github.com/zed-industries/zed" }
|
||||||
reqwest_client = { git = "https://github.com/zed-industries/zed" }
|
reqwest_client = { git = "https://github.com/zed-industries/zed" }
|
||||||
|
|
||||||
@@ -43,6 +42,7 @@ smallvec = "1.14.0"
|
|||||||
smol = "2"
|
smol = "2"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
webbrowser = "1.0.4"
|
webbrowser = "1.0.4"
|
||||||
|
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ impl Signal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Dekey = bool;
|
||||||
|
type GiftWrapId = EventId;
|
||||||
|
|
||||||
/// Chat Registry
|
/// Chat Registry
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ChatRegistry {
|
pub struct ChatRegistry {
|
||||||
@@ -90,7 +93,7 @@ pub struct ChatRegistry {
|
|||||||
seens: Arc<RwLock<HashMap<EventId, HashSet<RelayUrl>>>>,
|
seens: Arc<RwLock<HashMap<EventId, HashSet<RelayUrl>>>>,
|
||||||
|
|
||||||
/// Mapping of unwrapped event ids to their gift wrap event ids
|
/// Mapping of unwrapped event ids to their gift wrap event ids
|
||||||
event_map: Arc<RwLock<HashMap<EventId, EventId>>>,
|
event_map: Arc<RwLock<HashMap<EventId, (GiftWrapId, Dekey)>>>,
|
||||||
|
|
||||||
/// Tracking the status of unwrapping gift wrap events.
|
/// Tracking the status of unwrapping gift wrap events.
|
||||||
tracking_flag: Arc<AtomicBool>,
|
tracking_flag: Arc<AtomicBool>,
|
||||||
@@ -220,7 +223,10 @@ impl ChatRegistry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match *message {
|
match *message {
|
||||||
RelayMessage::Event { event, .. } => {
|
RelayMessage::Event {
|
||||||
|
event,
|
||||||
|
subscription_id,
|
||||||
|
} => {
|
||||||
// Keep track of which relays have seen this event
|
// Keep track of which relays have seen this event
|
||||||
{
|
{
|
||||||
let mut seens = seens.write().await;
|
let mut seens = seens.write().await;
|
||||||
@@ -243,7 +249,8 @@ impl ChatRegistry {
|
|||||||
// Map the rumor id to the gift wrap event id for later lookup
|
// Map the rumor id to the gift wrap event id for later lookup
|
||||||
{
|
{
|
||||||
let mut event_map = event_map.write().await;
|
let mut event_map = event_map.write().await;
|
||||||
event_map.insert(rumor.id.unwrap(), event.id);
|
let dekey = subscription_id.as_ref() == &sub_id1;
|
||||||
|
event_map.insert(rumor.id.unwrap(), (event.id, dekey));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the rumor has a recipient
|
// Check if the rumor has a recipient
|
||||||
@@ -251,8 +258,6 @@ impl ChatRegistry {
|
|||||||
let signal =
|
let signal =
|
||||||
Signal::error(event.as_ref(), "Recipient is missing");
|
Signal::error(event.as_ref(), "Recipient is missing");
|
||||||
tx.send_async(signal).await?;
|
tx.send_async(signal).await?;
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the rumor was created after the chat was initialized (for detecting new messages)
|
// Check if the rumor was created after the chat was initialized (for detecting new messages)
|
||||||
@@ -260,6 +265,7 @@ impl ChatRegistry {
|
|||||||
let signal = Signal::message(event.id, rumor);
|
let signal = Signal::message(event.id, rumor);
|
||||||
tx.send_async(signal).await?;
|
tx.send_async(signal).await?;
|
||||||
} else {
|
} else {
|
||||||
|
// Mark the chat still processing new messages
|
||||||
status.store(true, Ordering::Release);
|
status.store(true, Ordering::Release);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -539,7 +545,7 @@ impl ChatRegistry {
|
|||||||
self.event_map
|
self.event_map
|
||||||
.read_blocking()
|
.read_blocking()
|
||||||
.get(id)
|
.get(id)
|
||||||
.map(|id| self.seen_on(id))
|
.map(|(id, _dekey)| self.seen_on(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the relays that have seen a given gift wrap id.
|
/// Get the relays that have seen a given gift wrap id.
|
||||||
@@ -551,6 +557,15 @@ impl ChatRegistry {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if a given rumor was encrypted by the dekey.
|
||||||
|
pub fn encrypted_by_dekey(&self, id: &EventId) -> bool {
|
||||||
|
self.event_map
|
||||||
|
.read_blocking()
|
||||||
|
.get(id)
|
||||||
|
.map(|(_, dekey)| *dekey)
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
/// Add a new room to the start of list.
|
/// Add a new room to the start of list.
|
||||||
pub fn add_room<I>(&mut self, room: I, cx: &mut Context<Self>)
|
pub fn add_room<I>(&mut self, room: I, cx: &mut Context<Self>)
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -471,6 +471,12 @@ impl ChatPanel {
|
|||||||
self.reports_by_id.read(cx).get(id).is_some()
|
self.reports_by_id.read(cx).get(id).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if a message was encrypted by the dekey
|
||||||
|
fn encrypted_by_dekey(&self, id: &EventId, cx: &App) -> bool {
|
||||||
|
let chat = ChatRegistry::global(cx);
|
||||||
|
chat.read(cx).encrypted_by_dekey(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get all sent reports for a message by its ID
|
/// Get all sent reports for a message by its ID
|
||||||
fn sent_reports(&self, id: &EventId, cx: &App) -> Option<Vec<SendReport>> {
|
fn sent_reports(&self, id: &EventId, cx: &App) -> Option<Vec<SendReport>> {
|
||||||
self.reports_by_id.read(cx).get(id).cloned()
|
self.reports_by_id.read(cx).get(id).cloned()
|
||||||
@@ -843,6 +849,7 @@ impl ChatPanel {
|
|||||||
let replies = message.replies_to.as_slice();
|
let replies = message.replies_to.as_slice();
|
||||||
let has_replies = !replies.is_empty();
|
let has_replies = !replies.is_empty();
|
||||||
let has_reports = self.has_reports(&id, cx);
|
let has_reports = self.has_reports(&id, cx);
|
||||||
|
let encrypted_by_dekey = self.encrypted_by_dekey(&id, cx);
|
||||||
|
|
||||||
// Hide avatar setting
|
// Hide avatar setting
|
||||||
let hide_avatar = AppSettings::get_hide_avatar(cx);
|
let hide_avatar = AppSettings::get_hide_avatar(cx);
|
||||||
@@ -888,6 +895,17 @@ impl ChatPanel {
|
|||||||
.text_color(cx.theme().text)
|
.text_color(cx.theme().text)
|
||||||
.child(author.name()),
|
.child(author.name()),
|
||||||
)
|
)
|
||||||
|
.when(encrypted_by_dekey, |this| {
|
||||||
|
this.child(
|
||||||
|
Button::new(format!("dekey-{ix}"))
|
||||||
|
.icon(IconName::Shield)
|
||||||
|
.ghost()
|
||||||
|
.xsmall()
|
||||||
|
.px_4()
|
||||||
|
.tooltip("Encrypted by Dekey")
|
||||||
|
.disabled(true),
|
||||||
|
)
|
||||||
|
})
|
||||||
.child(message.created_at.to_human_time())
|
.child(message.created_at.to_human_time())
|
||||||
.when(has_reports, |this| {
|
.when(has_reports, |this| {
|
||||||
this.child(deferred(self.render_sent_reports(&id, cx)))
|
this.child(deferred(self.render_sent_reports(&id, cx)))
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ product-name = "Coop"
|
|||||||
description = "Chat Freely, Stay Private on Nostr"
|
description = "Chat Freely, Stay Private on Nostr"
|
||||||
identifier = "su.reya.coop"
|
identifier = "su.reya.coop"
|
||||||
category = "SocialNetworking"
|
category = "SocialNetworking"
|
||||||
version = "1.0.0-beta2"
|
version = "1.0.0-beta3"
|
||||||
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,9 +62,9 @@ smol.workspace = true
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
oneshot.workspace = true
|
oneshot.workspace = true
|
||||||
webbrowser.workspace = true
|
webbrowser.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
|
|
||||||
indexset = "0.12.3"
|
indexset = "0.12.3"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
# Temporary workaround https://github.com/zed-industries/zed/issues/47168
|
# Temporary workaround https://github.com/zed-industries/zed/issues/47168
|
||||||
|
|||||||
36
crates/coop_mobile/Cargo.toml
Normal file
36
crates/coop_mobile/Cargo.toml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[package]
|
||||||
|
name = "coop_mobile"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
publish.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
assets = { path = "../assets" }
|
||||||
|
ui = { path = "../ui" }
|
||||||
|
theme = { path = "../theme" }
|
||||||
|
common = { path = "../common" }
|
||||||
|
state = { path = "../state" }
|
||||||
|
device = { path = "../device" }
|
||||||
|
chat = { path = "../chat" }
|
||||||
|
settings = { path = "../settings" }
|
||||||
|
person = { path = "../person" }
|
||||||
|
relay_auth = { path = "../relay_auth" }
|
||||||
|
|
||||||
|
gpui.workspace = true
|
||||||
|
gpui_platform.workspace = true
|
||||||
|
gpui_tokio.workspace = true
|
||||||
|
gpui-mobile = { git = "https://github.com/itsbalamurali/gpui-mobile" }
|
||||||
|
|
||||||
|
nostr-connect.workspace = true
|
||||||
|
nostr-sdk.workspace = true
|
||||||
|
|
||||||
|
anyhow.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
itertools.workspace = true
|
||||||
|
log.workspace = true
|
||||||
|
smallvec.workspace = true
|
||||||
|
smol.workspace = true
|
||||||
|
futures.workspace = true
|
||||||
|
oneshot.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
0
crates/coop_mobile/src/lib.rs
Normal file
0
crates/coop_mobile/src/lib.rs
Normal file
@@ -12,15 +12,14 @@ common = { path = "../common" }
|
|||||||
state = { path = "../state" }
|
state = { path = "../state" }
|
||||||
device = { path = "../device" }
|
device = { path = "../device" }
|
||||||
chat = { path = "../chat" }
|
chat = { path = "../chat" }
|
||||||
chat_ui = { path = "../chat_ui" }
|
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
person = { path = "../person" }
|
person = { path = "../person" }
|
||||||
relay_auth = { path = "../relay_auth" }
|
relay_auth = { path = "../relay_auth" }
|
||||||
|
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
gpui_web.workspace = true
|
|
||||||
gpui_platform.workspace = true
|
gpui_platform.workspace = true
|
||||||
gpui_tokio.workspace = true
|
gpui_tokio.workspace = true
|
||||||
|
gpui_web = { git = "https://github.com/zed-industries/zed" }
|
||||||
|
|
||||||
nostr-connect.workspace = true
|
nostr-connect.workspace = true
|
||||||
nostr-sdk.workspace = true
|
nostr-sdk.workspace = true
|
||||||
@@ -35,8 +34,8 @@ smol.workspace = true
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
oneshot.workspace = true
|
oneshot.workspace = true
|
||||||
webbrowser.workspace = true
|
webbrowser.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
|
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
|
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
tracing-wasm = "0.2"
|
tracing-wasm = "0.2"
|
||||||
console_log = "1.0"
|
console_log = "1.0"
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ targets = [
|
|||||||
"x86_64-unknown-linux-gnu",
|
"x86_64-unknown-linux-gnu",
|
||||||
"x86_64-pc-windows-msvc",
|
"x86_64-pc-windows-msvc",
|
||||||
"aarch64-pc-windows-msvc",
|
"aarch64-pc-windows-msvc",
|
||||||
|
"aarch64-apple-ios",
|
||||||
|
"aarch64-linux-android",
|
||||||
"wasm32-unknown-unknown"
|
"wasm32-unknown-unknown"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user