feat: use native feature instead of react

This commit is contained in:
reya
2024-06-21 10:24:09 +07:00
parent 59eaaec903
commit 1283432632
25 changed files with 280 additions and 439 deletions

View File

@@ -5,9 +5,9 @@ import * as Checkbox from "@radix-ui/react-checkbox";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { invoke } from "@tauri-apps/api/core";
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
import { message } from "@tauri-apps/plugin-dialog";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
export const Route = createFileRoute("/auth/$account/backup")({
component: Screen,
@@ -29,7 +29,10 @@ function Screen() {
try {
if (key) {
if (!confirm.c1 || !confirm.c2 || !confirm.c3) {
return toast.warning("You need to confirm before continue");
return await message("You need to confirm before continue", {
title: "Backup",
kind: "info",
});
}
navigate({ to: "/", replace: true });
@@ -48,7 +51,10 @@ function Screen() {
});
} catch (e) {
setLoading(false);
toast.error(String(e));
await message(String(e), {
title: "Backup",
kind: "error",
});
}
};
@@ -57,7 +63,10 @@ function Screen() {
await writeText(key);
setCopied(true);
} catch (e) {
toast.error(e);
await message(String(e), {
title: "Backup",
kind: "error",
});
}
};

View File

@@ -4,10 +4,10 @@ import { NostrAccount } from "@lume/system";
import type { Metadata } from "@lume/types";
import { Spinner } from "@lume/ui";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { message } from "@tauri-apps/plugin-dialog";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
export const Route = createFileRoute("/auth/create-profile")({
component: Screen,
@@ -53,7 +53,7 @@ function Screen() {
}
} catch (e) {
setLoading(false);
toast.error(String(e));
await message(String(e), { title: "Create Profile", kind: "error" });
}
};

View File

@@ -1,8 +1,8 @@
import { NostrAccount } from "@lume/system";
import { Spinner } from "@lume/ui";
import { createLazyFileRoute } from "@tanstack/react-router";
import { message } from "@tauri-apps/plugin-dialog";
import { useState } from "react";
import { toast } from "sonner";
export const Route = createLazyFileRoute("/auth/import")({
component: Screen,
@@ -16,10 +16,12 @@ function Screen() {
const [loading, setLoading] = useState(false);
const submit = async () => {
if (!key.startsWith("nsec1"))
return toast.warning(
if (!key.startsWith("nsec1")) {
return await message(
"You need to enter a valid private key starts with nsec or ncryptsec",
{ title: "Import Key", kind: "info" },
);
}
try {
setLoading(true);
@@ -31,7 +33,7 @@ function Screen() {
}
} catch (e) {
setLoading(false);
toast.error(e);
await message(String(e), { title: "Import Key", kind: "error" });
}
};

View File

@@ -1,8 +1,8 @@
import { NostrAccount } from "@lume/system";
import { Spinner } from "@lume/ui";
import { createLazyFileRoute } from "@tanstack/react-router";
import { message } from "@tauri-apps/plugin-dialog";
import { useState } from "react";
import { toast } from "sonner";
export const Route = createLazyFileRoute("/auth/remote")({
component: Screen,
@@ -15,10 +15,12 @@ function Screen() {
const [loading, setLoading] = useState(false);
const submit = async () => {
if (!uri.startsWith("bunker://"))
return toast.warning(
if (!uri.startsWith("bunker://")) {
return await message(
"You need to enter a valid Connect URI starts with bunker://",
{ title: "Nostr Connect", kind: "info" },
);
}
try {
setLoading(true);
@@ -30,7 +32,7 @@ function Screen() {
}
} catch (e) {
setLoading(false);
toast.error(e);
await message(String(e), { title: "Nostr Connect", kind: "error" });
}
};