fix: blogs loading for reported nprofile

This commit is contained in:
enes 2024-12-26 17:21:19 +01:00
parent 1c4a9c8586
commit 5449591b6e

View File

@ -46,7 +46,6 @@ export const ProfilePage = () => {
profilePubkey, profilePubkey,
profile, profile,
isBlocked: _isBlocked, isBlocked: _isBlocked,
isOwnProfile,
repostList, repostList,
muteLists, muteLists,
nsfwList nsfwList
@ -60,6 +59,10 @@ export const ProfilePage = () => {
const displayName = const displayName =
profile?.displayName || profile?.name || '[name not set up]' profile?.displayName || profile?.name || '[name not set up]'
const [showReportPopUp, setShowReportPopUp] = useState(false) const [showReportPopUp, setShowReportPopUp] = useState(false)
const isOwnProfile =
userState.auth &&
userState.user?.pubkey &&
userState.user.pubkey === profilePubkey
const [isBlocked, setIsBlocked] = useState(_isBlocked) const [isBlocked, setIsBlocked] = useState(_isBlocked)
const handleBlock = async () => { const handleBlock = async () => {
@ -661,7 +664,7 @@ const ReportUserPopup = ({
} }
const ProfileTabBlogs = () => { const ProfileTabBlogs = () => {
const { profile, muteLists, nsfwList } = const { profilePubkey, muteLists, nsfwList } =
useLoaderData() as ProfilePageLoaderResult useLoaderData() as ProfilePageLoaderResult
const navigation = useNavigation() const navigation = useNavigation()
const { fetchEvents } = useNDKContext() const { fetchEvents } = useNDKContext()
@ -669,7 +672,7 @@ const ProfileTabBlogs = () => {
const [isLoading, setIsLoading] = useState(true) const [isLoading, setIsLoading] = useState(true)
const blogfilter: NDKFilter = useMemo(() => { const blogfilter: NDKFilter = useMemo(() => {
const filter: NDKFilter = { const filter: NDKFilter = {
authors: [profile?.pubkey as string], authors: [profilePubkey],
kinds: [kinds.LongFormArticle] kinds: [kinds.LongFormArticle]
} }
@ -683,13 +686,13 @@ const ProfileTabBlogs = () => {
} }
return filter return filter
}, [filterOptions.nsfw, filterOptions.source, profile?.pubkey]) }, [filterOptions.nsfw, filterOptions.source, profilePubkey])
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [hasMore, setHasMore] = useState(false) const [hasMore, setHasMore] = useState(false)
const [blogs, setBlogs] = useState<Partial<BlogCardDetails>[]>([]) const [blogs, setBlogs] = useState<Partial<BlogCardDetails>[]>([])
useEffect(() => { useEffect(() => {
if (profile) { if (profilePubkey) {
// Initial blog fetch, go beyond limit to check for next // Initial blog fetch, go beyond limit to check for next
const filter: NDKFilter = { const filter: NDKFilter = {
...blogfilter, ...blogfilter,
@ -704,7 +707,7 @@ const ProfileTabBlogs = () => {
setIsLoading(false) setIsLoading(false)
}) })
} }
}, [blogfilter, fetchEvents, profile]) }, [blogfilter, fetchEvents, profilePubkey])
const handleNext = useCallback(() => { const handleNext = useCallback(() => {
if (isLoading) return if (isLoading) return
@ -758,7 +761,7 @@ const ProfileTabBlogs = () => {
let _blogs = blogs || [] let _blogs = blogs || []
const isAdmin = userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB const isAdmin = userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB
const isOwner = const isOwner =
userState.user?.pubkey && userState.user.pubkey === profile?.pubkey userState.user?.pubkey && userState.user.pubkey === profilePubkey
const isUnmoderatedFully = const isUnmoderatedFully =
filterOptions.moderated === ModeratedFilter.Unmoderated_Fully filterOptions.moderated === ModeratedFilter.Unmoderated_Fully
@ -815,7 +818,7 @@ const ProfileTabBlogs = () => {
muteLists.user.authors, muteLists.user.authors,
muteLists.user.replaceableEvents, muteLists.user.replaceableEvents,
nsfwList, nsfwList,
profile?.pubkey, profilePubkey,
userState.user?.npub, userState.user?.npub,
userState.user?.pubkey userState.user?.pubkey
]) ])
@ -826,10 +829,7 @@ const ProfileTabBlogs = () => {
<LoadingSpinner desc={'Loading...'} /> <LoadingSpinner desc={'Loading...'} />
)} )}
<BlogsFilter <BlogsFilter filterKey={'filter-blog'} author={profilePubkey} />
filterKey={'filter-blog'}
author={profile?.pubkey as string}
/>
<div className='IBMSMList IBMSMListAlt'> <div className='IBMSMList IBMSMListAlt'>
{moderatedAndSortedBlogs.map((b) => ( {moderatedAndSortedBlogs.map((b) => (