refactor: TS
This commit is contained in:
18
src/feed/ProfileFeed.ts
Normal file
18
src/feed/ProfileFeed.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { HexKey } from "../nostr";
|
||||
import { RootState } from "../state/Store";
|
||||
import { addPubKey, MetadataCache } from "../state/Users";
|
||||
|
||||
export default function useProfile(pubKey: HexKey) {
|
||||
const dispatch = useDispatch();
|
||||
const user = useSelector<RootState, MetadataCache>(s => s.users.users[pubKey]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pubKey) {
|
||||
dispatch(addPubKey(pubKey));
|
||||
}
|
||||
}, [pubKey]);
|
||||
|
||||
return user;
|
||||
}
|
Reference in New Issue
Block a user