rework macos version
This commit is contained in:
@@ -61,7 +61,7 @@ export function ImportStep2Screen() {
|
||||
setLoading(true);
|
||||
if (data.password.length > 3) {
|
||||
const dir = await appConfigDir();
|
||||
const stronghold = await Stronghold.load(`${dir}lume.stronghold`, data.password);
|
||||
const stronghold = await Stronghold.load(`${dir}/lume.stronghold`, data.password);
|
||||
|
||||
if (!db.secureDB) db.secureDB = stronghold;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { appConfigDir } from '@tauri-apps/api/path';
|
||||
import { Stronghold } from '@tauri-apps/plugin-stronghold';
|
||||
import { useState } from 'react';
|
||||
import { Resolver, useForm } from 'react-hook-form';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
@@ -33,7 +33,6 @@ export function UnlockScreen() {
|
||||
const navigate = useNavigate();
|
||||
const setPrivkey = useStronghold((state) => state.setPrivkey);
|
||||
const setWalletConnectURL = useStronghold((state) => state.setWalletConnectURL);
|
||||
const resetStronghold = useStronghold((state) => state.reset);
|
||||
|
||||
const [showPassword, setShowPassword] = useState<boolean>(false);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
@@ -43,7 +42,7 @@ export function UnlockScreen() {
|
||||
register,
|
||||
setError,
|
||||
handleSubmit,
|
||||
formState: { errors, isDirty, isValid },
|
||||
formState: { isDirty, isValid },
|
||||
} = useForm<FormValues>({ resolver });
|
||||
|
||||
const onSubmit = async (data: { [x: string]: string }) => {
|
||||
@@ -71,15 +70,6 @@ export function UnlockScreen() {
|
||||
}
|
||||
};
|
||||
|
||||
const logout = async () => {
|
||||
// remove account
|
||||
db.accountLogout();
|
||||
// reset stronghold
|
||||
resetStronghold();
|
||||
// redirect to welcome screen
|
||||
navigate('/auth/welcome');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
<div className="mx-auto w-full max-w-md">
|
||||
|
||||
@@ -110,7 +110,7 @@ export function RelayScreen() {
|
||||
href={`https://nips.be/${item}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex aspect-square h-full w-full items-center justify-center rounded-lg bg-white/10 text-sm font-medium hover:bg-blue-600"
|
||||
className="inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg bg-white/10 text-sm font-medium hover:bg-blue-600"
|
||||
>
|
||||
{item}
|
||||
</a>
|
||||
|
||||
@@ -14,37 +14,39 @@ export class LumeStorage {
|
||||
public account: Account | null;
|
||||
public platform: Platform | null;
|
||||
|
||||
constructor(sqlite: Database, platform?: Platform, stronghold?: Stronghold) {
|
||||
constructor(sqlite: Database, platform: Platform, stronghold?: Stronghold) {
|
||||
this.db = sqlite;
|
||||
this.secureDB = stronghold ?? undefined;
|
||||
this.account = null;
|
||||
this.platform = platform ?? undefined;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
private async getSecureClient(key?: string) {
|
||||
private async getSecureClient() {
|
||||
try {
|
||||
return await this.secureDB.loadClient(key ?? 'lume');
|
||||
return await this.secureDB.loadClient('lume');
|
||||
} catch {
|
||||
return await this.secureDB.createClient(key ?? 'lume');
|
||||
return await this.secureDB.createClient('lume');
|
||||
}
|
||||
}
|
||||
|
||||
public async secureSave(key: string, value: string, clientKey?: string) {
|
||||
public async secureSave(key: string, value: string) {
|
||||
if (!this.secureDB) throw new Error("Stronghold isn't initialize");
|
||||
|
||||
const client = await this.getSecureClient(clientKey);
|
||||
const store = client.getStore();
|
||||
const client = await this.getSecureClient();
|
||||
if (!client) throw new Error('Cannot get stronghold client');
|
||||
|
||||
const store = client.getStore();
|
||||
await store.insert(key, Array.from(new TextEncoder().encode(value)));
|
||||
await this.secureDB.save();
|
||||
}
|
||||
|
||||
public async secureLoad(key: string, clientKey?: string) {
|
||||
public async secureLoad(key: string) {
|
||||
if (!this.secureDB) throw new Error("Stronghold isn't initialize");
|
||||
|
||||
const client = await this.getSecureClient(clientKey);
|
||||
const store = client.getStore();
|
||||
const client = await this.getSecureClient();
|
||||
if (!client) throw new Error('Cannot get stronghold client');
|
||||
|
||||
const store = client.getStore();
|
||||
const value = await store.get(key);
|
||||
if (!value) return null;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export function ActiveAccount() {
|
||||
|
||||
if (status === 'loading') {
|
||||
return (
|
||||
<div className="aspect-square h-full w-full animate-pulse rounded-lg bg-white/10" />
|
||||
<div className="aspect-square h-auto w-full animate-pulse rounded-lg bg-white/10" />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export function ActiveAccount() {
|
||||
<Image
|
||||
src={user?.picture || user?.image}
|
||||
alt={db.account.npub}
|
||||
className="aspect-square h-full w-full rounded-md"
|
||||
className="aspect-square h-auto w-full rounded-md"
|
||||
/>
|
||||
<span className="absolute bottom-0 right-0 block h-2 w-2 rounded-full bg-emerald-500 ring-2 ring-neutral-100 dark:ring-neutral-900" />
|
||||
</Link>
|
||||
|
||||
@@ -28,7 +28,7 @@ export function ComposerModal() {
|
||||
<Dialog.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="flex aspect-square h-full w-full items-center justify-center rounded-lg bg-neutral-300 hover:bg-blue-600 dark:bg-neutral-700 dark:hover:bg-blue-600"
|
||||
className="flex aspect-square h-auto w-full items-center justify-center rounded-lg bg-neutral-300 hover:bg-blue-600 dark:bg-neutral-700 dark:hover:bg-blue-600"
|
||||
>
|
||||
<ComposeIcon className="h-5 w-5 text-black dark:text-white" />
|
||||
</button>
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { Outlet, ScrollRestoration } from 'react-router-dom';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import { WindowTitlebar } from 'tauri-controls';
|
||||
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
import { Navigation } from '@shared/navigation';
|
||||
|
||||
export function AppLayout() {
|
||||
const { db } = useStorage();
|
||||
|
||||
return (
|
||||
<div className="flex h-screen w-screen flex-col bg-neutral-50 dark:bg-neutral-950">
|
||||
<WindowTitlebar />
|
||||
{db.platform !== 'macos' ? <WindowTitlebar /> : <div className="h-11" />}
|
||||
<div className="flex h-full min-h-0 w-full">
|
||||
<div data-tauri-drag-region className="h-full w-[64px] shrink-0 pt-2">
|
||||
<div
|
||||
data-tauri-drag-region
|
||||
className={twMerge(
|
||||
'h-full w-[64px] shrink-0',
|
||||
db.platform !== 'macos' ? 'pt-2' : 'pt-16'
|
||||
)}
|
||||
>
|
||||
<Navigation />
|
||||
</div>
|
||||
<div className="flex h-full min-h-0 flex-1 rounded-tl-lg bg-white shadow-[rgba(50,_50,_105,_0.15)_0px_2px_5px_0px,_rgba(0,_0,_0,_0.05)_0px_1px_1px_0px] dark:bg-black dark:shadow-[inset_0_0_0.5px_1px_hsla(0,0%,100%,0.075),0_0_0_1px_hsla(0,0%,0%,0.05),0_0.3px_0.4px_hsla(0,0%,0%,0.02),0_0.9px_1.5px_hsla(0,0%,0%,0.045),0_3.5px_6px_hsla(0,0%,0%,0.09)]">
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import { WindowTitlebar } from 'tauri-controls';
|
||||
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
export function AuthLayout() {
|
||||
const { db } = useStorage();
|
||||
|
||||
return (
|
||||
<div className="relative h-screen w-screen bg-neutral-50 dark:bg-neutral-950">
|
||||
<WindowTitlebar />
|
||||
{db.platform !== 'macos' ? <WindowTitlebar /> : null}
|
||||
<div className="bg-neutral-50 dark:bg-neutral-950">
|
||||
<Outlet />
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ export function Navigation() {
|
||||
<>
|
||||
<div
|
||||
className={twMerge(
|
||||
'inline-flex aspect-square h-full w-full items-center justify-center rounded-lg',
|
||||
'inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
isActive
|
||||
? 'bg-black/10 text-black dark:bg-white/10 dark:text-white'
|
||||
: 'text-black/50 dark:text-white/50'
|
||||
@@ -46,7 +46,7 @@ export function Navigation() {
|
||||
<>
|
||||
<div
|
||||
className={twMerge(
|
||||
'inline-flex aspect-square h-full w-full items-center justify-center rounded-lg',
|
||||
'inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
isActive
|
||||
? 'bg-black/10 text-black dark:bg-white/10 dark:text-white'
|
||||
: 'text-black/50 dark:text-white/50'
|
||||
@@ -67,7 +67,7 @@ export function Navigation() {
|
||||
<>
|
||||
<div
|
||||
className={twMerge(
|
||||
'inline-flex aspect-square h-full w-full items-center justify-center rounded-lg',
|
||||
'inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
isActive
|
||||
? 'bg-black/10 text-black dark:bg-white/10 dark:text-white'
|
||||
: 'text-black/50 dark:text-white/50'
|
||||
@@ -88,7 +88,7 @@ export function Navigation() {
|
||||
<>
|
||||
<div
|
||||
className={twMerge(
|
||||
'inline-flex aspect-square h-full w-full items-center justify-center rounded-lg',
|
||||
'inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
isActive
|
||||
? 'bg-black/10 text-black dark:bg-white/10 dark:text-white'
|
||||
: 'text-black/50 dark:text-white/50'
|
||||
@@ -109,7 +109,7 @@ export function Navigation() {
|
||||
<>
|
||||
<div
|
||||
className={twMerge(
|
||||
'inline-flex aspect-square h-full w-full items-center justify-center rounded-lg',
|
||||
'inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
isActive
|
||||
? 'bg-black/10 text-black dark:bg-white/10 dark:text-white'
|
||||
: 'text-black/50 dark:text-white/50'
|
||||
@@ -126,7 +126,7 @@ export function Navigation() {
|
||||
<ComposerModal />
|
||||
<Link
|
||||
to="/nwc"
|
||||
className="flex aspect-square h-full w-full items-center justify-center rounded-lg bg-neutral-100 hover:bg-blue-600 dark:bg-neutral-900 dark:hover:bg-blue-600"
|
||||
className="flex aspect-square h-auto w-full items-center justify-center rounded-lg bg-neutral-100 hover:bg-blue-600 dark:bg-neutral-900 dark:hover:bg-blue-600"
|
||||
>
|
||||
<NwcIcon className="h-5 w-5" />
|
||||
</Link>
|
||||
|
||||
10
src/utils/types.d.ts
vendored
10
src/utils/types.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { NDKEvent, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
||||
import { Response } from '@tauri-apps/plugin-http';
|
||||
import { type NDKEvent, type NDKUserProfile } from '@nostr-dev-kit/ndk';
|
||||
import { type Response } from '@tauri-apps/plugin-http';
|
||||
|
||||
export interface RichContent {
|
||||
parsed: string;
|
||||
@@ -68,12 +68,6 @@ export interface Chats {
|
||||
new_messages?: number;
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
id: string;
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Relays {
|
||||
id?: string;
|
||||
account_id?: number;
|
||||
|
||||
Reference in New Issue
Block a user