chore: fix build

This commit is contained in:
reya 2024-02-10 11:19:18 +07:00
parent 739ba63e6c
commit 35c5b5fb78
10 changed files with 136 additions and 43 deletions

View File

@ -1,9 +1,92 @@
import { Timeline } from "@columns/timeline"; 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() { export function HomeScreen() {
const { vlistRef } = useColumn();
return ( return (
<div className="relative w-full h-full"> <div className="relative w-full h-full">
<Timeline column={{ id: 1, title: "", content: "" }} /> <VList
ref={vlistRef}
className="h-full w-full flex-nowrap overflow-x-auto !overflow-y-hidden scrollbar-none focus:outline-none"
itemSize={420}
tabIndex={0}
horizontal
>
<Timeline column={{ id: 1, title: "", content: "" }} />
<div className="w-[420px] h-full flex items-center justify-center">
<button
type="button"
className="size-16 inline-flex items-center justify-center hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded-2xl"
>
<PlusIcon className="size-6" />
</button>
</div>
</VList>
<Tooltip.Provider>
<div className="absolute bottom-3 right-3">
<div className="flex items-center gap-1 p-1 bg-black/50 dark:bg-white/30 backdrop-blur-xl rounded-xl shadow-toolbar">
<Tooltip.Root delayDuration={150}>
<Tooltip.Trigger asChild>
<button
type="button"
className="inline-flex items-center justify-center rounded-lg text-white/70 hover:text-white hover:bg-black/30 size-10"
>
<ArrowLeftIcon className="size-5" />
</button>
</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Content className="inline-flex h-7 select-none text-neutral-50 dark:text-neutral-950 items-center justify-center rounded-md bg-neutral-950 dark:bg-neutral-50 px-3.5 text-sm will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade">
{t("global.moveLeft")}
<Tooltip.Arrow className="fill-neutral-950 dark:fill-neutral-50" />
</Tooltip.Content>
</Tooltip.Portal>
</Tooltip.Root>
<Tooltip.Root delayDuration={150}>
<Tooltip.Trigger asChild>
<button
type="button"
className="inline-flex items-center justify-center rounded-lg text-white/70 hover:text-white hover:bg-black/30 size-10"
>
<ArrowRightIcon className="size-5" />
</button>
</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Content className="inline-flex h-7 select-none text-neutral-50 dark:text-neutral-950 items-center justify-center rounded-md bg-neutral-950 dark:bg-neutral-50 px-3.5 text-sm will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade">
{t("global.moveRight")}
<Tooltip.Arrow className="fill-neutral-950 dark:fill-neutral-50" />
</Tooltip.Content>
</Tooltip.Portal>
</Tooltip.Root>
<Tooltip.Root delayDuration={150}>
<Tooltip.Trigger asChild>
<button
type="button"
className="inline-flex items-center justify-center rounded-lg text-white/70 hover:text-white hover:bg-black/30 size-10"
>
<PlusSquareIcon className="size-5" />
</button>
</Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Content className="inline-flex h-7 select-none text-neutral-50 dark:text-neutral-950 items-center justify-center rounded-md bg-neutral-950 dark:bg-neutral-50 px-3.5 text-sm will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade">
{t("global.newColumn")}
<Tooltip.Arrow className="fill-neutral-950 dark:fill-neutral-50" />
</Tooltip.Content>
</Tooltip.Portal>
</Tooltip.Root>
<div className="w-px h-6 bg-white/10" />
</div>
</div>
</Tooltip.Provider>
</div> </div>
); );
} }

View File

@ -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 { try {
let until: string = undefined;
if (asOf && asOf > 0) until = asOf.toString();
const cmd: Event[] = await invoke("get_text_events", { limit, until }); const cmd: Event[] = await invoke("get_text_events", { limit, until });
return cmd; return cmd;
} catch (e) { } catch (e) {

View File

@ -30,9 +30,15 @@ export class LumeStorage {
} }
public async loadSettings() { public async loadSettings() {
const settings: Settings = JSON.parse(await this.#store.get("settings")); const data = await this.#store.get("settings");
for (const [key, value] of Object.entries(settings)) { if (!data) return;
this.settings[key] = value;
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;
}
} }
} }

