import { useArk } from "@lume/ark"; import { LoaderIcon } from "@lume/icons"; import { delay, VITE_FLATPAK_RESOURCE } from "@lume/utils"; import { resolve, resolveResource } from "@tauri-apps/api/path"; import { useStorage } from "@lume/storage"; import { readTextFile, writeTextFile } from "@tauri-apps/plugin-fs"; import { useState } from "react"; import { useNavigate } from "react-router-dom"; import { parse, stringify } from "smol-toml"; import { toast } from "sonner"; export function DepotOnboardingScreen() { const ark = useArk(); const storage = useStorage(); const navigate = useNavigate(); const [loading, setLoading] = useState(false); const launchDepot = async () => { try { setLoading(true); // get default config const defaultConfig = VITE_FLATPAK_RESOURCE !== null ? await resolve("/", VITE_FLATPAK_RESOURCE) : await resolveResource("resources/config.toml"); const config = await readTextFile(defaultConfig); const parsedConfig = parse(config); // add current user to whitelist // biome-ignore lint/complexity/useLiteralKeys: parsedConfig.authorization["pubkey_whitelist"].push(ark.account.pubkey); // update new config const newConfig = stringify(parsedConfig); await writeTextFile(defaultConfig, newConfig); // launch depot await storage.launchDepot(); await storage.createSetting("depot", "1"); await delay(2000); // delay 2s to make sure depot is running // default depot url: ws://localhost:6090 // #TODO: user can custom depot url const connect = await ark.connectDepot(); if (connect) { toast.success("Your Depot is successfully launch."); setLoading(false); navigate("/depot/"); } } catch (e) { toast.error(String(e)); } }; return (

Run your Personal Nostr Relay inside Lume

Your Relay, Your Control.

); }