diff --git a/apps/u3/src/components/profile/v1/ProfileSocial.tsx b/apps/u3/src/components/profile/v1/ProfileSocial.tsx deleted file mode 100644 index 2bb5effc..00000000 --- a/apps/u3/src/components/profile/v1/ProfileSocial.tsx +++ /dev/null @@ -1,202 +0,0 @@ -import { useCallback, useEffect } from 'react'; -import styled from 'styled-components'; -import { useSession } from '@lens-protocol/react-web'; -import InfiniteScroll from 'react-infinite-scroll-component'; -import { useLoadProfileFeeds } from '../../../hooks/social/useLoadProfileFeeds'; -import Loading from '../../common/loading/Loading'; -import LensPostCardV1 from '../../social/lens/v1/LensPostCard'; -import LensPostCard from '../../social/lens/LensPostCard'; -import FCast from '../../social/farcaster/FCast'; -import { useFarcasterCtx } from '../../../contexts/social/FarcasterCtx'; -import { ProfileFeedsGroups } from '../../../services/social/api/feeds'; -import Rss3Content from '../../fren/Rss3Content'; -import { NoActivity } from '../../../container/Activity'; -import { useLensCtx } from '../../../contexts/social/AppLensCtx'; - -export function ProfileSocialPosts({ - lensProfileId, - fid, - group, -}: { - lensProfileId: string; - fid: string; - group: ProfileFeedsGroups; -}) { - const { openFarcasterQR, farcasterUserData } = useFarcasterCtx(); - const { loading: activeLensProfileLoading } = useSession(); - const { sessionProfile: lensSessionProfile } = useLensCtx(); - - const { id: lensSessionProfileId } = lensSessionProfile || {}; - - const { - firstLoading, - moreLoading, - feeds, - pageInfo, - loadFirstFeeds, - loadMoreFeeds, - } = useLoadProfileFeeds(); - - const loadFirstSocialFeeds = useCallback(() => { - loadFirstFeeds({ - activeLensProfileId: lensSessionProfileId, - lensProfileId, - fid, - group, - }); - }, [loadFirstFeeds, lensSessionProfileId, fid, group, lensProfileId]); - - const loadMoreSocialFeeds = useCallback(() => { - loadMoreFeeds({ - activeLensProfileId: lensSessionProfileId, - lensProfileId, - fid, - group, - }); - }, [loadMoreFeeds, lensSessionProfileId, fid, group, lensProfileId]); - - useEffect(() => { - if (activeLensProfileLoading) return; - loadFirstSocialFeeds(); - }, [activeLensProfileLoading, loadFirstSocialFeeds]); - - return ( - - {(() => { - if (firstLoading) { - return ( - - - - ); - } - - return ( - { - if (moreLoading) return; - loadMoreSocialFeeds(); - }} - hasMore={!firstLoading && pageInfo.hasNextPage} - loader={ - moreLoading ? ( - - - - ) : null - } - scrollableTarget="profile-wrapper" - > - - {feeds.map(({ platform, data, ...args }) => { - if (platform === 'lens') { - let d; - if ((args as any)?.version === 'v2') { - switch (group) { - case ProfileFeedsGroups.POSTS: - d = data as any; - break; - case ProfileFeedsGroups.REPOSTS: - d = (data as any).mirrorOn; - break; - case ProfileFeedsGroups.REPLIES: - d = (data as any).commentOn; - break; - default: - break; - } - if (!d) return null; - return ; - } - switch (group) { - case ProfileFeedsGroups.POSTS: - d = data as any; - break; - case ProfileFeedsGroups.REPOSTS: - d = (data as any).mirrorOf; - break; - case ProfileFeedsGroups.REPLIES: - d = (data as any).commentOn; - break; - default: - break; - } - if (!d) return null; - return ; - } - if (platform === 'farcaster') { - const key = Buffer.from(data.hash.data).toString('hex'); - return ( - - ); - } - return null; - })} - - - ); - })()} - - ); -} -export function ProfileSocialActivity({ address }: { address: string }) { - return ( - - - - - } - /> - - ); -} - -const MainCenter = styled.div` - width: 100%; -`; -const LoadingWrapper = styled.div` - width: 100%; - height: 80vh; - display: flex; - justify-content: center; - align-items: center; -`; -const LoadingMoreWrapper = styled.div` - width: 100%; - display: flex; - justify-content: center; - align-items: center; - margin-top: 20px; -`; -const PostList = styled.div` - display: flex; - flex-direction: column; - gap: 1px; - - border-radius: 20px; - /* border-top-right-radius: 0; - border-top-left-radius: 0; */ - background: #212228; - overflow: hidden; - & > *:not(:first-child) { - border-top: 1px solid #718096; - } -`; -const NoActivityWrapper = styled.div` - .no-item { - height: 100%; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } -`; diff --git a/apps/u3/src/components/social/lens/v1/LensPostCard.tsx b/apps/u3/src/components/social/lens/v1/LensPostCard.tsx deleted file mode 100644 index 4ab25d3a..00000000 --- a/apps/u3/src/components/social/lens/v1/LensPostCard.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { useMemo } from 'react'; -import { useNavigate } from 'react-router-dom'; - -import { lensPublicationToPostCardData } from '../../../../utils/social/lens/v1/lens-ui-utils'; -import LensPostCardContent from './LensPostCardContent'; -import PostCard, { PostCardData } from '../../PostCard'; -import { getSocialDetailShareUrlWithLens } from '../../../../utils/shared/share'; - -export default function LensPostCardV1({ - data, - cardClickAction, -}: { - data: any; - cardClickAction?: (e: React.MouseEvent) => void; -}) { - const navigate = useNavigate(); - - const publication = data; - - const cardData = useMemo( - () => lensPublicationToPostCardData(publication), - [publication] - ); - - const replyDisabled = true; - const repostDisabled = true; - return ( - } - id={data.id} - onClick={(e) => { - cardClickAction?.(e); - navigate(`/social/post-detail/lens/${data.id}`); - }} - data={cardData} - likeDisabled - replyDisabled={replyDisabled} - repostDisabled={repostDisabled} - shareLink={getSocialDetailShareUrlWithLens(data.id)} - shareLinkEmbedTitle={ - data?.metadata?.description || data?.metadata?.content - } - /> - ); -} diff --git a/apps/u3/src/components/social/lens/v1/LensPostCardContent.tsx b/apps/u3/src/components/social/lens/v1/LensPostCardContent.tsx deleted file mode 100644 index f4e9fa31..00000000 --- a/apps/u3/src/components/social/lens/v1/LensPostCardContent.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { useEffect, useMemo, useRef, useState } from 'react'; -import { Player } from '@livepeer/react'; -import { - PostCardAudioWrapper, - PostCardContentWrapper, - PostCardImgWrapper, - PostCardShowMoreWrapper, - PostCardVideoWrapper, -} from '../../PostCard'; -import Markup from '../Markup'; -import ModalImg from '../../ModalImg'; -import Audio from '../../Audio'; -import sanitizeDStorageUrl from '../../../../utils/social/lens/sanitizeDStorageUrl'; - -type Props = { - publication: any; - isDetail?: boolean; -}; -export default function LensPostCardContent({ publication, isDetail }: Props) { - const { metadata } = publication || {}; - const markdownContent = useMemo(() => metadata?.content || '', [metadata]); - - const viewRef = useRef(null); - const [showMore, setShowMore] = useState(false); - useEffect(() => { - if (isDetail) return; - if (!viewRef.current) return; - const observer = new IntersectionObserver(([entry]) => { - if (entry.isIntersecting) { - if (entry.target.clientHeight > 125) { - setShowMore(true); - } - - observer.disconnect(); - } - }); - - observer.observe(viewRef.current); - // eslint-disable-next-line consistent-return - return () => { - observer.disconnect(); - }; - }, [isDetail]); - - const embedImgs = - metadata?.media?.filter((m) => m?.original?.mimeType?.includes('image')) || - []; - const embedAudios = - metadata?.media?.filter((m) => m?.original?.mimeType?.includes('audio')) || - []; - const embedVideos = - metadata?.media?.filter((m) => m?.original?.mimeType?.includes('video')) || - []; - - return ( - <> - - {markdownContent} - - {showMore && ( - - - - )} - {embedImgs.length > 0 && } - - {embedAudios.length > 0 && ( - - )} - - {embedVideos.length > 0 && } - - ); -} - -function EmbedImgs({ embedImgs }: { embedImgs: any[] }) { - const [modalImgIdx, setModalImgIdx] = useState(-1); - return ( - <> - - {embedImgs.map((img, idx) => ( - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions - { - e.stopPropagation(); - setModalImgIdx(idx); - }} - /> - ))} - - item.original.url)} - onAfterClose={() => setModalImgIdx(-1)} - /> - - ); -} - -function EmbedAudio({ media, publication }: { media: any; publication: any }) { - const { metadata } = publication || {}; - const name = metadata?.name || ''; - const author = - metadata?.attributes.find((attr) => attr.traitType === 'author')?.value || - ''; - const coverImg = sanitizeDStorageUrl( - metadata?.cover?.original?.url || - metadata?.image || - media.original?.cover || - '' - ); - return ( - e.stopPropagation()}> - - ); -} - -function EmbedVideo({ media }: { media: any }) { - return ( - e.stopPropagation()}> - - - ); -} diff --git a/apps/u3/src/container/profile/Profile.tsx b/apps/u3/src/container/profile/Profile.tsx index ffba41dd..6567e382 100644 --- a/apps/u3/src/container/profile/Profile.tsx +++ b/apps/u3/src/container/profile/Profile.tsx @@ -34,7 +34,7 @@ import { isDidPkh } from '../../utils/shared/did'; import { ProfileSocialActivity, ProfileSocialPosts, -} from '../../components/profile/v1/ProfileSocial'; +} from '../../components/profile/ProfileSocial'; import Loading from '../../components/common/loading/Loading'; import useDid from '../../hooks/profile/useDid'; import FollowingDefault from '../../components/social/FollowingDefault'; diff --git a/apps/u3/src/container/social/SocialLens.tsx b/apps/u3/src/container/social/SocialLens.tsx index 624f8de9..5903bde1 100644 --- a/apps/u3/src/container/social/SocialLens.tsx +++ b/apps/u3/src/container/social/SocialLens.tsx @@ -7,7 +7,6 @@ import Loading from 'src/components/common/loading/Loading'; import AddPostForm from 'src/components/social/AddPostForm'; import FollowingDefault from 'src/components/social/FollowingDefault'; import { FeedsType } from 'src/components/social/SocialPageNav'; -import LensPostCardV1 from 'src/components/social/lens/v1/LensPostCard'; import LensPostCard from 'src/components/social/lens/LensPostCard'; import useLogin from 'src/hooks/shared/useLogin'; import useListFeeds from 'src/hooks/social/useListFeeds'; @@ -167,23 +166,8 @@ export default function SocialFarcaster() { {feeds.map(({ platform, data, ...args }) => { if (platform === 'lens') { - if ((args as any)?.version === 'v2') { - return ( - { - setPostScroll({ - currentParent: parentId, - id: data.id, - top: (e.target as HTMLDivElement).offsetTop, - }); - }} - /> - ); - } return ( - { diff --git a/apps/u3/src/utils/social/lens/v1/getAvatar.ts b/apps/u3/src/utils/social/lens/v1/getAvatar.ts deleted file mode 100644 index 3731546a..00000000 --- a/apps/u3/src/utils/social/lens/v1/getAvatar.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { AVATAR, ZERO_ADDRESS } from '../constants'; - -import getStampFyiURL from '../getStampFyiURL'; -import imageKit from '../imageKit'; -import sanitizeDStorageUrl from '../sanitizeDStorageUrl'; - -/** - * Returns the avatar image URL for a given profile. - * - * @param profile The profile object. - * @param namedTransform The named transform to use. - * @returns The avatar image URL. - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const getAvatar = (profile: any, namedTransform = AVATAR): string => { - const avatarUrl = - profile?.avatar ?? - profile?.picture?.original?.url ?? - profile?.picture?.uri ?? - getStampFyiURL(profile?.ownedBy ?? ZERO_ADDRESS); - - return imageKit(sanitizeDStorageUrl(avatarUrl), namedTransform); -}; - -export default getAvatar; diff --git a/apps/u3/src/utils/social/lens/v1/lens-ui-utils.ts b/apps/u3/src/utils/social/lens/v1/lens-ui-utils.ts deleted file mode 100644 index 13dac2f9..00000000 --- a/apps/u3/src/utils/social/lens/v1/lens-ui-utils.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { SocialPlatform } from '../../../../services/social/types'; -import getAvatar from '../getAvatar'; - -export const lensPublicationToPostCardData = (publication: any) => { - return { - platform: SocialPlatform.Lens, - avatar: getAvatar(publication?.profile), - name: publication?.profile?.name || '', - handle: publication?.profile?.handle || '', - createdAt: publication?.createdAt || '', - content: publication?.metadata?.content || '', - totalLikes: publication?.stats?.totalUpvotes || 0, - totalReplies: publication?.stats?.totalAmountOfComments || 0, - totalReposts: publication?.stats?.totalAmountOfMirrors || 0, - likeAvatars: [], - }; -}; - -export const lensPublicationToReplyCardData = (publication: any) => { - return { - platform: SocialPlatform.Lens, - avatar: getAvatar(publication?.profile), - name: publication?.profile?.name || '', - handle: publication?.profile?.handle || '', - createdAt: publication?.createdAt || '', - content: publication?.metadata?.content || '', - totalLikes: publication?.stats?.totalUpvotes || 0, - totalReplies: publication?.stats?.totalAmountOfComments || 0, - totalReposts: publication?.stats?.totalAmountOfMirrors || 0, - likeAvatars: [], - }; -};