update unlock page

This commit is contained in:
Ren Amamiya
2023-07-09 17:38:54 +07:00
parent a099f4fc85
commit 5787eff7d5
6 changed files with 353 additions and 267 deletions

View File

@@ -2,6 +2,8 @@ import { NDKEvent, NDKKind, NDKPrivateKeySigner } from '@nostr-dev-kit/ndk';
import { useNDK } from '@libs/ndk/provider';
import { useStronghold } from '@stores/stronghold';
import { useAccount } from '@utils/hooks/useAccount';
import { useSecureStorage } from '@utils/hooks/useSecureStorage';
@@ -10,6 +12,8 @@ export function usePublish() {
const { account } = useAccount();
const { load } = useSecureStorage();
const privkey = useStronghold((state) => state.privkey);
const publish = async ({
content,
kind,
@@ -19,10 +23,10 @@ export function usePublish() {
kind: NDKKind;
tags: string[][];
}): Promise<NDKEvent> => {
const privkey = await load(account.pubkey);
const securePrivkey = await load(account.pubkey);
const event = new NDKEvent(ndk);
const signer = new NDKPrivateKeySigner(privkey);
const signer = new NDKPrivateKeySigner(privkey ? privkey : securePrivkey);
event.content = content;
event.kind = kind;