import { LaurelIcon } from "@lume/icons"; import { createFileRoute, useNavigate } from "@tanstack/react-router"; import { useTranslation } from "react-i18next"; import * as Switch from "@radix-ui/react-switch"; import { useState } from "react"; import { AppRouteSearch, Settings } from "@lume/types"; import { isPermissionGranted, requestPermission, } from "@tauri-apps/plugin-notification"; import { toast } from "sonner"; import { Spinner } from "@lume/ui"; export const Route = createFileRoute("/auth/settings")({ validateSearch: (search: Record): AppRouteSearch => { return { account: search.account, }; }, beforeLoad: async ({ context }) => { const permissionGranted = await isPermissionGranted(); // get notification permission const ark = context.ark; const settings = await ark.get_settings(); return { settings: { ...settings, notification: permissionGranted }, }; }, component: Screen, pendingComponent: Pending, }); function Screen() { const navigate = useNavigate(); const { account } = Route.useSearch(); const { t } = useTranslation(); const { ark, settings } = Route.useRouteContext(); const [newSettings, setNewSettings] = useState(settings); const [loading, setLoading] = useState(false); const toggleNofitication = async () => { await requestPermission(); setNewSettings((prev) => ({ ...prev, notification: !newSettings.notification, })); }; const toggleAutoUpdate = () => { setNewSettings((prev) => ({ ...prev, autoUpdate: !newSettings.autoUpdate, })); }; const toggleEnhancedPrivacy = () => { setNewSettings((prev) => ({ ...prev, enhancedPrivacy: !newSettings.enhancedPrivacy, })); }; const toggleZap = () => { setNewSettings((prev) => ({ ...prev, zap: !newSettings.zap, })); }; const toggleNsfw = () => { setNewSettings((prev) => ({ ...prev, nsfw: !newSettings.nsfw, })); }; const submit = async () => { try { // start loading setLoading(true); // publish settings const eventId = await ark.set_settings(newSettings); if (eventId) { console.log("event_id: ", eventId); navigate({ to: "/$account/home", params: { account }, replace: true }); } } catch (e) { setLoading(false); toast.error(e); } }; return (

{t("onboardingSettings.title")}

{t("onboardingSettings.subtitle")}

toggleNofitication()} className="relative mt-1 h-7 w-12 shrink-0 cursor-default rounded-full bg-neutral-200 outline-none data-[state=checked]:bg-blue-500 dark:bg-neutral-800" >

Push Notification

Enabling push notifications will allow you to receive notifications from Lume.

toggleEnhancedPrivacy()} className="relative mt-1 h-7 w-12 shrink-0 cursor-default rounded-full bg-neutral-200 outline-none data-[state=checked]:bg-blue-500 dark:bg-neutral-800" >

Enhanced Privacy

Lume will display external resources like image, video or link preview as plain text.

toggleAutoUpdate()} className="relative mt-1 h-7 w-12 shrink-0 cursor-default rounded-full bg-neutral-200 outline-none data-[state=checked]:bg-blue-500 dark:bg-neutral-800" >

Auto Update

Automatically download and install new version.

toggleZap()} className="relative mt-1 h-7 w-12 shrink-0 cursor-default rounded-full bg-neutral-200 outline-none data-[state=checked]:bg-blue-500 dark:bg-neutral-800" >

Zap

Show the Zap button in each note and user's profile screen, use for send Bitcoin tip to other users.

toggleNsfw()} className="relative mt-1 h-7 w-12 shrink-0 cursor-default rounded-full bg-neutral-200 outline-none data-[state=checked]:bg-blue-500 dark:bg-neutral-800" >

Filter sensitive content

By default, Lume will display all content which have Content Warning tag, it's may include NSFW content.

); } function Pending() { return (
); }