From 35c5b5fb78976b2d82487a7d7cd6fd06ca9b439a Mon Sep 17 00:00:00 2001 From: reya Date: Sat, 10 Feb 2024 11:19:18 +0700 Subject: [PATCH] chore: fix build --- apps/desktop/src/routes/home/index.tsx | 85 ++++++++++++++++++++++++- packages/ark/src/ark.ts | 5 +- packages/storage/src/storage.ts | 12 +++- src-tauri/Cargo.toml | 9 --- src-tauri/capabilities/main.json | 1 + src-tauri/gen/schemas/capabilities.json | 2 +- src-tauri/src/main.rs | 1 + src-tauri/src/nostr/event.rs | 29 +++++---- src-tauri/src/nostr/metadata.rs | 10 +-- turbo.json | 25 ++++---- 10 files changed, 136 insertions(+), 43 deletions(-) diff --git a/apps/desktop/src/routes/home/index.tsx b/apps/desktop/src/routes/home/index.tsx index cbcbb194..1eedf47a 100644 --- a/apps/desktop/src/routes/home/index.tsx +++ b/apps/desktop/src/routes/home/index.tsx @@ -1,9 +1,92 @@ import { Timeline } from "@columns/timeline"; +import { + ArrowLeftIcon, + ArrowRightIcon, + PlusIcon, + PlusSquareIcon, +} from "@lume/icons"; +import { useColumn } from "@lume/storage"; +import * as Tooltip from "@radix-ui/react-tooltip"; +import { t } from "i18next"; +import { VList } from "virtua"; export function HomeScreen() { + const { vlistRef } = useColumn(); + return (
- + + +
+ +
+
+ +
+
+ + + + + + + {t("global.moveLeft")} + + + + + + + + + + + {t("global.moveRight")} + + + + + + + + + + + {t("global.newColumn")} + + + + +
+
+
+
); } diff --git a/packages/ark/src/ark.ts b/packages/ark/src/ark.ts index cf55d1f4..3d75da4b 100644 --- a/packages/ark/src/ark.ts +++ b/packages/ark/src/ark.ts @@ -43,8 +43,11 @@ export class Ark { } } - public async get_text_events(limit: number, until?: number) { + public async get_text_events(limit: number, asOf?: number) { try { + let until: string = undefined; + if (asOf && asOf > 0) until = asOf.toString(); + const cmd: Event[] = await invoke("get_text_events", { limit, until }); return cmd; } catch (e) { diff --git a/packages/storage/src/storage.ts b/packages/storage/src/storage.ts index 9d544d6c..3d71c9cc 100644 --- a/packages/storage/src/storage.ts +++ b/packages/storage/src/storage.ts @@ -30,9 +30,15 @@ export class LumeStorage { } public async loadSettings() { - const settings: Settings = JSON.parse(await this.#store.get("settings")); - for (const [key, value] of Object.entries(settings)) { - this.settings[key] = value; + const data = await this.#store.get("settings"); + if (!data) return; + + const settings = JSON.parse(data as string) as Settings; + + if (Object.keys(settings).length) { + for (const [key, value] of Object.entries(settings)) { + this.settings[key] = value; + } } } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b1297e76..a34a9d56 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -47,12 +47,3 @@ default = ["custom-protocol"] # this feature is used used for production builds where `devPath` points to the filesystem # DO NOT remove this custom-protocol = ["tauri/custom-protocol"] - -# Optimized for bundle size. If you want faster builds comment out/delete this section. -[profile.release] -lto = true # Enable Link Time Optimization -opt-level = "z" # Optimize for size. -codegen-units = 1 # Reduce number of codegen units to increase optimizations. -panic = "abort" # Abort on panic -strip = true # Automatically strip symbols from the binary. -debug = false diff --git a/src-tauri/capabilities/main.json b/src-tauri/capabilities/main.json index 7c0d6d74..660381f7 100644 --- a/src-tauri/capabilities/main.json +++ b/src-tauri/capabilities/main.json @@ -22,6 +22,7 @@ "updater:allow-check", "updater:default", "window:allow-start-dragging", + "store:allow-get", { "identifier": "http:default", "allow": [ diff --git a/src-tauri/gen/schemas/capabilities.json b/src-tauri/gen/schemas/capabilities.json index d96cafc5..8d1b3624 100644 --- a/src-tauri/gen/schemas/capabilities.json +++ b/src-tauri/gen/schemas/capabilities.json @@ -1 +1 @@ -{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","context":"local","windows":["main","settings","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","theme:allow-set-theme","theme:allow-get-theme","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}} \ No newline at end of file +{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","context":"local","windows":["main","settings","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","theme:allow-set-theme","theme:allow-get-theme","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","store:allow-get",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}} \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7bccc499..266221ab 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -126,6 +126,7 @@ fn main() { Ok(()) }) + .plugin(tauri_plugin_store::Builder::default().build()) .plugin(tauri_plugin_theme::init(ctx.config_mut())) .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_dialog::init()) diff --git a/src-tauri/src/nostr/event.rs b/src-tauri/src/nostr/event.rs index 87636116..69e559d7 100644 --- a/src-tauri/src/nostr/event.rs +++ b/src-tauri/src/nostr/event.rs @@ -4,7 +4,7 @@ use std::{str::FromStr, time::Duration}; use tauri::State; #[tauri::command(async)] -pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result { +pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result { let client = &nostr.client; let event_id; @@ -21,9 +21,12 @@ pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result .get_events_of(vec![filter], Some(Duration::from_secs(10))) .await .expect("Get event failed"); - let event = events.first().unwrap().as_json(); - Ok(event) + if let Some(event) = events.first() { + Ok(event.as_json()) + } else { + Err("Event not found".into()) + } } #[tauri::command(async)] @@ -48,12 +51,14 @@ pub async fn get_text_events( .limit(limit) .until(final_until); - let events = client + if let Ok(events) = client .get_events_of(vec![filter], Some(Duration::from_secs(10))) .await - .expect("Get event failed"); - - Ok(events) + { + Ok(events) + } else { + Err(()) + } } #[tauri::command(async)] @@ -62,12 +67,14 @@ pub async fn get_event_thread(id: &str, nostr: State<'_, Nostr>) -> Result) -> Result