1
0
forked from Kieran/snort

get profiles from ndk

This commit is contained in:
Martti Malmi 2023-12-23 16:53:14 +02:00
parent 85169ebe0c
commit 5bfcd858da
22 changed files with 47 additions and 52 deletions

View File

@ -1,10 +1,10 @@
import "./CashuNuts.css"; import "./CashuNuts.css";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { FormattedMessage, FormattedNumber } from "react-intl"; import { FormattedMessage, FormattedNumber } from "react-intl";
import { useUserProfile } from "@snort/system-react";
import useLogin from "@/Hooks/useLogin"; import useLogin from "@/Hooks/useLogin";
import Icon from "@/Icons/Icon"; import Icon from "@/Icons/Icon";
import useProfile from "@/Hooks/useProfile";
interface Token { interface Token {
token: Array<{ token: Array<{
@ -18,7 +18,7 @@ interface Token {
export default function CashuNuts({ token }: { token: string }) { export default function CashuNuts({ token }: { token: string }) {
const { publicKey } = useLogin(s => ({ publicKey: s.publicKey })); const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
const profile = useUserProfile(publicKey); const profile = useProfile(publicKey);
async function copyToken(e: React.MouseEvent<HTMLButtonElement>, token: string) { async function copyToken(e: React.MouseEvent<HTMLButtonElement>, token: string) {
e.stopPropagation(); e.stopPropagation();

View File

@ -1,13 +1,13 @@
import { NostrLink, NostrPrefix } from "@snort/system"; import { NostrLink, NostrPrefix } from "@snort/system";
import { useUserProfile } from "@snort/system-react";
import DisplayName from "@/Element/User/DisplayName"; import DisplayName from "@/Element/User/DisplayName";
import { ProfileCard } from "@/Element/User/ProfileCard"; import { ProfileCard } from "@/Element/User/ProfileCard";
import { ProfileLink } from "@/Element/User/ProfileLink"; import { ProfileLink } from "@/Element/User/ProfileLink";
import { useCallback, useRef, useState } from "react"; import { useCallback, useRef, useState } from "react";
import useProfile from "@/Hooks/useProfile";
export default function Mention({ link }: { link: NostrLink }) { export default function Mention({ link }: { link: NostrLink }) {
const profile = useUserProfile(link.id); const profile = useProfile(link.id);
const [isHovering, setIsHovering] = useState(false); const [isHovering, setIsHovering] = useState(false);
const hoverTimeoutRef = useRef<NodeJS.Timeout | null>(null); const hoverTimeoutRef = useRef<NodeJS.Timeout | null>(null);

View File

@ -3,7 +3,7 @@ import { FormattedMessage, useIntl } from "react-intl";
import { useLongPress } from "use-long-press"; import { useLongPress } from "use-long-press";
import { TaggedNostrEvent, ParsedZap, countLeadingZeros, NostrLink } from "@snort/system"; import { TaggedNostrEvent, ParsedZap, countLeadingZeros, NostrLink } from "@snort/system";
import { normalizeReaction } from "@snort/shared"; import { normalizeReaction } from "@snort/shared";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import { Menu, MenuItem } from "@szhsin/react-menu"; import { Menu, MenuItem } from "@szhsin/react-menu";
import classNames from "classnames"; import classNames from "classnames";
@ -53,7 +53,7 @@ export default function NoteFooter(props: NoteFooterProps) {
preferences: prefs, preferences: prefs,
readonly, readonly,
} = useLogin(s => ({ preferences: s.appData.item.preferences, publicKey: s.publicKey, readonly: s.readonly })); } = useLogin(s => ({ preferences: s.appData.item.preferences, publicKey: s.publicKey, readonly: s.readonly }));
const author = useUserProfile(ev.pubkey); const author = useProfile(ev.pubkey);
const interactionCache = useInteractionCache(publicKey, ev.id); const interactionCache = useInteractionCache(publicKey, ev.id);
const { publisher, system } = useEventPublisher(); const { publisher, system } = useEventPublisher();
const note = useNoteCreator(n => ({ show: n.show, replyTo: n.replyTo, update: n.update, quote: n.quote })); const note = useNoteCreator(n => ({ show: n.show, replyTo: n.replyTo, update: n.update, quote: n.quote }));

View File

@ -8,7 +8,7 @@ import { eventLink, hexToBech32, getDisplayName } from "@/SnortUtils";
import useModeration from "@/Hooks/useModeration"; import useModeration from "@/Hooks/useModeration";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import Icon from "@/Icons/Icon"; import Icon from "@/Icons/Icon";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
export interface NoteReactionProps { export interface NoteReactionProps {
@ -20,7 +20,7 @@ export default function NoteReaction(props: NoteReactionProps) {
const { data: ev } = props; const { data: ev } = props;
const { isMuted } = useModeration(); const { isMuted } = useModeration();
const { inView, ref } = useInView({ triggerOnce: true, rootMargin: "2000px" }); const { inView, ref } = useInView({ triggerOnce: true, rootMargin: "2000px" });
const profile = useUserProfile(inView ? ev.pubkey : ""); const profile = useProfile(inView ? ev.pubkey : "");
const refEvent = useMemo(() => { const refEvent = useMemo(() => {
if (ev) { if (ev) {

View File

@ -2,7 +2,7 @@ import { TaggedNostrEvent, ParsedZap, NostrLink } from "@snort/system";
import { LNURL } from "@snort/shared"; import { LNURL } from "@snort/shared";
import { useState } from "react"; import { useState } from "react";
import { FormattedMessage, FormattedNumber, useIntl } from "react-intl"; import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import useEventPublisher from "@/Hooks/useEventPublisher"; import useEventPublisher from "@/Hooks/useEventPublisher";
import { useWallet } from "@/Wallet"; import { useWallet } from "@/Wallet";
@ -28,7 +28,7 @@ export default function Poll(props: PollProps) {
publicKey: myPubKey, publicKey: myPubKey,
relays, relays,
} = useLogin(s => ({ preferences: s.appData.item.preferences, publicKey: s.publicKey, relays: s.relays })); } = useLogin(s => ({ preferences: s.appData.item.preferences, publicKey: s.publicKey, relays: s.relays }));
const pollerProfile = useUserProfile(props.ev.pubkey); const pollerProfile = useProfile(props.ev.pubkey);
const [tallyBy, setTallyBy] = useState<PollTally>("pubkeys"); const [tallyBy, setTallyBy] = useState<PollTally>("pubkeys");
const [error, setError] = useState(""); const [error, setError] = useState("");
const [invoice, setInvoice] = useState(""); const [invoice, setInvoice] = useState("");

View File

@ -1,7 +1,7 @@
import "./ZapButton.css"; import "./ZapButton.css";
import { useState } from "react"; import { useState } from "react";
import { HexKey } from "@snort/system"; import { HexKey } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import SendSats from "@/Element/SendSats"; import SendSats from "@/Element/SendSats";
import Icon from "@/Icons/Icon"; import Icon from "@/Icons/Icon";
@ -18,7 +18,7 @@ const ZapButton = ({
children?: React.ReactNode; children?: React.ReactNode;
event?: string; event?: string;
}) => { }) => {
const profile = useUserProfile(pubkey); const profile = useProfile(pubkey);
const [zap, setZap] = useState(false); const [zap, setZap] = useState(false);
const service = lnurl ?? (profile?.lud16 || profile?.lud06); const service = lnurl ?? (profile?.lud16 || profile?.lud06);
if (!service) return null; if (!service) return null;

View File

@ -1,6 +1,6 @@
import SnortApi from "@/External/SnortApi"; import SnortApi from "@/External/SnortApi";
import { getCurrentRefCode, getDisplayName } from "@/SnortUtils"; import { getCurrentRefCode, getDisplayName } from "@/SnortUtils";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import Lottie from "lottie-react"; import Lottie from "lottie-react";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
@ -18,7 +18,7 @@ const InviteModal = () => {
api.getRefCodeInfo(code).then(a => setPubkey(a.pubkey)); api.getRefCodeInfo(code).then(a => setPubkey(a.pubkey));
} }
}, []); }, []);
const profile = useUserProfile(pubkey); const profile = useProfile(pubkey);
if (!code) return; if (!code) return;
function close() { function close() {

View File

@ -1,5 +1,5 @@
import { mapEventToProfile } from "@snort/system"; import { mapEventToProfile } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import AccountName from "./AccountName"; import AccountName from "./AccountName";
import useLogin from "@/Hooks/useLogin"; import useLogin from "@/Hooks/useLogin";
@ -12,7 +12,7 @@ export default function ActiveAccount({ name = "", setAsPrimary = () => {} }) {
publicKey: s.publicKey, publicKey: s.publicKey,
readonly: s.readonly, readonly: s.readonly,
})); }));
const profile = useUserProfile(publicKey); const profile = useProfile(publicKey);
const { publisher, system } = useEventPublisher(); const { publisher, system } = useEventPublisher();
async function saveProfile(nip05: string) { async function saveProfile(nip05: string) {

View File

@ -17,7 +17,7 @@ import {
import AsyncButton from "@/Element/Button/AsyncButton"; import AsyncButton from "@/Element/Button/AsyncButton";
import SendSats from "@/Element/SendSats"; import SendSats from "@/Element/SendSats";
import Copy from "@/Element/Copy"; import Copy from "@/Element/Copy";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import useEventPublisher from "@/Hooks/useEventPublisher"; import useEventPublisher from "@/Hooks/useEventPublisher";
import { debounce } from "@/SnortUtils"; import { debounce } from "@/SnortUtils";
import useLogin from "@/Hooks/useLogin"; import useLogin from "@/Hooks/useLogin";
@ -43,7 +43,7 @@ export default function Nip5Service(props: Nip05ServiceProps) {
const { helpText = true } = props; const { helpText = true } = props;
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const { publicKey } = useLogin(s => ({ publicKey: s.publicKey })); const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
const user = useUserProfile(publicKey); const user = useProfile(publicKey);
const { publisher, system } = useEventPublisher(); const { publisher, system } = useEventPublisher();
const svc = useMemo(() => new ServiceProvider(props.service), [props.service]); const svc = useMemo(() => new ServiceProvider(props.service), [props.service]);
const [serviceConfig, setServiceConfig] = useState<ServiceConfig>(); const [serviceConfig, setServiceConfig] = useState<ServiceConfig>();

View File

@ -4,7 +4,7 @@ import { HexKey } from "@snort/system";
import { getDisplayNameOrPlaceHolder } from "@/SnortUtils"; import { getDisplayNameOrPlaceHolder } from "@/SnortUtils";
import classNames from "classnames"; import classNames from "classnames";
import useProfile from "@/Hooks/useProfile"; import useProfile from "@/Hooks/useProfile";
import {NDKUserProfile} from "@nostr-dev-kit/ndk"; import { NDKUserProfile } from "@nostr-dev-kit/ndk";
interface DisplayNameProps { interface DisplayNameProps {
pubkey: HexKey; pubkey: HexKey;

View File

@ -1,9 +1,9 @@
import "./Nip05.css"; import "./Nip05.css";
import { HexKey } from "@snort/system"; import { HexKey } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/Hooks/useProfile";
export function useIsVerified(pubkey?: HexKey, bypassCheck?: boolean) { export function useIsVerified(pubkey?: HexKey, bypassCheck?: boolean) {
const profile = useUserProfile(pubkey); const profile = useProfile(pubkey);
return { isVerified: bypassCheck || profile?.isNostrAddressValid }; return { isVerified: bypassCheck || profile?.isNostrAddressValid };
} }

View File

@ -1,8 +1,9 @@
import { ReactNode, useContext } from "react"; import { ReactNode, useContext } from "react";
import { Link, LinkProps } from "react-router-dom"; import { Link, LinkProps } from "react-router-dom";
import { UserMetadata, NostrLink, NostrPrefix, MetadataCache } from "@snort/system"; import { NostrLink, NostrPrefix } from "@snort/system";
import { SnortContext } from "@snort/system-react"; import { SnortContext } from "@snort/system-react";
import { randomSample } from "@/SnortUtils"; import { randomSample } from "@/SnortUtils";
import { NDKUserProfile } from "@nostr-dev-kit/ndk";
export function ProfileLink({ export function ProfileLink({
pubkey, pubkey,
@ -12,7 +13,7 @@ export function ProfileLink({
...others ...others
}: { }: {
pubkey: string; pubkey: string;
user?: UserMetadata | MetadataCache; user?: NDKUserProfile;
explicitLink?: string; explicitLink?: string;
children?: ReactNode; children?: ReactNode;
} & Omit<LinkProps, "to">) { } & Omit<LinkProps, "to">) {

View File

@ -1,11 +1,12 @@
import "./ProfilePreview.css"; import "./ProfilePreview.css";
import { ReactNode } from "react"; import { ReactNode } from "react";
import { HexKey, UserMetadata } from "@snort/system"; import { HexKey } from "@snort/system";
import { useUserProfile } from "@snort/system-react";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
import ProfileImage from "@/Element/User/ProfileImage"; import ProfileImage from "@/Element/User/ProfileImage";
import FollowButton from "@/Element/User/FollowButton"; import FollowButton from "@/Element/User/FollowButton";
import useProfile from "@/Hooks/useProfile";
import { NDKUserProfile } from "@nostr-dev-kit/ndk";
export interface ProfilePreviewProps { export interface ProfilePreviewProps {
pubkey: HexKey; pubkey: HexKey;
@ -14,7 +15,7 @@ export interface ProfilePreviewProps {
linkToProfile?: boolean; linkToProfile?: boolean;
profileCards?: boolean; profileCards?: boolean;
}; };
profile?: UserMetadata; profile?: NDKUserProfile;
actions?: ReactNode; actions?: ReactNode;
className?: string; className?: string;
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void; onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
@ -22,7 +23,7 @@ export interface ProfilePreviewProps {
export default function ProfilePreview(props: ProfilePreviewProps) { export default function ProfilePreview(props: ProfilePreviewProps) {
const pubkey = props.pubkey; const pubkey = props.pubkey;
const { ref, inView } = useInView({ triggerOnce: true }); const { ref, inView } = useInView({ triggerOnce: true });
const user = useUserProfile(inView ? pubkey : undefined); const user = useProfile(inView ? pubkey : undefined);
const options = { const options = {
about: true, about: true,
...props.options, ...props.options,

View File

@ -1,11 +1,11 @@
import { HexKey } from "@snort/system"; import { HexKey } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import { ProfileLink } from "./ProfileLink"; import { ProfileLink } from "./ProfileLink";
import DisplayName from "./DisplayName"; import DisplayName from "./DisplayName";
export default function Username({ pubkey, onLinkVisit }: { pubkey: HexKey; onLinkVisit(): void }) { export default function Username({ pubkey, onLinkVisit }: { pubkey: HexKey; onLinkVisit(): void }) {
const user = useUserProfile(pubkey); const user = useProfile(pubkey);
return user ? ( return user ? (
<ProfileLink pubkey={pubkey} onClick={onLinkVisit} user={user}> <ProfileLink pubkey={pubkey} onClick={onLinkVisit} user={user}>

View File

@ -5,7 +5,7 @@ import Icon from "@/Icons/Icon";
import { ProfileLink } from "@/Element/User/ProfileLink"; import { ProfileLink } from "@/Element/User/ProfileLink";
import { NoteCreatorButton } from "@/Element/Event/Create/NoteCreatorButton"; import { NoteCreatorButton } from "@/Element/Event/Create/NoteCreatorButton";
import classNames from "classnames"; import classNames from "classnames";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import Avatar from "@/Element/User/Avatar"; import Avatar from "@/Element/User/Avatar";
import { useIntl } from "react-intl"; import { useIntl } from "react-intl";
@ -37,7 +37,7 @@ const Footer = () => {
publicKey: s.publicKey, publicKey: s.publicKey,
readonly: s.readonly, readonly: s.readonly,
})); }));
const profile = useUserProfile(publicKey); const profile = useProfile(publicKey);
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const readOnlyIcon = readonly && ( const readOnlyIcon = readonly && (

View File

@ -4,7 +4,7 @@ import Icon from "@/Icons/Icon";
import { ProfileLink } from "../../Element/User/ProfileLink"; import { ProfileLink } from "../../Element/User/ProfileLink";
import Avatar from "../../Element/User/Avatar"; import Avatar from "../../Element/User/Avatar";
import useLogin from "../../Hooks/useLogin"; import useLogin from "../../Hooks/useLogin";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import { NoteCreatorButton } from "../../Element/Event/Create/NoteCreatorButton"; import { NoteCreatorButton } from "../../Element/Event/Create/NoteCreatorButton";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import classNames from "classnames"; import classNames from "classnames";
@ -78,7 +78,7 @@ export default function NavSidebar({ narrow = false }) {
subscriptions: s.subscriptions, subscriptions: s.subscriptions,
readonly: s.readonly, readonly: s.readonly,
})); }));
const profile = useUserProfile(publicKey); const profile = useProfile(publicKey);
const navigate = useNavigate(); const navigate = useNavigate();
const { publisher } = useEventPublisher(); const { publisher } = useEventPublisher();
const sub = getCurrentSubscription(subscriptions); const sub = getCurrentSubscription(subscriptions);

View File

@ -2,7 +2,7 @@ import "./Notifications.css";
import { Suspense, lazy, useEffect, useMemo, useState, useSyncExternalStore } from "react"; import { Suspense, lazy, useEffect, useMemo, useState, useSyncExternalStore } from "react";
import { EventExt, EventKind, NostrEvent, NostrLink, NostrPrefix, TaggedNostrEvent, parseZap } from "@snort/system"; import { EventExt, EventKind, NostrEvent, NostrLink, NostrPrefix, TaggedNostrEvent, parseZap } from "@snort/system";
import { unwrap } from "@snort/shared"; import { unwrap } from "@snort/shared";
import { useEventFeed, useUserProfile } from "@snort/system-react"; import { useEventFeed } from "@snort/system-react";
import { useInView } from "react-intersection-observer"; import { useInView } from "react-intersection-observer";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
@ -20,6 +20,7 @@ import { LiveEvent } from "@/Element/LiveEvent";
import ProfilePreview from "@/Element/User/ProfilePreview"; import ProfilePreview from "@/Element/User/ProfilePreview";
import { ShowMoreInView } from "@/Element/Event/ShowMore"; import { ShowMoreInView } from "@/Element/Event/ShowMore";
import PageSpinner from "@/Element/PageSpinner"; import PageSpinner from "@/Element/PageSpinner";
import useProfile from "@/Hooks/useProfile";
const NotificationGraph = lazy(() => import("@/Pages/Notifications/NotificationChart")); const NotificationGraph = lazy(() => import("@/Pages/Notifications/NotificationChart"));
function notificationContext(ev: TaggedNostrEvent) { function notificationContext(ev: TaggedNostrEvent) {
@ -133,7 +134,7 @@ function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEvent>; onC
}), }),
); );
const firstPubkey = pubkeys[0]; const firstPubkey = pubkeys[0];
const firstPubkeyProfile = useUserProfile(inView ? (firstPubkey === "anon" ? "" : firstPubkey) : ""); const firstPubkeyProfile = useProfile(inView ? (firstPubkey === "anon" ? "" : firstPubkey) : "");
const context = notificationContext(evs[0]); const context = notificationContext(evs[0]);
const totalZaps = zaps.reduce((acc, v) => acc + v.amount, 0); const totalZaps = zaps.reduce((acc, v) => acc + v.amount, 0);

View File

@ -2,14 +2,7 @@ import "./ProfilePage.css";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import { Link, useLocation, useNavigate, useParams } from "react-router-dom"; import { Link, useLocation, useNavigate, useParams } from "react-router-dom";
import { import { encodeTLVEntries, EventKind, NostrLink, NostrPrefix, TLVEntryType, tryParseNostrLink } from "@snort/system";
encodeTLVEntries,
EventKind,
NostrLink,
NostrPrefix,
TLVEntryType,
tryParseNostrLink,
} from "@snort/system";
import { fetchNip05Pubkey, LNURL } from "@snort/shared"; import { fetchNip05Pubkey, LNURL } from "@snort/shared";
import { findTag, getLinkReactions, hexToBech32, parseId, unwrap } from "@/SnortUtils"; import { findTag, getLinkReactions, hexToBech32, parseId, unwrap } from "@/SnortUtils";
@ -55,7 +48,7 @@ import { UserWebsiteLink } from "@/Element/User/UserWebsiteLink";
import { useMuteList, usePinList } from "@/Hooks/useLists"; import { useMuteList, usePinList } from "@/Hooks/useLists";
import FollowedBy from "@/Element/User/FollowedBy"; import FollowedBy from "@/Element/User/FollowedBy";
import useProfile from "@/Hooks/useProfile"; import useProfile from "@/Hooks/useProfile";
import {NDKUserProfile} from "@nostr-dev-kit/ndk"; import { NDKUserProfile } from "@nostr-dev-kit/ndk";
interface ProfilePageProps { interface ProfilePageProps {
id?: string; id?: string;

View File

@ -2,7 +2,7 @@ import "./ZapPool.css";
import { useMemo, useSyncExternalStore } from "react"; import { useMemo, useSyncExternalStore } from "react";
import { FormattedMessage, FormattedNumber } from "react-intl"; import { FormattedMessage, FormattedNumber } from "react-intl";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import { SnortPubKey } from "@/Const"; import { SnortPubKey } from "@/Const";
import ProfilePreview from "@/Element/User/ProfilePreview"; import ProfilePreview from "@/Element/User/ProfilePreview";
@ -24,7 +24,7 @@ const DataProviders = [
export function ZapPoolTarget({ target }: { target: ZapPoolRecipient }) { export function ZapPoolTarget({ target }: { target: ZapPoolRecipient }) {
if (!ZapPoolController) return; if (!ZapPoolController) return;
const login = useLogin(); const login = useLogin();
const profile = useUserProfile(target.pubkey); const profile = useProfile(target.pubkey);
const hasAddress = profile?.lud16 || profile?.lud06; const hasAddress = profile?.lud16 || profile?.lud06;
const defaultZapMount = Math.ceil(login.appData.item.preferences.defaultZapAmount * (target.split / 100)); const defaultZapMount = Math.ceil(login.appData.item.preferences.defaultZapAmount * (target.split / 100));
return ( return (

View File

@ -2,7 +2,7 @@ import "./Profile.css";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { mapEventToProfile } from "@snort/system"; import { mapEventToProfile } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import useEventPublisher from "@/Hooks/useEventPublisher"; import useEventPublisher from "@/Hooks/useEventPublisher";
import { openFile, debounce } from "@/SnortUtils"; import { openFile, debounce } from "@/SnortUtils";
@ -27,7 +27,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
const navigate = useNavigate(); const navigate = useNavigate();
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const { publicKey: id, readonly } = useLogin(s => ({ publicKey: s.publicKey, readonly: s.readonly })); const { publicKey: id, readonly } = useLogin(s => ({ publicKey: s.publicKey, readonly: s.readonly }));
const user = useUserProfile(id ?? ""); const user = useProfile(id ?? "");
const { publisher, system } = useEventPublisher(); const { publisher, system } = useEventPublisher();
const uploader = useFileUpload(); const uploader = useFileUpload();
const [error, setError] = useState<Error>(); const [error, setError] = useState<Error>();

View File

@ -16,12 +16,11 @@ import {
NostrEvent, NostrEvent,
MetadataCache, MetadataCache,
NostrLink, NostrLink,
UserMetadata,
} from "@snort/system"; } from "@snort/system";
import { isHex, isOffline } from "@snort/shared"; import { isHex, isOffline } from "@snort/shared";
import { Birthday, Day } from "@/Const"; import { Birthday, Day } from "@/Const";
import AnimalName from "@/Element/User/AnimalName"; import AnimalName from "@/Element/User/AnimalName";
import {NDKUser, NDKUserProfile} from "@nostr-dev-kit/ndk"; import { NDKUserProfile } from "@nostr-dev-kit/ndk";
export const sha256 = (str: string | Uint8Array): u256 => { export const sha256 = (str: string | Uint8Array): u256 => {
return utils.bytesToHex(hash(str)); return utils.bytesToHex(hash(str));

View File

@ -1,6 +1,6 @@
import "./TaskList.css"; import "./TaskList.css";
import { Fragment, useSyncExternalStore } from "react"; import { Fragment, useSyncExternalStore } from "react";
import { useUserProfile } from "@snort/system-react"; import useProfile from "@/hooks/useProfile";
import useLogin from "@/Hooks/useLogin"; import useLogin from "@/Hooks/useLogin";
import Icon from "@/Icons/Icon"; import Icon from "@/Icons/Icon";
@ -38,7 +38,7 @@ class TaskStore extends ExternalStore<Array<UITask>> {
const AllTasks = new TaskStore(); const AllTasks = new TaskStore();
export const TaskList = () => { export const TaskList = () => {
const session = useLogin(); const session = useLogin();
const user = useUserProfile(session.publicKey); const user = useProfile(session.publicKey);
const tasks = useSyncExternalStore( const tasks = useSyncExternalStore(
c => AllTasks.hook(c), c => AllTasks.hook(c),
() => AllTasks.snapshot(), () => AllTasks.snapshot(),