(undefined);
diff --git a/packages/lume-column-timeline/src/home.tsx b/packages/lume-column-timeline/src/home.tsx
index cacb30e9..17f4c4eb 100644
--- a/packages/lume-column-timeline/src/home.tsx
+++ b/packages/lume-column-timeline/src/home.tsx
@@ -1,5 +1,6 @@
import { RepostNote, TextNote, useArk } from "@lume/ark";
import { ArrowRightCircleIcon, LoaderIcon, SearchIcon } from "@lume/icons";
+import { Event, Kind } from "@lume/types";
import { EmptyFeed } from "@lume/ui";
import { FETCH_LIMIT } from "@lume/utils";
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
@@ -30,18 +31,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
signal: AbortSignal;
pageParam: number;
}) => {
- if (!ark.account.contacts.length) return [];
-
- const events = await ark.getInfiniteEvents({
- filter: {
- kinds: [NDKKind.Text, NDKKind.Repost],
- authors: ark.account.contacts,
- },
- limit: FETCH_LIMIT,
- pageParam,
- signal,
- });
-
+ const events = await ark.get_text_events(FETCH_LIMIT);
return events;
},
getNextPageParam: (lastPage) => {
@@ -54,11 +44,11 @@ export function HomeRoute({ colKey }: { colKey: string }) {
refetchOnMount: false,
});
- const renderItem = (event: NDKEvent) => {
+ const renderItem = (event: Event) => {
switch (event.kind) {
- case NDKKind.Text:
+ case Kind.Text:
return
;
- case NDKKind.Repost:
+ case Kind.Repost:
return
;
default:
return
;
@@ -81,6 +71,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
};
}, []);
+ /*
if (!ark.account.contacts.length) {
return (
@@ -95,6 +86,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
);
}
+ */
return (
diff --git a/packages/lume-column-timeline/src/index.tsx b/packages/lume-column-timeline/src/index.tsx
index fad7c37b..3324b29c 100644
--- a/packages/lume-column-timeline/src/index.tsx
+++ b/packages/lume-column-timeline/src/index.tsx
@@ -1,17 +1,15 @@
-import { Column, useArk } from "@lume/ark";
+import { Column } from "@lume/ark";
import { IColumn } from "@lume/types";
import { EventRoute, SuggestRoute, UserRoute } from "@lume/ui";
-import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
-import { useQueryClient } from "@tanstack/react-query";
-import { useRef } from "react";
import { HomeRoute } from "./home";
export function Timeline({ column }: { column: IColumn }) {
const colKey = `timeline-${column.id}`;
- const ark = useArk();
- const queryClient = useQueryClient();
- const since = useRef(Math.floor(Date.now() / 1000));
+ // const ark = useArk();
+ // const queryClient = useQueryClient();
+ // const since = useRef(Math.floor(Date.now() / 1000));
+ /*
const refresh = async (events: NDKEvent[]) => {
const uniqEvents = new Set(events);
await queryClient.setQueryData(
@@ -22,11 +20,12 @@ export function Timeline({ column }: { column: IColumn }) {
}),
);
};
+ */
return (
-
- {ark.account.contacts.length ? (
+ {/**/}
+ {/*ark.account.contacts.length ? (
- ) : null}
+ ) : null*/}
} />
- } />
- } />
- }
- />
+ {/*
+ } />
+ } />
+ }
+ />
+ */}
);
diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts
index 1a1f9c24..e169b8df 100644
--- a/packages/types/index.d.ts
+++ b/packages/types/index.d.ts
@@ -41,9 +41,10 @@ export interface Metadata {
}
export interface CurrentAccount {
- npub: string;
- contacts: string[];
- interests: Interests;
+ pubkey: string;
+ npub?: string;
+ contacts?: string[];
+ interests?: Interests;
}
export interface Interests {
diff --git a/packages/ui/src/account/active.tsx b/packages/ui/src/account/active.tsx
index d6ecf5f8..47aadc5f 100644
--- a/packages/ui/src/account/active.tsx
+++ b/packages/ui/src/account/active.tsx
@@ -29,7 +29,7 @@ export function ActiveAccount() {
{
};
export function EditorForm() {
- const ark = useArk();
- const storage = useStorage();
const ref = useRef();
const [editorValue, setEditorValue] = useAtom(editorValueAtom);
@@ -202,7 +201,6 @@ export function EditorForm() {
);
const { t } = useTranslation();
- const { addColumn } = useColumnContext();
const filters = contacts
?.filter((c) => c?.name?.toLowerCase().startsWith(search.toLowerCase()))
@@ -242,32 +240,24 @@ export function EditorForm() {
try {
setLoading(true);
- const event = new NDKEvent(ark.ndk);
- event.kind = NDKKind.Text;
- event.content = serialize(editor.children);
-
- const publish = await event.publish();
+ const content = serialize(editor.children);
+ const publish = await invoke("publish", { content });
if (publish) {
+ console.log(publish);
toast.success(t("editor.successMessage"));
- // add current post as column thread
- addColumn({
- kind: COL_TYPES.thread,
- content: event.id,
- title: "Thread",
- });
-
- setLoading(false);
-
return reset();
}
+
+ setLoading(false);
} catch (e) {
setLoading(false);
toast.error(String(e));
}
};
+ /*
useEffect(() => {
async function loadContacts() {
const res = await storage.getAllCacheUsers();
@@ -276,6 +266,7 @@ export function EditorForm() {
loadContacts();
}, []);
+ */
useEffect(() => {
if (target && filters.length > 0) {
diff --git a/packages/ui/src/search/dialog.tsx b/packages/ui/src/search/dialog.tsx
index 7aa06d00..88ee251c 100644
--- a/packages/ui/src/search/dialog.tsx
+++ b/packages/ui/src/search/dialog.tsx
@@ -1,4 +1,4 @@
-import { Note, User, useArk, useColumnContext } from "@lume/ark";
+import { Note, User, useArk } from "@lume/ark";
import { LoaderIcon, SearchIcon } from "@lume/icons";
import { COL_TYPES, searchAtom } from "@lume/utils";
import { type NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
@@ -18,7 +18,6 @@ export function SearchDialog() {
const [value] = useDebounce(search, 1200);
const { t } = useTranslation();
- const { vlistRef, columns, addColumn } = useColumnContext();
const searchEvents = async () => {
if (!value.length) return;
diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs
index 58ce6ede..1434139e 100644
--- a/src-tauri/src/commands.rs
+++ b/src-tauri/src/commands.rs
@@ -1,3 +1,2 @@
pub mod folder;
pub mod opg;
-pub mod secret;
diff --git a/src-tauri/src/commands/secret.rs b/src-tauri/src/commands/secret.rs
deleted file mode 100644
index 71ba6c0d..00000000
--- a/src-tauri/src/commands/secret.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-use keyring::Entry;
-
-#[tauri::command]
-pub fn secure_save(key: String, value: String) -> Result<(), ()> {
- let entry = Entry::new("Lume", &key).expect("Failed to create entry");
- let _ = entry.set_password(&value);
- Ok(())
-}
-
-#[tauri::command]
-pub fn secure_load(key: String) -> Result {
- let entry = Entry::new("Lume", &key).expect("Failed to create entry");
- if let Ok(password) = entry.get_password() {
- Ok(password.into())
- } else {
- Err("Not found".into())
- }
-}
-
-#[tauri::command]
-pub fn secure_remove(key: String) -> Result<(), ()> {
- let entry = Entry::new("Lume", &key).expect("Failed to remove entry");
- let _ = entry.delete_password();
- Ok(())
-}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index d237a6b1..7bccc499 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -23,6 +23,7 @@ use tauri_plugin_autostart::MacosLauncher;
pub struct Nostr {
pub client: Arc,
+ pub client_user: Option,
pub contact_list: Option>,
}
@@ -90,17 +91,22 @@ fn main() {
client.connect().await;
// Prepare contact list
+ let mut user = None;
let mut contact_list = None;
// Run somethings if account existed
if let Some(key) = stored_nsec_key {
let secret_key = SecretKey::from_bech32(key).expect("Get secret key failed");
let keys = Keys::new(secret_key);
+ let public_key = keys.public_key();
let signer = ClientSigner::Keys(keys);
// Update client's signer
client.set_signer(Some(signer)).await;
+ // Update user
+ user = Some(public_key);
+
// Get contact list
contact_list = Some(
client
@@ -113,6 +119,7 @@ fn main() {
// Init global state
handle.manage(Nostr {
client: client.into(),
+ client_user: user.into(),
contact_list: contact_list.into(),
})
});
@@ -152,9 +159,6 @@ fn main() {
nostr::event::repost,
nostr::event::upvote,
nostr::event::downvote,
- commands::secret::secure_save,
- commands::secret::secure_load,
- commands::secret::secure_remove,
commands::folder::show_in_folder,
commands::opg::fetch_opg,
])
diff --git a/src-tauri/src/nostr/event.rs b/src-tauri/src/nostr/event.rs
index 1180607d..87636116 100644
--- a/src-tauri/src/nostr/event.rs
+++ b/src-tauri/src/nostr/event.rs
@@ -8,12 +8,10 @@ pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result
let client = &nostr.client;
let event_id;
- if id.starts_with("note1") {
- event_id = EventId::from_bech32(id).unwrap();
- } else if id.starts_with("nevent1") {
- event_id = EventId::from_bech32(id).unwrap();
- } else if id.starts_with("naddr1") {
+ if id.starts_with("note") {
event_id = EventId::from_bech32(id).unwrap();
+ } else if id.starts_with("nevent") {
+ event_id = Nip19Event::from_bech32(id).unwrap().event_id;
} else {
event_id = EventId::from_hex(id).unwrap();
}
diff --git a/src-tauri/src/nostr/keys.rs b/src-tauri/src/nostr/keys.rs
index 6d4a49cb..cf4a56c3 100644
--- a/src-tauri/src/nostr/keys.rs
+++ b/src-tauri/src/nostr/keys.rs
@@ -25,7 +25,7 @@ pub fn create_keys() -> Result {
}
#[tauri::command]
-pub fn save_key(nsec: &str, app_handle: tauri::AppHandle) -> Result<(), ()> {
+pub fn save_key(nsec: &str, app_handle: tauri::AppHandle) -> Result {
if let Ok(nostr_secret_key) = SecretKey::from_bech32(nsec) {
let nostr_keys = Keys::new(nostr_secret_key);
let nostr_npub = nostr_keys.public_key().to_bech32().unwrap();
@@ -50,9 +50,9 @@ pub fn save_key(nsec: &str, app_handle: tauri::AppHandle) -> Result<(), ()> {
.expect("Write nsec failed");
writer.finish().expect("Save nsec failed");
- Ok(())
+ Ok(true)
} else {
- Err(())
+ Err(false)
}
}
@@ -76,11 +76,19 @@ pub async fn update_signer(nsec: &str, nostr: State<'_, Nostr>) -> Result<(), ()
}
#[tauri::command]
-pub async fn verify_signer(nostr: State<'_, Nostr>) -> Result {
+pub async fn verify_signer(nostr: State<'_, Nostr>) -> Result {
let client = &nostr.client;
- let status = client.signer().await.is_ok();
+ let user = &nostr.client_user;
- Ok(status)
+ if let Ok(_) = client.signer().await {
+ if let Some(public_key) = user {
+ Ok(public_key.to_string())
+ } else {
+ Err(())
+ }
+ } else {
+ Err(())
+ }
}
#[tauri::command]