2023-01-16 00:07:27 +00:00
|
|
|
import { useLiveQuery } from "dexie-react-hooks";
|
2023-01-15 19:40:47 +00:00
|
|
|
import { useEffect } from "react";
|
2023-01-16 00:07:27 +00:00
|
|
|
import { db } from "../db";
|
2023-01-15 19:40:47 +00:00
|
|
|
import { HexKey } from "../nostr";
|
2023-01-16 00:07:27 +00:00
|
|
|
import { System } from "../nostr/System";
|
2023-01-15 19:40:47 +00:00
|
|
|
|
|
|
|
export default function useProfile(pubKey: HexKey) {
|
2023-01-16 00:07:27 +00:00
|
|
|
const user = useLiveQuery(async () => {
|
|
|
|
return await db.users.get(pubKey);
|
|
|
|
}, [pubKey]);
|
2023-01-15 19:40:47 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
2023-01-16 00:07:27 +00:00
|
|
|
System.GetMetadata(pubKey);
|
2023-01-15 19:40:47 +00:00
|
|
|
}, [pubKey]);
|
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|