@snort/system-react package
This commit is contained in:
@ -2,7 +2,8 @@ import { useEffect, useState } from "react";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import { System } from "index";
|
||||
|
||||
interface Token {
|
||||
token: Array<{
|
||||
@ -16,7 +17,7 @@ interface Token {
|
||||
|
||||
export default function CashuNuts({ token }: { token: string }) {
|
||||
const login = useLogin();
|
||||
const profile = useUserProfile(login.publicKey);
|
||||
const profile = useUserProfile(System, login.publicKey);
|
||||
|
||||
async function copyToken(e: React.MouseEvent<HTMLButtonElement>, token: string) {
|
||||
e.stopPropagation();
|
||||
|
@ -2,12 +2,13 @@ import { useMemo } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { HexKey } from "@snort/system";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import { profileLink } from "SnortUtils";
|
||||
import { getDisplayName } from "Element/ProfileImage";
|
||||
import { System } from "index";
|
||||
|
||||
export default function Mention({ pubkey, relays }: { pubkey: HexKey; relays?: Array<string> | string }) {
|
||||
const user = useUserProfile(pubkey);
|
||||
const user = useUserProfile(System, pubkey);
|
||||
|
||||
const name = useMemo(() => {
|
||||
return getDisplayName(user, pubkey);
|
||||
|
@ -2,10 +2,11 @@ import "./Nip05.css";
|
||||
import { HexKey } from "@snort/system";
|
||||
|
||||
import Icon from "Icons/Icon";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import { System } from "index";
|
||||
|
||||
export function useIsVerified(pubkey: HexKey, bypassCheck?: boolean) {
|
||||
const profile = useUserProfile(pubkey);
|
||||
const profile = useUserProfile(System, pubkey);
|
||||
return { isVerified: bypassCheck || profile?.isNostrAddressValid };
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import SendSats from "Element/SendSats";
|
||||
import Copy from "Element/Copy";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { debounce } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
@ -44,7 +44,7 @@ export default function Nip5Service(props: Nip05ServiceProps) {
|
||||
const { helpText = true } = props;
|
||||
const { formatMessage } = useIntl();
|
||||
const pubkey = useLogin().publicKey;
|
||||
const user = useUserProfile(pubkey);
|
||||
const user = useUserProfile(System, pubkey);
|
||||
const publisher = useEventPublisher();
|
||||
const svc = useMemo(() => new ServiceProvider(props.service), [props.service]);
|
||||
const [serviceConfig, setServiceConfig] = useState<ServiceConfig>();
|
||||
|
@ -5,6 +5,7 @@ import { Menu, MenuItem } from "@szhsin/react-menu";
|
||||
import { useLongPress } from "use-long-press";
|
||||
import { TaggedRawEvent, HexKey, u256, encodeTLV, NostrPrefix, Lists } from "@snort/system";
|
||||
import { LNURL } from "@snort/shared";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
|
||||
import Icon from "Icons/Icon";
|
||||
import Spinner from "Icons/Spinner";
|
||||
@ -17,7 +18,6 @@ import { ReBroadcaster } from "Element/ReBroadcaster";
|
||||
import Reactions from "Element/Reactions";
|
||||
import SendSats from "Element/SendSats";
|
||||
import { ParsedZap, ZapsSummary } from "Element/Zap";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { RootState } from "State/Store";
|
||||
import { setReplyTo, setShow, reset } from "State/NoteCreator";
|
||||
import {
|
||||
@ -73,7 +73,7 @@ export default function NoteFooter(props: NoteFooterProps) {
|
||||
const login = useLogin();
|
||||
const { pinned, bookmarked, publicKey, preferences: prefs, relays } = login;
|
||||
const { mute, block } = useModeration();
|
||||
const author = useUserProfile(ev.pubkey);
|
||||
const author = useUserProfile(System, ev.pubkey);
|
||||
const interactionCache = useInteractionCache(publicKey, ev.id);
|
||||
const publisher = useEventPublisher();
|
||||
const showNoteCreatorModal = useSelector((s: RootState) => s.noteCreator.show);
|
||||
|
@ -2,17 +2,18 @@ import { TaggedRawEvent } from "@snort/system";
|
||||
import { LNURL } from "@snort/shared";
|
||||
import { useState } from "react";
|
||||
import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
|
||||
import { ParsedZap } from "Element/Zap";
|
||||
import Text from "Element/Text";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { useWallet } from "Wallet";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { formatShort } from "Number";
|
||||
import Spinner from "Icons/Spinner";
|
||||
import SendSats from "Element/SendSats";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { System } from "index";
|
||||
|
||||
interface PollProps {
|
||||
ev: TaggedRawEvent;
|
||||
@ -24,7 +25,7 @@ export default function Poll(props: PollProps) {
|
||||
const publisher = useEventPublisher();
|
||||
const { wallet } = useWallet();
|
||||
const { preferences: prefs, publicKey: myPubKey, relays } = useLogin();
|
||||
const pollerProfile = useUserProfile(props.ev.pubkey);
|
||||
const pollerProfile = useUserProfile(System, props.ev.pubkey);
|
||||
const [error, setError] = useState("");
|
||||
const [invoice, setInvoice] = useState("");
|
||||
const [voting, setVoting] = useState<number>();
|
||||
|
@ -1,13 +1,14 @@
|
||||
import "./ProfileImage.css";
|
||||
|
||||
import React, { useMemo } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { HexKey, NostrPrefix, MetadataCache } from "@snort/system";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { hexToBech32, profileLink } from "SnortUtils";
|
||||
import Avatar from "Element/Avatar";
|
||||
import Nip05 from "Element/Nip05";
|
||||
import { Link } from "react-router-dom";
|
||||
import { System } from "index";
|
||||
|
||||
export interface ProfileImageProps {
|
||||
pubkey: HexKey;
|
||||
@ -30,7 +31,7 @@ export default function ProfileImage({
|
||||
verifyNip,
|
||||
overrideUsername,
|
||||
}: ProfileImageProps) {
|
||||
const user = useUserProfile(pubkey);
|
||||
const user = useUserProfile(System, pubkey);
|
||||
const nip05 = defaultNip ? defaultNip : user?.nip05;
|
||||
|
||||
const name = useMemo(() => {
|
||||
|
@ -1,11 +1,12 @@
|
||||
import "./ProfilePreview.css";
|
||||
import { ReactNode } from "react";
|
||||
import { HexKey } from "@snort/system";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
import { useInView } from "react-intersection-observer";
|
||||
|
||||
import ProfileImage from "Element/ProfileImage";
|
||||
import FollowButton from "Element/FollowButton";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { HexKey } from "@snort/system";
|
||||
import { useInView } from "react-intersection-observer";
|
||||
import { System } from "index";
|
||||
|
||||
export interface ProfilePreviewProps {
|
||||
pubkey: HexKey;
|
||||
@ -18,7 +19,7 @@ export interface ProfilePreviewProps {
|
||||
export default function ProfilePreview(props: ProfilePreviewProps) {
|
||||
const pubkey = props.pubkey;
|
||||
const { ref, inView } = useInView({ triggerOnce: true });
|
||||
const user = useUserProfile(inView ? pubkey : undefined);
|
||||
const user = useUserProfile(System, inView ? pubkey : undefined);
|
||||
const options = {
|
||||
about: true,
|
||||
...props.options,
|
||||
|
@ -1,11 +1,11 @@
|
||||
import "./SubDebug.css";
|
||||
import { useState } from "react";
|
||||
import { ReqFilter } from "@snort/system";
|
||||
import { useSystemState } from "@snort/system-react";
|
||||
|
||||
import useRelayState from "Feed/RelayState";
|
||||
import Tabs, { Tab } from "Element/Tabs";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import useSystemState from "Hooks/useSystemState";
|
||||
import { ReqFilter } from "@snort/system";
|
||||
import { useCopy } from "useCopy";
|
||||
import { System } from "index";
|
||||
|
||||
@ -15,7 +15,7 @@ function RelayInfo({ id }: { id: string }) {
|
||||
}
|
||||
|
||||
function Queries() {
|
||||
const qs = useSystemState();
|
||||
const qs = useSystemState(System);
|
||||
const { copy } = useCopy();
|
||||
|
||||
function countElements(filters: Array<ReqFilter>) {
|
||||
|
@ -2,12 +2,13 @@ import { MouseEvent } from "react";
|
||||
import { useNavigate, Link } from "react-router-dom";
|
||||
|
||||
import { HexKey } from "@snort/system";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { profileLink } from "SnortUtils";
|
||||
import { System } from "index";
|
||||
|
||||
export default function Username({ pubkey, onLinkVisit }: { pubkey: HexKey; onLinkVisit(): void }) {
|
||||
const user = useUserProfile(pubkey);
|
||||
const user = useUserProfile(System, pubkey);
|
||||
const navigate = useNavigate();
|
||||
|
||||
function onClick(ev: MouseEvent) {
|
||||
|
@ -1,13 +1,14 @@
|
||||
import "./ZapButton.css";
|
||||
import { useState } from "react";
|
||||
import { HexKey } from "@snort/system";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import SendSats from "Element/SendSats";
|
||||
import Icon from "Icons/Icon";
|
||||
import { System } from "index";
|
||||
|
||||
const ZapButton = ({ pubkey, lnurl, children }: { pubkey: HexKey; lnurl?: string; children?: React.ReactNode }) => {
|
||||
const profile = useUserProfile(pubkey);
|
||||
const profile = useUserProfile(System, pubkey);
|
||||
const [zap, setZap] = useState(false);
|
||||
const service = lnurl ?? (profile?.lud16 || profile?.lud06);
|
||||
if (!service) return null;
|
||||
|
Reference in New Issue
Block a user