This commit is contained in:
2023-10-12 09:13:06 +07:00
parent 3b46e71525
commit 35650a40f2
36 changed files with 444 additions and 1447 deletions

View File

@@ -5,19 +5,14 @@ import { useStorage } from '@libs/storage/provider';
import { LogoutIcon } from '@shared/icons';
import { useStronghold } from '@stores/stronghold';
export function Logout() {
const { db } = useStorage();
const navigate = useNavigate();
const resetStronghold = useStronghold((state) => state.reset);
const logout = async () => {
// remove account
db.accountLogout();
// clear privkey in session storage
resetStronghold();
// redirect to welcome screen
navigate('/auth/welcome');
};

View File

@@ -8,8 +8,6 @@ import CurrencyInput from 'react-currency-input-field';
import { CancelIcon, ZapIcon } from '@shared/icons';
import { useStronghold } from '@stores/stronghold';
import { useEvent } from '@utils/hooks/useEvent';
import { useNostr } from '@utils/hooks/useNostr';
import { useProfile } from '@utils/hooks/useProfile';
@@ -21,6 +19,7 @@ export function NoteZap({ id, pubkey }: { id: string; pubkey: string }) {
const { user } = useProfile(pubkey);
const { data: event } = useEvent(id);
const [walletConnectURL, setWalletConnectURL] = useState<string>(null);
const [amount, setAmount] = useState<string>('21');
const [zapMessage, setZapMessage] = useState<string>('');
const [invoice, setInvoice] = useState<null | string>(null);
@@ -28,7 +27,6 @@ export function NoteZap({ id, pubkey }: { id: string; pubkey: string }) {
const [isCompleted, setIsCompleted] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const walletConnectURL = useStronghold((state) => state.walletConnectURL);
const nwc = useRef(null);
const createZapRequest = async () => {
@@ -80,6 +78,12 @@ export function NoteZap({ id, pubkey }: { id: string; pubkey: string }) {
};
useEffect(() => {
async function getWalletConnectURL() {
// const uri: string = await invoke('secure_load', { key: 'nwc' });
setWalletConnectURL('todo');
}
getWalletConnectURL();
return () => {
setAmount('21');
setZapMessage('');

View File

@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import { useStorage } from '@libs/storage/provider';
import { useStronghold } from '@stores/stronghold';
import { useWidgets } from '@stores/widgets';
import { useNostr } from '@utils/hooks/useNostr';
@@ -11,11 +11,11 @@ export function EventLoader({ firstTime }: { firstTime: boolean }) {
const { db } = useStorage();
const { getAllEventsSinceLastLogin } = useNostr();
const setIsFetched = useStronghold((state) => state.setIsFetched);
const queryClient = useQueryClient();
const [progress, setProgress] = useState(0);
const queryClient = useQueryClient();
const setIsFetched = useWidgets((state) => state.setIsFetched);
useEffect(() => {
async function getEvents() {
const events = await getAllEventsSinceLastLogin();

View File

@@ -18,7 +18,7 @@ import { NoteSkeleton } from '@shared/notes/skeleton';
import { TitleBar } from '@shared/titleBar';
import { EventLoader, WidgetWrapper } from '@shared/widgets';
import { useStronghold } from '@stores/stronghold';
import { useWidgets } from '@stores/widgets';
import { useNostr } from '@utils/hooks/useNostr';
import { toRawEvent } from '@utils/rawEvent';
@@ -36,7 +36,7 @@ export function LocalNetworkWidget() {
getNextPageParam: (lastPage) => lastPage.nextCursor,
});
const isFetched = useStronghold((state) => state.isFetched);
const isFetched = useWidgets((state) => state.isFetched);
const dbEvents = useMemo(
() => (data ? data.pages.flatMap((d: { data: DBEvent[] }) => d.data) : []),
[data]