completed migrate to prisma-rust-client
This commit is contained in:
@@ -6,17 +6,17 @@ import { DEFAULT_AVATAR } from '@stores/constants';
|
||||
import { truncate } from '@utils/truncate';
|
||||
|
||||
import { Author } from 'nostr-relaypool';
|
||||
import { memo, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { memo, useContext, useEffect, useState } from 'react';
|
||||
|
||||
export const UserBase = memo(function UserBase({ pubkey }: { pubkey: string }) {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const [profile, setProfile] = useState(null);
|
||||
const user = useMemo(() => new Author(pool, relays, pubkey), [pubkey, pool, relays]);
|
||||
|
||||
useEffect(() => {
|
||||
const user = new Author(pool, relays, pubkey);
|
||||
user.metaData((res) => setProfile(JSON.parse(res.content)), 0);
|
||||
}, [user]);
|
||||
}, [pool, relays, pubkey]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -10,16 +10,15 @@ import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { useRouter } from 'next/router';
|
||||
import { Author } from 'nostr-relaypool';
|
||||
import { memo, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { memo, useContext, useEffect, useState } from 'react';
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
export const UserExtend = memo(function UserExtend({ pubkey, time }: { pubkey: string; time: any }) {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
const router = useRouter();
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const [profile, setProfile] = useState(null);
|
||||
const user = useMemo(() => new Author(pool, relays, pubkey), [pubkey, pool, relays]);
|
||||
|
||||
const openUserPage = (e) => {
|
||||
e.stopPropagation();
|
||||
@@ -27,8 +26,9 @@ export const UserExtend = memo(function UserExtend({ pubkey, time }: { pubkey: s
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const user = new Author(pool, relays, pubkey);
|
||||
user.metaData((res) => setProfile(JSON.parse(res.content)), 0);
|
||||
}, [user]);
|
||||
}, [pool, relays, pubkey]);
|
||||
|
||||
return (
|
||||
<div className="group flex items-start gap-2">
|
||||
|
||||
@@ -1,33 +1,22 @@
|
||||
import { ImageWithFallback } from '@components/imageWithFallback';
|
||||
import { RelayContext } from '@components/relaysProvider';
|
||||
|
||||
import { DEFAULT_AVATAR } from '@stores/constants';
|
||||
|
||||
import { createCacheProfile } from '@utils/storage';
|
||||
import { truncate } from '@utils/truncate';
|
||||
|
||||
import { fetch } from '@tauri-apps/api/http';
|
||||
import destr from 'destr';
|
||||
import { memo, useCallback, useEffect, useState } from 'react';
|
||||
import { Author } from 'nostr-relaypool';
|
||||
import { memo, useContext, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
export const UserFollow = memo(function UserFollow({ pubkey }: { pubkey: string }) {
|
||||
const [profile, setProfile] = useState(null);
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const fetchProfile = useCallback(async (id: string) => {
|
||||
const res = await fetch(`https://rbr.bio/${id}/metadata.json`, {
|
||||
method: 'GET',
|
||||
timeout: 30,
|
||||
});
|
||||
return res.data;
|
||||
}, []);
|
||||
const [profile, setProfile] = useState(null);
|
||||
const user = useMemo(() => new Author(pool, relays, pubkey), [pubkey, pool, relays]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchProfile(pubkey)
|
||||
.then((res: any) => {
|
||||
setProfile(destr(res.content));
|
||||
createCacheProfile(res.pubkey, res.content);
|
||||
})
|
||||
.catch(console.error);
|
||||
}, [fetchProfile, pubkey]);
|
||||
user.metaData((res) => setProfile(JSON.parse(res.content)), 0);
|
||||
}, [user]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -9,19 +9,18 @@ import { DotsHorizontalIcon } from '@radix-ui/react-icons';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { Author } from 'nostr-relaypool';
|
||||
import { memo, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { memo, useContext, useEffect, useState } from 'react';
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
export const UserLarge = memo(function UserLarge({ pubkey, time }: { pubkey: string; time: any }) {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const [profile, setProfile] = useState(null);
|
||||
const user = useMemo(() => new Author(pool, relays, pubkey), [pubkey, pool, relays]);
|
||||
|
||||
useEffect(() => {
|
||||
const user = new Author(pool, relays, pubkey);
|
||||
user.metaData((res) => setProfile(JSON.parse(res.content)), 0);
|
||||
}, [user]);
|
||||
}, [pool, relays, pubkey]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -3,17 +3,16 @@ import { RelayContext } from '@components/relaysProvider';
|
||||
import { truncate } from '@utils/truncate';
|
||||
|
||||
import { Author } from 'nostr-relaypool';
|
||||
import { memo, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { memo, useContext, useEffect, useState } from 'react';
|
||||
|
||||
export const UserMention = memo(function UserMention({ pubkey }: { pubkey: string }) {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const [profile, setProfile] = useState(null);
|
||||
const user = useMemo(() => new Author(pool, relays, pubkey), [pubkey, pool, relays]);
|
||||
|
||||
useEffect(() => {
|
||||
const user = new Author(pool, relays, pubkey);
|
||||
user.metaData((res) => setProfile(JSON.parse(res.content)), 0);
|
||||
}, [user]);
|
||||
}, [pool, relays, pubkey]);
|
||||
|
||||
return <span className="cursor-pointer text-fuchsia-500">@{profile?.name || truncate(pubkey, 16, ' .... ')}</span>;
|
||||
});
|
||||
|
||||
@@ -6,17 +6,16 @@ import { DEFAULT_AVATAR } from '@stores/constants';
|
||||
import { truncate } from '@utils/truncate';
|
||||
|
||||
import { Author } from 'nostr-relaypool';
|
||||
import { useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useContext, useEffect, useState } from 'react';
|
||||
|
||||
export const UserMini = ({ pubkey }: { pubkey: string }) => {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const [profile, setProfile] = useState(null);
|
||||
const user = useMemo(() => new Author(pool, relays, pubkey), [pubkey, pool, relays]);
|
||||
|
||||
useEffect(() => {
|
||||
const user = new Author(pool, relays, pubkey);
|
||||
user.metaData((res) => setProfile(JSON.parse(res.content)), 0);
|
||||
}, [user]);
|
||||
}, [pool, relays, pubkey]);
|
||||
|
||||
if (profile) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user