View File

@ -47,12 +47,3 @@ default = ["custom-protocol"]
# this feature is used used for production builds where `devPath` points to the filesystem # this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this # DO NOT remove this
custom-protocol = ["tauri/custom-protocol"] 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

View File

@ -22,6 +22,7 @@
"updater:allow-check", "updater:allow-check",
"updater:default", "updater:default",
"window:allow-start-dragging", "window:allow-start-dragging",
"store:allow-get",
{ {
"identifier": "http:default", "identifier": "http:default",
"allow": [ "allow": [

View File

@ -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"]}} {"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"]}}

View File

@ -126,6 +126,7 @@ fn main() {
Ok(()) Ok(())
}) })
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_theme::init(ctx.config_mut())) .plugin(tauri_plugin_theme::init(ctx.config_mut()))
.plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())

View File

@ -4,7 +4,7 @@ use std::{str::FromStr, time::Duration};
use tauri::State; use tauri::State;
#[tauri::command(async)] #[tauri::command(async)]
pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, ()> { pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, String> {
let client = &nostr.client; let client = &nostr.client;
let event_id; let event_id;
@ -21,9 +21,12 @@ pub async fn get_event(id: &str, nostr: State<'_, Nostr>) -> Result<String, ()>
.get_events_of(vec![filter], Some(Duration::from_secs(10))) .get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await .await
.expect("Get event failed"); .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)] #[tauri::command(async)]
@ -48,12 +51,14 @@ pub async fn get_text_events(
.limit(limit) .limit(limit)
.until(final_until); .until(final_until);
let events = client if let Ok(events) = client
.get_events_of(vec![filter], Some(Duration::from_secs(10))) .get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await .await
.expect("Get event failed"); {
Ok(events)
Ok(events) } else {
Err(())
}
} }
#[tauri::command(async)] #[tauri::command(async)]
@ -62,12 +67,14 @@ pub async fn get_event_thread(id: &str, nostr: State<'_, Nostr>) -> Result<Vec<E
let event_id = EventId::from_hex(id).unwrap(); let event_id = EventId::from_hex(id).unwrap();
let filter = Filter::new().kinds(vec![Kind::TextNote]).event(event_id); let filter = Filter::new().kinds(vec![Kind::TextNote]).event(event_id);
let events = client if let Ok(events) = client
.get_events_of(vec![filter], Some(Duration::from_secs(10))) .get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await .await
.expect("Get event failed"); {
Ok(events)
Ok(events) } else {
Err(())
}
} }
#[tauri::command(async)] #[tauri::command(async)]

View File

@ -26,8 +26,10 @@ pub async fn get_profile(id: &str, nostr: State<'_, Nostr>) -> Result<Metadata,
.await .await
.expect("Get metadata failed"); .expect("Get metadata failed");
let event = events.first().unwrap(); if let Some(event) = events.first() {
let metadata: Metadata = Metadata::from_json(&event.content).unwrap(); let metadata: Metadata = Metadata::from_json(&event.content).unwrap();
Ok(metadata)
Ok(metadata) } else {
Err(())
}
} }

View File

@ -1,15 +1,14 @@
{ {
"$schema": "https://turbo.build/schema.json", "$schema": "https://turbo.build/schema.json",
"pipeline": { "pipeline": {
"build": { "build": {
"outputs": [ "outputs": ["dist/**"],
"dist/**" "cache": false
] },
}, "dev": {
"dev": { "cache": false,
"cache": false, "persistent": true
"persistent": true },
}, "type-check": {}
"type-check": {} }
}
} }