diff --git a/src/libs/storage.tsx b/src/libs/storage.tsx index 54b3f619..747f2d8a 100644 --- a/src/libs/storage.tsx +++ b/src/libs/storage.tsx @@ -482,7 +482,7 @@ export async function getUserMetadata(pubkey: string) { const db = await connect(); const result = await db.select(`SELECT * FROM metadata WHERE pubkey = "${pubkey}";`); if (result[0]) { - return JSON.parse(result[0].content) as Profile; + return { ...result[0], ...JSON.parse(result[0].content) } as Profile; } else { return null; } diff --git a/src/shared/icons/download.tsx b/src/shared/icons/download.tsx new file mode 100644 index 00000000..e8d39fee --- /dev/null +++ b/src/shared/icons/download.tsx @@ -0,0 +1,22 @@ +import { SVGProps } from 'react'; + +export function DownloadIcon(props: JSX.IntrinsicAttributes & SVGProps) { + return ( + + + + ); +} diff --git a/src/shared/icons/index.tsx b/src/shared/icons/index.tsx index 8a2deb45..7bbdecb4 100644 --- a/src/shared/icons/index.tsx +++ b/src/shared/icons/index.tsx @@ -46,4 +46,5 @@ export * from './unfollow'; export * from './reaction'; export * from './thread'; export * from './strangers'; +export * from './download'; // @endindex diff --git a/src/shared/notes/preview/image.tsx b/src/shared/notes/preview/image.tsx index c7aca728..b3fb99f9 100644 --- a/src/shared/notes/preview/image.tsx +++ b/src/shared/notes/preview/image.tsx @@ -1,11 +1,21 @@ +import { downloadDir } from '@tauri-apps/api/path'; +import { download } from 'tauri-plugin-upload-api'; + +import { DownloadIcon } from '@shared/icons'; import { Image } from '@shared/image'; export function ImagePreview({ urls, truncate }: { urls: string[]; truncate?: boolean }) { + const downloadImage = async (url: string) => { + const downloadDirPath = await downloadDir(); + const filename = url.substring(url.lastIndexOf('/') + 1); + return await download(url, downloadDirPath + `/${filename}`); + }; + return (
{urls.map((url) => ( -
+
+
))}
diff --git a/src/shared/notification/user.tsx b/src/shared/notification/user.tsx index 41864519..9c58b61c 100644 --- a/src/shared/notification/user.tsx +++ b/src/shared/notification/user.tsx @@ -21,16 +21,16 @@ export function NotiUser({ pubkey }: { pubkey: string }) { return (
-
+
{pubkey}
- - {user.nip05 || user.name || user.displayName || displayNpub(pubkey, 16)} + + {user?.nip05 || user?.name || user?.displayName || displayNpub(pubkey, 16)}
); diff --git a/src/shared/user.tsx b/src/shared/user.tsx index 718612a3..658f4d5d 100644 --- a/src/shared/user.tsx +++ b/src/shared/user.tsx @@ -115,12 +115,12 @@ export function User({
)} - + {user?.nip05 || shortenKey(pubkey)}
-

+

{user?.about}