diff --git a/apps/desktop2/src/routes/open.lazy.tsx b/apps/desktop2/src/routes/open.lazy.tsx
index 51ea076c..5eac8dfe 100644
--- a/apps/desktop2/src/routes/open.lazy.tsx
+++ b/apps/desktop2/src/routes/open.lazy.tsx
@@ -22,8 +22,8 @@ function Screen() {
type="button"
onClick={() =>
install({
- id: 9999,
- name: "Lume Store",
+ label: "store",
+ name: "Store",
content: "/store/official",
})
}
@@ -36,8 +36,8 @@ function Screen() {
type="button"
onClick={() =>
install({
- id: 9999,
- name: "Lume Store",
+ label: "store",
+ name: "Store",
content: "/store/official",
})
}
diff --git a/apps/desktop2/src/routes/store.official.tsx b/apps/desktop2/src/routes/store.official.tsx
index 881a4bd7..2f6d093f 100644
--- a/apps/desktop2/src/routes/store.official.tsx
+++ b/apps/desktop2/src/routes/store.official.tsx
@@ -1,68 +1,27 @@
import { LumeColumn } from "@lume/types";
import { createFileRoute } from "@tanstack/react-router";
+import { resolveResource } from "@tauri-apps/api/path";
import { getCurrent } from "@tauri-apps/api/window";
+import { readTextFile } from "@tauri-apps/plugin-fs";
export const Route = createFileRoute("/store/official")({
component: Screen,
- loader: () => {
- const columns: LumeColumn[] = [
- {
- id: 10002,
- name: "For you",
- content: "/foryou",
- logo: "",
- cover: "/foryou.png",
- coverRetina: "/foryou@2x.png",
- author: "Lume",
- description: "Keep up to date with content based on your interests.",
- },
- {
- id: 10003,
- name: "Group Feeds",
- content: "/group",
- logo: "",
- cover: "/group.png",
- coverRetina: "/group@2x.png",
- author: "Lume",
- description: "Collective of people you're interested in.",
- },
- {
- id: 10004,
- name: "Antenas",
- content: "/antenas",
- logo: "",
- cover: "/antenas.png",
- coverRetina: "/antenas@2x.png",
- author: "Lume",
- description: "Keep track to specific content.",
- },
- {
- id: 10005,
- name: "Trending",
- content: "/trending",
- logo: "",
- cover: "/trending.png",
- coverRetina: "/trending@2x.png",
- author: "Lume",
- description: "What is trending on Nostr?.",
- },
- {
- id: 10006,
- name: "Global",
- content: "/global",
- logo: "",
- cover: "/global.png",
- coverRetina: "/global@2x.png",
- author: "Lume",
- description: "All events from connected relays.",
- },
- ];
- return columns;
+ beforeLoad: async () => {
+ const resourcePath = await resolveResource(
+ "resources/official_columns.json",
+ );
+ const officialColumns: LumeColumn[] = JSON.parse(
+ await readTextFile(resourcePath),
+ );
+
+ return {
+ officialColumns,
+ };
},
});
function Screen() {
- const data = Route.useLoaderData();
+ const { officialColumns } = Route.useRouteContext();
const install = async (column: LumeColumn) => {
const mainWindow = getCurrent();
@@ -71,9 +30,9 @@ function Screen() {
return (
- {data.map((column) => (
+ {officialColumns.map((column) => (
{column.cover ? (
diff --git a/apps/desktop2/src/routes/store.tsx b/apps/desktop2/src/routes/store.tsx
index 905e9a7a..46d98bd7 100644
--- a/apps/desktop2/src/routes/store.tsx
+++ b/apps/desktop2/src/routes/store.tsx
@@ -1,63 +1,61 @@
-import { CancelIcon, GlobalIcon, LaurelIcon } from "@lume/icons";
+import { GlobalIcon, LaurelIcon } from "@lume/icons";
+import { ColumnRouteSearch } from "@lume/types";
import { Column } from "@lume/ui";
import { cn } from "@lume/utils";
import { Link } from "@tanstack/react-router";
import { Outlet, createFileRoute } from "@tanstack/react-router";
-import { getCurrent } from "@tauri-apps/api/window";
export const Route = createFileRoute("/store")({
component: Screen,
+ validateSearch: (search: Record
): ColumnRouteSearch => {
+ return {
+ account: search.account,
+ label: search.label,
+ name: search.name,
+ };
+ },
});
function Screen() {
- // @ts-ignore, just work!!!
- const { id } = Route.useSearch();
-
- const close = async () => {
- const mainWindow = getCurrent();
- await mainWindow.emit("columns", { type: "remove", id });
- };
+ const { label, name } = Route.useSearch();
return (
-
-
-
-
- {({ isActive }) => (
-
-
- Official
-
- )}
-
-
- {({ isActive }) => (
-
-
- Community
-
- )}
-
-
-
+
+
+
+ {({ isActive }) => (
+
+
+ Official
+
+ )}
+
+
+ {({ isActive }) => (
+
+
+ Community
+
+ )}
+
+
+
diff --git a/packages/ark/src/ark.ts b/packages/ark/src/ark.ts
index b392bcdf..592f517f 100644
--- a/packages/ark/src/ark.ts
+++ b/packages/ark/src/ark.ts
@@ -6,6 +6,7 @@ import type {
EventWithReplies,
Interests,
Keys,
+ LumeColumn,
Metadata,
Settings,
} from "@lume/types";
@@ -14,6 +15,13 @@ import { open } from "@tauri-apps/plugin-dialog";
import { readFile } from "@tauri-apps/plugin-fs";
import { generateContentTags } from "@lume/utils";
+enum NSTORE_KEYS {
+ settings = "lume_user_settings",
+ interests = "lume_user_interests",
+ columns = "lume_user_columns",
+ group = "lume_group_",
+}
+
export class Ark {
public windows: WebviewWindow[];
@@ -565,13 +573,36 @@ export class Ark {
}
}
- public async get_settings(id: string) {
+ public async get_columns() {
try {
- const cmd: string = await invoke("get_settings", { id });
- if (!cmd) return null;
- if (!cmd.length) return null;
+ const cmd: string = await invoke("get_nstore", {
+ key: NSTORE_KEYS.columns,
+ });
+ const columns: LumeColumn[] = cmd ? JSON.parse(cmd) : [];
+ return columns;
+ } catch {
+ return [];
+ }
+ }
- const settings: Settings = JSON.parse(cmd);
+ public async set_columns(columns: LumeColumn[]) {
+ try {
+ const cmd: string = await invoke("set_nstore", {
+ key: NSTORE_KEYS.columns,
+ content: JSON.stringify(columns),
+ });
+ return cmd;
+ } catch (e) {
+ throw new Error(e);
+ }
+ }
+
+ public async get_settings() {
+ try {
+ const cmd: string = await invoke("get_nstore", {
+ key: NSTORE_KEYS.settings,
+ });
+ const settings: Settings = cmd ? JSON.parse(cmd) : null;
return settings;
} catch {
const defaultSettings: Settings = {
@@ -585,7 +616,8 @@ export class Ark {
public async set_settings(settings: Settings) {
try {
- const cmd: string = await invoke("set_settings", {
+ const cmd: string = await invoke("set_nstore", {
+ key: NSTORE_KEYS.settings,
content: JSON.stringify(settings),
});
return cmd;
@@ -594,13 +626,12 @@ export class Ark {
}
}
- public async get_interest(id: string) {
+ public async get_interest() {
try {
- const cmd: string = await invoke("get_interest", { id });
- if (!cmd) return null;
- if (!cmd.length) return null;
-
- const interests: Interests = JSON.parse(cmd);
+ const cmd: string = await invoke("get_nstore", {
+ key: NSTORE_KEYS.interests,
+ });
+ const interests: Interests = cmd ? JSON.parse(cmd) : null;
return interests;
} catch {
return null;
@@ -618,7 +649,8 @@ export class Ark {
users: users ?? [],
hashtags: hashtags ?? [],
};
- const cmd: string = await invoke("set_interest", {
+ const cmd: string = await invoke("set_nstore", {
+ key: NSTORE_KEYS.interests,
content: JSON.stringify(interests),
});
return cmd;
diff --git a/packages/icons/src/refresh.tsx b/packages/icons/src/refresh.tsx
index 1bf56169..02a482a8 100644
--- a/packages/icons/src/refresh.tsx
+++ b/packages/icons/src/refresh.tsx
@@ -1,18 +1,17 @@
-export function RefreshIcon(props: JSX.IntrinsicElements['svg']) {
+export function RefreshIcon(props: JSX.IntrinsicElements["svg"]) {
return (
-
);
}
diff --git a/packages/ui/src/column/root.tsx b/packages/ui/src/column/root.tsx
index dcc46107..41e554ea 100644
--- a/packages/ui/src/column/root.tsx
+++ b/packages/ui/src/column/root.tsx
@@ -3,20 +3,20 @@ import { ReactNode } from "react";
export function ColumnRoot({
children,
- shadow = true,
- background = true,
className,
+ background = true,
+ shadow = true,
}: {
children: ReactNode;
- shadow?: boolean;
- background?: boolean;
className?: string;
+ background?: boolean;
+ shadow?: boolean;
}) {
return (
) -> Result
) -> Result {
+pub async fn set_nstore(
+ key: &str,
+ content: &str,
+ state: State<'_, Nostr>,
+) -> Result {
let client = &state.client;
- let tag = Tag::Identifier("lume_user_interest".into());
+ let tag = Tag::Identifier(key.into());
let builder = EventBuilder::new(Kind::ApplicationSpecificData, content, vec![tag]);
if let Ok(event_id) = client.send_event_builder(builder).await {
+ println!("set nstore: {}", event_id);
Ok(event_id)
} else {
- Err("Set interest failed".into())
+ Err("Event has been published failled".into())
}
}
#[tauri::command]
-pub async fn get_interest(id: &str, state: State<'_, Nostr>) -> Result {
+pub async fn get_nstore(key: &str, state: State<'_, Nostr>) -> Result {
let client = &state.client;
- let public_key: Option = match Nip19::from_bech32(id) {
- Ok(val) => match val {
- Nip19::Pubkey(pubkey) => Some(pubkey),
- Nip19::Profile(profile) => Some(profile.public_key),
- _ => None,
- },
- Err(_) => match PublicKey::from_str(id) {
- Ok(val) => Some(val),
- Err(_) => None,
- },
- };
+ let signer = client.signer().await.unwrap();
+ let public_key = signer.public_key().await;
- if let Some(author) = public_key {
+ if let Ok(author) = public_key {
let filter = Filter::new()
.author(author)
.kind(Kind::ApplicationSpecificData)
- .identifier("lume_user_interest")
+ .identifier(key)
.limit(1);
let query = client
@@ -219,68 +215,17 @@ pub async fn get_interest(id: &str, state: State<'_, Nostr>) -> Result) -> Result {
- let client = &state.client;
- let tag = Tag::Identifier("lume_user_settings".into());
- let builder = EventBuilder::new(Kind::ApplicationSpecificData, content, vec![tag]);
-
- if let Ok(event_id) = client.send_event_builder(builder).await {
- Ok(event_id)
- } else {
- Err("Set settings failed".into())
- }
-}
-
-#[tauri::command]
-pub async fn get_settings(id: &str, state: State<'_, Nostr>) -> Result {
- let client = &state.client;
- let public_key: Option = match Nip19::from_bech32(id) {
- Ok(val) => match val {
- Nip19::Pubkey(pubkey) => Some(pubkey),
- Nip19::Profile(profile) => Some(profile.public_key),
- _ => None,
- },
- Err(_) => match PublicKey::from_str(id) {
- Ok(val) => Some(val),
- Err(_) => None,
- },
- };
-
- if let Some(author) = public_key {
- let filter = Filter::new()
- .author(author)
- .kind(Kind::ApplicationSpecificData)
- .identifier("lume_user_settings")
- .limit(1);
-
- let query = client
- .get_events_of(vec![filter], Some(Duration::from_secs(10)))
- .await;
-
- if let Ok(events) = query {
- if let Some(event) = events.first() {
- Ok(event.content.to_string())
- } else {
- Err("User settings not found".into())
- }
- } else {
- Err("User settings not found".into())
- }
- } else {
- Err("Get settings failed".into())
+ Err("Something is wrong".into())
}
}
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 524ddfb8..8a67f2d9 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -44,7 +44,7 @@
"targets": "all",
"active": true,
"category": "SocialNetworking",
- "resources": ["resources/*", "./locales/*"],
+ "resources": ["resources/*", "locales/*"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",