wip: fix ui for macos

This commit is contained in:
2023-10-13 09:12:30 +07:00
parent 893663561d
commit 0777c483e5
5 changed files with 15 additions and 10 deletions

View File

@@ -2,14 +2,18 @@ import { NDKEvent } from '@nostr-dev-kit/ndk';
import { nip04 } from 'nostr-tools';
import { useEffect, useState } from 'react';
export function useDecryptMessage(message: NDKEvent, pubkey: string, privkey: string) {
import { useStorage } from '@libs/storage/provider';
export function useDecryptMessage(message: NDKEvent) {
const { db } = useStorage();
const [content, setContent] = useState(message.content);
useEffect(() => {
async function decryptContent() {
try {
const privkey = await db.secureLoad();
const sender =
pubkey === message.pubkey
db.account.pubkey === message.pubkey
? message.tags.find((el) => el[0] === 'p')[1]
: message.pubkey;
const result = await nip04.decrypt(privkey, sender, message.content);