diff --git a/apps/desktop2/public/heading-en.png b/apps/desktop2/public/heading-en.png deleted file mode 100644 index fb740945..00000000 Binary files a/apps/desktop2/public/heading-en.png and /dev/null differ diff --git a/apps/desktop2/public/heading-en@2x.png b/apps/desktop2/public/heading-en@2x.png deleted file mode 100644 index 802c679b..00000000 Binary files a/apps/desktop2/public/heading-en@2x.png and /dev/null differ diff --git a/apps/desktop2/public/heading-fr.png b/apps/desktop2/public/heading-fr.png deleted file mode 100644 index 9a1cf82a..00000000 Binary files a/apps/desktop2/public/heading-fr.png and /dev/null differ diff --git a/apps/desktop2/public/heading-fr@2x.png b/apps/desktop2/public/heading-fr@2x.png deleted file mode 100644 index 16bf43fd..00000000 Binary files a/apps/desktop2/public/heading-fr@2x.png and /dev/null differ diff --git a/apps/desktop2/public/heading-ja.png b/apps/desktop2/public/heading-ja.png deleted file mode 100644 index 19134a08..00000000 Binary files a/apps/desktop2/public/heading-ja.png and /dev/null differ diff --git a/apps/desktop2/public/heading-ja@2x.png b/apps/desktop2/public/heading-ja@2x.png deleted file mode 100644 index 606cb59c..00000000 Binary files a/apps/desktop2/public/heading-ja@2x.png and /dev/null differ diff --git a/apps/desktop2/public/icon.jpeg b/apps/desktop2/public/icon.jpeg new file mode 100644 index 00000000..cf1fea19 Binary files /dev/null and b/apps/desktop2/public/icon.jpeg differ diff --git a/apps/desktop2/public/lock-screen.jpg b/apps/desktop2/public/lock-screen.jpg deleted file mode 100644 index d65317bd..00000000 Binary files a/apps/desktop2/public/lock-screen.jpg and /dev/null differ diff --git a/apps/desktop2/public/lock-screen@2x.jpg b/apps/desktop2/public/lock-screen@2x.jpg deleted file mode 100644 index 922f81ad..00000000 Binary files a/apps/desktop2/public/lock-screen@2x.jpg and /dev/null differ diff --git a/apps/desktop2/public/waifu.png b/apps/desktop2/public/waifu.png deleted file mode 100644 index 833949c3..00000000 Binary files a/apps/desktop2/public/waifu.png and /dev/null differ diff --git a/apps/desktop2/public/waifu@2x.png b/apps/desktop2/public/waifu@2x.png deleted file mode 100644 index 484ef2c9..00000000 Binary files a/apps/desktop2/public/waifu@2x.png and /dev/null differ diff --git a/apps/desktop2/src/routes/group.tsx b/apps/desktop2/src/routes/group.tsx index 255a1e77..f41bc5ea 100644 --- a/apps/desktop2/src/routes/group.tsx +++ b/apps/desktop2/src/routes/group.tsx @@ -21,7 +21,7 @@ export const Route = createFileRoute("/group")({ beforeLoad: async ({ search }) => { const key = `lume_group_${search.label}`; const groups = (await NostrQuery.getNstore(key)) as string[]; - const settings = await NostrAccount.getAccounts(); + const settings = await NostrQuery.getSettings(); if (!groups?.length) { throw redirect({ diff --git a/apps/desktop2/src/routes/index.tsx b/apps/desktop2/src/routes/index.tsx index f57a96a3..25f52b12 100644 --- a/apps/desktop2/src/routes/index.tsx +++ b/apps/desktop2/src/routes/index.tsx @@ -4,25 +4,22 @@ import { User } from "@/components/user"; import { checkForAppUpdates } from "@lume/utils"; import { Link } from "@tanstack/react-router"; import { createFileRoute, redirect } from "@tanstack/react-router"; -import { invoke } from "@tauri-apps/api/core"; import { useState } from "react"; import { toast } from "sonner"; import { NostrAccount } from "@lume/system"; export const Route = createFileRoute("/")({ beforeLoad: async () => { + await checkForAppUpdates(true); // check for app updates const accounts = await NostrAccount.getAccounts(); if (accounts.length < 1) { throw redirect({ - to: "/landing/", + to: "/landing", replace: true, }); } - await checkForAppUpdates(true); // check for app updates - await invoke("run_notification", { accounts }); // Run notification service - return { accounts }; }, component: Screen, @@ -65,14 +62,16 @@ function Screen() { return (
-
-

{currentDate}

+
+

+ {currentDate} +

Welcome back!

{loading ? (
- +
) : ( <> @@ -83,42 +82,25 @@ function Screen() { onClick={() => select(account)} > - + - + ))} - -
-
+ +
+
-

Add

+

Add

)}
-
-
); } diff --git a/apps/desktop2/src/routes/landing.lazy.tsx b/apps/desktop2/src/routes/landing.lazy.tsx new file mode 100644 index 00000000..3652ab4d --- /dev/null +++ b/apps/desktop2/src/routes/landing.lazy.tsx @@ -0,0 +1,62 @@ +import { KeyIcon, RemoteIcon } from "@lume/icons"; +import { Link, createLazyFileRoute } from "@tanstack/react-router"; + +export const Route = createLazyFileRoute("/landing")({ + component: Screen, +}); + +function Screen() { + return ( +
+
+
+
+ +
+ App Icon +
+
+ + Create new account + + + Use everywhere + +
+ +
+
+ +
+ +
+ Login with Private Key + + +
+ +
+ Nostr Connect + +
+
+
+
+ ); +} diff --git a/apps/desktop2/src/routes/landing/index.tsx b/apps/desktop2/src/routes/landing/index.tsx deleted file mode 100644 index 23cc9cb8..00000000 --- a/apps/desktop2/src/routes/landing/index.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { KeyIcon, RemoteIcon } from "@lume/icons"; -import { Link, createFileRoute } from "@tanstack/react-router"; -import { useTranslation } from "react-i18next"; - -export const Route = createFileRoute("/landing/")({ - component: Screen, -}); - -function Screen() { - const { t } = useTranslation(); - - return ( -
-
-
-
-
-
- lume -

- {t("welcome.title")} -

-
-
- - {t("welcome.signup")} - -
-
-
{t("login.or")}
-
-
-
- - - Nostr Connect -
- - - - Private Key -
- -
-
-
-
-
- - ); -} diff --git a/packages/system/src/account.ts b/packages/system/src/account.ts index e26f1c58..9b46ac27 100644 --- a/packages/system/src/account.ts +++ b/packages/system/src/account.ts @@ -6,11 +6,7 @@ export class NostrAccount { const query = await commands.getAccounts(); if (query.status === "ok") { - const accounts = query.data - .split(/\s+/) - .filter((v) => v.startsWith("npub1")); - - return [...new Set(accounts)]; + return query.data; } else { return []; } diff --git a/packages/system/src/commands.ts b/packages/system/src/commands.ts index 6ecc71c8..64289696 100644 --- a/packages/system/src/commands.ts +++ b/packages/system/src/commands.ts @@ -31,7 +31,7 @@ export const commands = { else return { status: "error", error: e as any }; } }, - async getAccounts(): Promise> { + async getAccounts(): Promise> { try { return { status: "ok", data: await TAURI_INVOKE("get_accounts") }; } catch (e) { @@ -150,17 +150,6 @@ export const commands = { else return { status: "error", error: e as any }; } }, - async runNotification(accounts: string[]): Promise> { - try { - return { - status: "ok", - data: await TAURI_INVOKE("run_notification", { accounts }), - }; - } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; - } - }, async getActivities( account: string, kind: string, diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 32cdae33..395b90cc 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -40,7 +40,6 @@ fn main() { nostr::keys::user_to_bech32, nostr::keys::to_npub, nostr::keys::verify_nip05, - nostr::metadata::run_notification, nostr::metadata::get_activities, nostr::metadata::get_current_user_profile, nostr::metadata::get_profile, diff --git a/src-tauri/src/nostr/keys.rs b/src-tauri/src/nostr/keys.rs index bcd14902..b6b193ea 100644 --- a/src-tauri/src/nostr/keys.rs +++ b/src-tauri/src/nostr/keys.rs @@ -6,7 +6,7 @@ use serde::Serialize; use specta::Type; use std::str::FromStr; use std::time::Duration; -use tauri::State; +use tauri::{Manager, State}; #[derive(Serialize, Type)] pub struct Account { @@ -16,12 +16,26 @@ pub struct Account { #[tauri::command] #[specta::specta] -pub fn get_accounts() -> Result { +pub fn get_accounts() -> Result, String> { let search = Search::new().unwrap(); let results = search.by("Account", "nostr_secret"); match List::list_credentials(results, Limit::All) { - Ok(list) => Ok(list), + Ok(list) => { + let search: Vec = list + .split_whitespace() + .map(|v| v.to_string()) + .filter(|v| v.starts_with("npub1")) + .collect(); + + let accounts: Vec = search + .into_iter() + .collect::>() + .into_iter() + .collect(); + + Ok(accounts) + } Err(_) => Err("Empty.".into()), } } @@ -86,7 +100,11 @@ pub async fn save_account( #[tauri::command] #[specta::specta] -pub async fn load_account(npub: &str, state: State<'_, Nostr>) -> Result { +pub async fn load_account( + npub: &str, + state: State<'_, Nostr>, + app: tauri::AppHandle, +) -> Result { let client = &state.client; let keyring = Entry::new(npub, "nostr_secret").unwrap(); @@ -122,12 +140,13 @@ pub async fn load_account(npub: &str, state: State<'_, Nostr>) -> Result) -> Result todo!(), }; + // Run notification service + tauri::async_runtime::spawn(async move { + let window = app.get_window("main").unwrap(); + let state = window.state::(); + let client = &state.client; + let subscription = Filter::new() + .pubkey(public_key) + .kinds(vec![Kind::TextNote, Kind::Repost, Kind::ZapReceipt]) + .since(Timestamp::now()); + let activity_id = SubscriptionId::new("activity"); + + // Create a subscription for activity + client + .subscribe_with_id(activity_id.clone(), vec![subscription], None) + .await; + + // Handle notifications + let _ = client + .handle_notifications(|notification| async { + if let RelayPoolNotification::Event { + subscription_id, + event, + .. + } = notification + { + if subscription_id == activity_id { + let _ = app.emit("activity", event.as_json()); + } + } + Ok(false) + }) + .await; + }); + Ok(true) } Err(err) => Err(err.to_string()), diff --git a/src-tauri/src/nostr/metadata.rs b/src-tauri/src/nostr/metadata.rs index e94eb036..f415093f 100644 --- a/src-tauri/src/nostr/metadata.rs +++ b/src-tauri/src/nostr/metadata.rs @@ -2,53 +2,9 @@ use crate::Nostr; use keyring::Entry; use nostr_sdk::prelude::*; use std::{str::FromStr, time::Duration}; -use tauri::{Manager, State}; +use tauri::State; use url::Url; -#[tauri::command] -#[specta::specta] -pub fn run_notification(accounts: Vec, app: tauri::AppHandle) -> Result<(), ()> { - tauri::async_runtime::spawn(async move { - let window = app.get_window("main").unwrap(); - let state = window.state::(); - let client = &state.client; - let pubkeys: Vec = accounts - .into_iter() - .map(|f| PublicKey::from_bech32(f).unwrap()) - .collect(); - let subscription = Filter::new() - .pubkeys(pubkeys) - .kinds(vec![Kind::TextNote, Kind::Repost, Kind::ZapReceipt]) - .since(Timestamp::now()); - let activity_id = SubscriptionId::new("activity"); - - // Create a subscription for activity - client - .subscribe_with_id(activity_id.clone(), vec![subscription], None) - .await; - - // Handle notifications - let _ = client - .handle_notifications(|notification| async { - if let RelayPoolNotification::Event { - subscription_id, - event, - .. - } = notification - { - if subscription_id == activity_id { - println!("new notification: {}", event.as_json()); - let _ = app.emit("activity", event.as_json()); - } - } - Ok(false) - }) - .await; - }); - - Ok(()) -} - #[tauri::command] #[specta::specta] pub async fn get_activities(