fix: inbox relay isn't connect when send message in compose dialog
This commit is contained in:
@@ -27,12 +27,12 @@ pub fn get_accounts() -> Vec<String> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn get_metadata(id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
pub async fn get_metadata(user_id: String, state: State<'_, Nostr>) -> Result<String, String> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
let public_key = PublicKey::parse(&user_id).map_err(|e| e.to_string())?;
|
||||||
let filter = Filter::new().author(public_key).kind(Kind::Metadata).limit(1);
|
let filter = Filter::new().author(public_key).kind(Kind::Metadata).limit(1);
|
||||||
|
|
||||||
match client.get_events_of(vec![filter], Some(Duration::from_secs(3))).await {
|
match client.get_events_of(vec![filter], Some(Duration::from_secs(2))).await {
|
||||||
Ok(events) => {
|
Ok(events) => {
|
||||||
if let Some(event) = events.first() {
|
if let Some(event) = events.first() {
|
||||||
Ok(Metadata::from_json(&event.content).unwrap_or(Metadata::new()).as_json())
|
Ok(Metadata::from_json(&event.content).unwrap_or(Metadata::new()).as_json())
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
use std::time::Duration;
|
|
||||||
use tauri::State;
|
use tauri::State;
|
||||||
|
|
||||||
use crate::Nostr;
|
use crate::Nostr;
|
||||||
@@ -54,62 +53,6 @@ pub async fn get_chat_messages(id: String, state: State<'_, Nostr>) -> Result<Ve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
#[specta::specta]
|
|
||||||
pub async fn connect_inbox(id: String, state: State<'_, Nostr>) -> Result<Vec<String>, String> {
|
|
||||||
let client = &state.client;
|
|
||||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
|
||||||
let mut inbox_relays = state.inbox_relays.lock().await;
|
|
||||||
|
|
||||||
if let Some(relays) = inbox_relays.get(&public_key) {
|
|
||||||
for relay in relays {
|
|
||||||
let _ = client.connect_relay(relay).await;
|
|
||||||
}
|
|
||||||
return Ok(relays.to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
let inbox = Filter::new().kind(Kind::Custom(10050)).author(public_key).limit(1);
|
|
||||||
|
|
||||||
match client.get_events_of(vec![inbox], Some(Duration::from_secs(2))).await {
|
|
||||||
Ok(events) => {
|
|
||||||
let mut relays = Vec::new();
|
|
||||||
|
|
||||||
if let Some(event) = events.into_iter().next() {
|
|
||||||
for tag in &event.tags {
|
|
||||||
if let Some(TagStandard::Relay(relay)) = tag.as_standardized() {
|
|
||||||
let url = relay.to_string();
|
|
||||||
let _ = client.add_relay(&url).await;
|
|
||||||
let _ = client.connect_relay(&url).await;
|
|
||||||
|
|
||||||
relays.push(url)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inbox_relays.insert(public_key, relays.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(relays)
|
|
||||||
}
|
|
||||||
Err(e) => Err(e.to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
#[specta::specta]
|
|
||||||
pub async fn disconnect_inbox(id: String, state: State<'_, Nostr>) -> Result<(), String> {
|
|
||||||
let client = &state.client;
|
|
||||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
|
||||||
let inbox_relays = state.inbox_relays.lock().await;
|
|
||||||
|
|
||||||
if let Some(relays) = inbox_relays.get(&public_key) {
|
|
||||||
for relay in relays {
|
|
||||||
let _ = client.disconnect_relay(relay).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn send_message(
|
pub async fn send_message(
|
||||||
@@ -126,24 +69,27 @@ pub async fn send_message(
|
|||||||
// TODO: Add support reply_to
|
// TODO: Add support reply_to
|
||||||
let rumor = EventBuilder::private_msg_rumor(receiver, message, None);
|
let rumor = EventBuilder::private_msg_rumor(receiver, message, None);
|
||||||
|
|
||||||
// Get inbox relays
|
// Get inbox state
|
||||||
let relays = state.inbox_relays.lock().await;
|
let relays = state.inbox_relays.lock().await;
|
||||||
|
|
||||||
|
// Get inbox relays per member
|
||||||
let outbox = relays.get(&receiver);
|
let outbox = relays.get(&receiver);
|
||||||
let inbox = relays.get(&public_key);
|
let inbox = relays.get(&public_key);
|
||||||
|
|
||||||
let outbox_urls = match outbox {
|
let outbox_urls = match outbox {
|
||||||
Some(relays) => relays,
|
Some(relays) => relays,
|
||||||
None => return Err("User's didn't have inbox relays to receive message.".into()),
|
None => return Err("Receiver didn't have inbox relays to receive message.".into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let inbox_urls = match inbox {
|
let inbox_urls = match inbox {
|
||||||
Some(relays) => relays,
|
Some(relays) => relays,
|
||||||
None => return Err("User's didn't have inbox relays to receive message.".into()),
|
None => return Err("Please config inbox relays to backup your message.".into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Send message to [receiver]
|
||||||
match client.gift_wrap_to(outbox_urls, receiver, rumor.clone(), None).await {
|
match client.gift_wrap_to(outbox_urls, receiver, rumor.clone(), None).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
// Send message to [yourself]
|
||||||
if let Err(e) = client.gift_wrap_to(inbox_urls, public_key, rumor, None).await {
|
if let Err(e) = client.gift_wrap_to(inbox_urls, public_key, rumor, None).await {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,27 @@ use nostr_sdk::prelude::*;
|
|||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
io::{self, BufRead, Write},
|
io::{self, BufRead, Write},
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tauri::{Manager, State};
|
use tauri::{Manager, State};
|
||||||
|
|
||||||
use crate::Nostr;
|
use crate::Nostr;
|
||||||
|
|
||||||
|
async fn get_nip65_list(public_key: PublicKey, client: &Client) -> Vec<String> {
|
||||||
|
let filter = Filter::new().author(public_key).kind(Kind::RelayList).limit(1);
|
||||||
|
let mut relay_list: Vec<String> = Vec::new();
|
||||||
|
|
||||||
|
if let Ok(events) = client.get_events_of(vec![filter], Some(Duration::from_secs(10))).await {
|
||||||
|
if let Some(event) = events.first() {
|
||||||
|
for (url, ..) in nip65::extract_relay_list(event) {
|
||||||
|
relay_list.push(url.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
relay_list
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub fn get_bootstrap_relays(app: tauri::AppHandle) -> Result<Vec<String>, String> {
|
pub fn get_bootstrap_relays(app: tauri::AppHandle) -> Result<Vec<String>, String> {
|
||||||
@@ -80,3 +96,85 @@ pub async fn set_inbox_relays(relays: Vec<String>, state: State<'_, Nostr>) -> R
|
|||||||
Err(e) => Err(e.to_string()),
|
Err(e) => Err(e.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
#[specta::specta]
|
||||||
|
pub async fn connect_inbox_relays(
|
||||||
|
user_id: String,
|
||||||
|
ignore_cache: bool,
|
||||||
|
state: State<'_, Nostr>,
|
||||||
|
) -> Result<Vec<String>, String> {
|
||||||
|
let client = &state.client;
|
||||||
|
let public_key = PublicKey::parse(&user_id).map_err(|e| e.to_string())?;
|
||||||
|
let mut inbox_relays = state.inbox_relays.lock().await;
|
||||||
|
|
||||||
|
if !ignore_cache {
|
||||||
|
if let Some(relays) = inbox_relays.get(&public_key) {
|
||||||
|
for relay in relays {
|
||||||
|
let _ = client.connect_relay(relay).await;
|
||||||
|
}
|
||||||
|
return Ok(relays.to_owned());
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
let inbox = Filter::new().kind(Kind::Custom(10050)).author(public_key).limit(1);
|
||||||
|
|
||||||
|
match client.get_events_of(vec![inbox], Some(Duration::from_secs(2))).await {
|
||||||
|
Ok(events) => {
|
||||||
|
let mut relays = Vec::new();
|
||||||
|
|
||||||
|
if let Some(event) = events.into_iter().next() {
|
||||||
|
for tag in &event.tags {
|
||||||
|
if let Some(TagStandard::Relay(relay)) = tag.as_standardized() {
|
||||||
|
let url = relay.to_string();
|
||||||
|
let _ = client.add_relay(&url).await;
|
||||||
|
let _ = client.connect_relay(&url).await;
|
||||||
|
|
||||||
|
relays.push(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inbox_relays.insert(public_key, relays.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for https://github.com/rust-nostr/nostr/issues/509
|
||||||
|
// TODO: remove this
|
||||||
|
// let relays_clone = relays.clone();
|
||||||
|
/*tauri::async_runtime::spawn(async move {
|
||||||
|
let state = handle.state::<Nostr>();
|
||||||
|
let client = &state.client;
|
||||||
|
|
||||||
|
client
|
||||||
|
.get_events_from(
|
||||||
|
relays_clone,
|
||||||
|
vec![Filter::new().kind(Kind::TextNote).limit(0)],
|
||||||
|
Some(Duration::from_secs(5)),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
Ok(relays)
|
||||||
|
}
|
||||||
|
Err(e) => Err(e.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
#[specta::specta]
|
||||||
|
pub async fn disconnect_inbox_relays(
|
||||||
|
user_id: String,
|
||||||
|
state: State<'_, Nostr>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let client = &state.client;
|
||||||
|
let public_key = PublicKey::parse(&user_id).map_err(|e| e.to_string())?;
|
||||||
|
let inbox_relays = state.inbox_relays.lock().await;
|
||||||
|
|
||||||
|
if let Some(relays) = inbox_relays.get(&public_key) {
|
||||||
|
for relay in relays {
|
||||||
|
let _ = client.disconnect_relay(relay).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ fn main() {
|
|||||||
set_bootstrap_relays,
|
set_bootstrap_relays,
|
||||||
get_inbox_relays,
|
get_inbox_relays,
|
||||||
set_inbox_relays,
|
set_inbox_relays,
|
||||||
|
connect_inbox_relays,
|
||||||
|
disconnect_inbox_relays,
|
||||||
login,
|
login,
|
||||||
delete_account,
|
delete_account,
|
||||||
create_account,
|
create_account,
|
||||||
@@ -41,8 +43,6 @@ fn main() {
|
|||||||
get_contact_list,
|
get_contact_list,
|
||||||
get_chats,
|
get_chats,
|
||||||
get_chat_messages,
|
get_chat_messages,
|
||||||
connect_inbox,
|
|
||||||
disconnect_inbox,
|
|
||||||
send_message,
|
send_message,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,22 @@ try {
|
|||||||
else return { status: "error", error: e as any };
|
else return { status: "error", error: e as any };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async connectInboxRelays(userId: string, ignoreCache: boolean) : Promise<Result<string[], string>> {
|
||||||
|
try {
|
||||||
|
return { status: "ok", data: await TAURI_INVOKE("connect_inbox_relays", { userId, ignoreCache }) };
|
||||||
|
} catch (e) {
|
||||||
|
if(e instanceof Error) throw e;
|
||||||
|
else return { status: "error", error: e as any };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async disconnectInboxRelays(userId: string) : Promise<Result<null, string>> {
|
||||||
|
try {
|
||||||
|
return { status: "ok", data: await TAURI_INVOKE("disconnect_inbox_relays", { userId }) };
|
||||||
|
} catch (e) {
|
||||||
|
if(e instanceof Error) throw e;
|
||||||
|
else return { status: "error", error: e as any };
|
||||||
|
}
|
||||||
|
},
|
||||||
async login(account: string, password: string) : Promise<Result<string, string>> {
|
async login(account: string, password: string) : Promise<Result<string, string>> {
|
||||||
try {
|
try {
|
||||||
return { status: "ok", data: await TAURI_INVOKE("login", { account, password }) };
|
return { status: "ok", data: await TAURI_INVOKE("login", { account, password }) };
|
||||||
@@ -111,22 +127,6 @@ try {
|
|||||||
else return { status: "error", error: e as any };
|
else return { status: "error", error: e as any };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async connectInbox(id: string) : Promise<Result<string[], string>> {
|
|
||||||
try {
|
|
||||||
return { status: "ok", data: await TAURI_INVOKE("connect_inbox", { id }) };
|
|
||||||
} catch (e) {
|
|
||||||
if(e instanceof Error) throw e;
|
|
||||||
else return { status: "error", error: e as any };
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async disconnectInbox(id: string) : Promise<Result<null, string>> {
|
|
||||||
try {
|
|
||||||
return { status: "ok", data: await TAURI_INVOKE("disconnect_inbox", { id }) };
|
|
||||||
} catch (e) {
|
|
||||||
if(e instanceof Error) throw e;
|
|
||||||
else return { status: "error", error: e as any };
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async sendMessage(to: string, message: string) : Promise<Result<null, string>> {
|
async sendMessage(to: string, message: string) : Promise<Result<null, string>> {
|
||||||
try {
|
try {
|
||||||
return { status: "ok", data: await TAURI_INVOKE("send_message", { to, message }) };
|
return { status: "ok", data: await TAURI_INVOKE("send_message", { to, message }) };
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ function Form() {
|
|||||||
const [newMessage, setNewMessage] = useState("");
|
const [newMessage, setNewMessage] = useState("");
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!newMessage.length) return;
|
if (!newMessage.length) return;
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ function AttachMedia({
|
|||||||
}: { callback: Dispatch<SetStateAction<string>> }) {
|
}: { callback: Dispatch<SetStateAction<string>> }) {
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
const attach = async () => {
|
const attach = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
const file = await upload();
|
const file = await upload();
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
import { commands } from "@/commands";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/$account/chats/$id")({
|
export const Route = createFileRoute("/$account/chats/$id")({
|
||||||
loader: async ({ params }) => {
|
loader: async ({ params }) => {
|
||||||
const inboxRelays: string[] = await invoke("connect_inbox", {
|
const res = await commands.connectInboxRelays(params.id, false);
|
||||||
id: params.id,
|
|
||||||
});
|
if (res.status === "ok") {
|
||||||
return inboxRelays;
|
return res.data;
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import { Link, Outlet, createLazyFileRoute } from "@tanstack/react-router";
|
import { Link, Outlet, createLazyFileRoute } from "@tanstack/react-router";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu";
|
import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu";
|
||||||
|
import { readText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { message } from "@tauri-apps/plugin-dialog";
|
import { message } from "@tauri-apps/plugin-dialog";
|
||||||
import { open } from "@tauri-apps/plugin-shell";
|
import { open } from "@tauri-apps/plugin-shell";
|
||||||
import type { NostrEvent } from "nostr-tools";
|
import type { NostrEvent } from "nostr-tools";
|
||||||
@@ -273,20 +274,41 @@ function Compose() {
|
|||||||
|
|
||||||
const navigate = Route.useNavigate();
|
const navigate = Route.useNavigate();
|
||||||
|
|
||||||
const sendMessage = async () => {
|
const pasteFromClipboard = async () => {
|
||||||
|
const val = await readText();
|
||||||
|
setTarget(val);
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendMessage = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!newMessage.length) return;
|
if (!newMessage.length) return;
|
||||||
if (!target.length) return;
|
if (!target.length) return;
|
||||||
|
|
||||||
|
// Connect to user's inbox relays
|
||||||
|
const connect = await commands.connectInboxRelays(target, false);
|
||||||
|
|
||||||
|
// Send message
|
||||||
|
if (connect.status === "ok") {
|
||||||
const res = await commands.sendMessage(target, newMessage);
|
const res = await commands.sendMessage(target, newMessage);
|
||||||
|
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
|
setTarget("");
|
||||||
|
setNewMessage("");
|
||||||
|
setIsOpen(false);
|
||||||
|
|
||||||
navigate({
|
navigate({
|
||||||
to: "/$account/chats/$id",
|
to: "/$account/chats/$id",
|
||||||
params: { account, id: target },
|
params: { account, id: target },
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await message(res.error, { title: "Coop", kind: "error" });
|
await message(res.error, { title: "Send Message", kind: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await message(connect.error, {
|
||||||
|
title: "Connect Inbox Relays",
|
||||||
|
kind: "error",
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -307,7 +329,7 @@ function Compose() {
|
|||||||
<Dialog.Content className="flex flex-col data-[state=open]:animate-content fixed top-[50%] left-[50%] w-full h-full max-h-[500px] max-w-[400px] translate-x-[-50%] translate-y-[-50%] rounded-xl bg-white dark:bg-neutral-900 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none">
|
<Dialog.Content className="flex flex-col data-[state=open]:animate-content fixed top-[50%] left-[50%] w-full h-full max-h-[500px] max-w-[400px] translate-x-[-50%] translate-y-[-50%] rounded-xl bg-white dark:bg-neutral-900 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none">
|
||||||
<div className="h-28 shrink-0 flex flex-col justify-end">
|
<div className="h-28 shrink-0 flex flex-col justify-end">
|
||||||
<div className="h-10 inline-flex items-center justify-between px-3.5 text-sm font-semibold text-neutral-600 dark:text-neutral-400">
|
<div className="h-10 inline-flex items-center justify-between px-3.5 text-sm font-semibold text-neutral-600 dark:text-neutral-400">
|
||||||
Send to
|
<Dialog.Title>Send to</Dialog.Title>
|
||||||
<Dialog.Close asChild>
|
<Dialog.Close asChild>
|
||||||
<button type="button">
|
<button type="button">
|
||||||
<X className="size-4" />
|
<X className="size-4" />
|
||||||
@@ -316,13 +338,22 @@ function Compose() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1 px-3.5 border-b border-neutral-100 dark:border-neutral-800">
|
<div className="flex items-center gap-1 px-3.5 border-b border-neutral-100 dark:border-neutral-800">
|
||||||
<span className="shrink-0 font-medium">To:</span>
|
<span className="shrink-0 font-medium">To:</span>
|
||||||
|
<div className="flex-1 relative">
|
||||||
<input
|
<input
|
||||||
placeholder="npub1..."
|
placeholder="npub1..."
|
||||||
value={target}
|
value={target}
|
||||||
onChange={(e) => setTarget(e.target.value)}
|
onChange={(e) => setTarget(e.target.value)}
|
||||||
disabled={isPending || isLoading}
|
disabled={isPending || isLoading}
|
||||||
className="flex-1 h-9 bg-transparent focus:outline-none placeholder:text-neutral-400 dark:placeholder:text-neutral-600"
|
className="w-full pr-14 h-9 bg-transparent focus:outline-none placeholder:text-neutral-400 dark:placeholder:text-neutral-600"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => pasteFromClipboard()}
|
||||||
|
className="absolute uppercase top-1/2 right-2 transform -translate-y-1/2 text-xs font-semibold text-blue-500"
|
||||||
|
>
|
||||||
|
Paste
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1 px-3.5 border-b border-neutral-100 dark:border-neutral-800">
|
<div className="flex items-center gap-1 px-3.5 border-b border-neutral-100 dark:border-neutral-800">
|
||||||
<span className="shrink-0 font-medium">Message:</span>
|
<span className="shrink-0 font-medium">Message:</span>
|
||||||
@@ -339,7 +370,11 @@ function Compose() {
|
|||||||
onClick={() => sendMessage()}
|
onClick={() => sendMessage()}
|
||||||
className="rounded-full size-7 inline-flex items-center justify-center bg-blue-300 hover:bg-blue-500 dark:bg-blue-700 dark:hover:bg-blue-800 text-white"
|
className="rounded-full size-7 inline-flex items-center justify-center bg-blue-300 hover:bg-blue-500 dark:bg-blue-700 dark:hover:bg-blue-800 text-white"
|
||||||
>
|
>
|
||||||
|
{isPending ? (
|
||||||
|
<Spinner className="size-4" />
|
||||||
|
) : (
|
||||||
<ArrowRight className="size-4" />
|
<ArrowRight className="size-4" />
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function Screen() {
|
|||||||
setRelays((prev) => prev.filter((item) => item !== relay));
|
setRelays((prev) => prev.filter((item) => item !== relay));
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!relays.length) {
|
if (!relays.length) {
|
||||||
await message("You need to add at least 1 relay", { kind: "info" });
|
await message("You need to add at least 1 relay", { kind: "info" });
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function Screen() {
|
|||||||
setRelays((prev) => prev.filter((item) => item !== relay));
|
setRelays((prev) => prev.filter((item) => item !== relay));
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!relays.length) {
|
if (!relays.length) {
|
||||||
await message("You need to add at least 1 relay", {
|
await message("You need to add at least 1 relay", {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function Screen() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!name.length) {
|
if (!name.length) {
|
||||||
await message("Please add your name", {
|
await message("Please add your name", {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function Screen() {
|
|||||||
setKey(val);
|
setKey(val);
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!key.startsWith("nsec1") && !key.startsWith("ncryptsec")) {
|
if (!key.startsWith("nsec1") && !key.startsWith("ncryptsec")) {
|
||||||
await message(
|
await message(
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function Screen() {
|
|||||||
setValue(account);
|
setValue(account);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loginWith = async () => {
|
const loginWith = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!value || !password) return;
|
if (!value || !password) return;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function Screen() {
|
|||||||
setUri(val);
|
setUri(val);
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
if (!uri.startsWith("bunker://")) {
|
if (!uri.startsWith("bunker://")) {
|
||||||
await message(
|
await message(
|
||||||
|
|||||||
Reference in New Issue
Block a user