Skip to content

Commit

Permalink
Merge pull request #120 from luminous-devs/fix/logout
Browse files Browse the repository at this point in the history
Fix logout function and other issues
  • Loading branch information
reyamir authored Nov 23, 2023
2 parents 8ee38cd + 731c725 commit 2fdf437
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 47 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lume",
"description": "the communication app",
"private": true,
"version": "2.1.2",
"version": "2.1.3",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down Expand Up @@ -63,7 +63,7 @@
"html-to-text": "^9.0.5",
"idb-keyval": "^6.2.1",
"light-bolt11-decoder": "^3.0.0",
"lru-cache": "^10.0.3",
"lru-cache": "^10.1.0",
"markdown-to-jsx": "^7.3.2",
"media-chrome": "^1.5.3",
"minidenticons": "^4.2.0",
Expand All @@ -77,15 +77,15 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.48.2",
"react-hotkeys-hook": "^4.4.1",
"react-router-dom": "^6.19.0",
"react-router-dom": "^6.20.0",
"react-string-replace": "^1.1.1",
"reactflow": "^11.10.1",
"sonner": "^1.2.2",
"tailwind-scrollbar": "^3.0.5",
"tauri-controls": "github:reyamir/tauri-controls",
"tippy.js": "^6.3.7",
"tiptap-markdown": "^0.8.4",
"virtua": "^0.16.5",
"virtua": "^0.16.6",
"zustand": "^4.4.6"
},
"devDependencies": {
Expand Down
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lume"
version = "2.1.2"
version = "2.1.3"
description = "the communication app"
authors = ["Ren Amamiya"]
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"package": {
"productName": "Lume",
"version": "2.1.2"
"version": "2.1.3"
},
"plugins": {
"fs": {
Expand Down
2 changes: 0 additions & 2 deletions src/app/auth/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export function CreateAccountScreen() {

const onSubmit = async (data: { name: string; about: string }) => {
try {
if (!ndk.signer) return navigate('/new/privkey');

setLoading(true);

const profile = {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/storage/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class LumeStorage {

public async checkAccount() {
const result: Array<{ total: string }> = await this.db.select(
'SELECT COUNT(*) AS "total" FROM accounts;'
'SELECT COUNT(*) AS "total" FROM accounts WHERE is_active = "1" ORDER BY id DESC LIMIT 1;'
);
return parseInt(result[0].total);
}
Expand Down
39 changes: 24 additions & 15 deletions src/shared/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as AlertDialog from '@radix-ui/react-alert-dialog';
import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';

import { useNDK } from '@libs/ndk/provider';
import { useStorage } from '@libs/storage/provider';
Expand All @@ -11,15 +12,21 @@ export function Logout() {
const navigate = useNavigate();

const logout = async () => {
ndk.signer = null;
try {
ndk.signer = null;

// remove account
await db.accountLogout();
await db.secureRemove(db.account.pubkey);
await db.secureRemove(db.account.pubkey + '-bunker');
// remove private key
await db.secureRemove(db.account.pubkey);
await db.secureRemove(db.account.pubkey + '-bunker');

// redirect to welcome screen
navigate('/auth/welcome');
// logout
await db.accountLogout();

// redirect to welcome screen
navigate('/auth/welcome');
} catch (e) {
toast.error(e);
}
};

return (
Expand All @@ -33,7 +40,7 @@ export function Logout() {
</button>
</AlertDialog.Trigger>
<AlertDialog.Portal>
<AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/50 backdrop-blur-2xl dark:bg-white/50" />
<AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/20 backdrop-blur-sm dark:bg-black/20" />
<AlertDialog.Content className="fixed inset-0 z-50 flex min-h-full items-center justify-center">
<div className="relative h-min w-full max-w-md rounded-xl bg-neutral-100 dark:bg-neutral-900">
<div className="flex flex-col gap-1 border-b border-white/5 px-5 py-4">
Expand All @@ -54,13 +61,15 @@ export function Logout() {
Cancel
</button>
</AlertDialog.Cancel>
<button
type="button"
onClick={() => logout()}
className="inline-flex h-9 items-center justify-center rounded-lg bg-red-500 px-4 text-sm font-medium text-white outline-none hover:bg-red-600"
>
Logout
</button>
<AlertDialog.Action asChild>
<button
type="button"
onClick={() => logout()}
className="inline-flex h-9 items-center justify-center rounded-lg bg-red-500 px-4 text-sm font-medium text-white outline-none hover:bg-red-600"
>
Logout
</button>
</AlertDialog.Action>
</div>
</div>
</AlertDialog.Content>
Expand Down

0 comments on commit 2fdf437

Please sign in to comment.