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