Skip to content

Commit

Permalink
Revert "feat: show post thread with OG post" (heyxyz#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
sasicodes authored Nov 3, 2022
1 parent 8c7e8cf commit 244688f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 41 deletions.
11 changes: 3 additions & 8 deletions src/components/Home/Timeline/EventType/Commented.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ interface Props {
const Commented: FC<Props> = ({ feedItem }) => {
const publication = feedItem.root as Comment;
const firstComment = feedItem.comments && feedItem.comments[0];
const commentOn: LensterPublication | any = publication?.commentOn;
const mainPost = commentOn?.mainPost;

return firstComment && !commentOn ? (
return firstComment ? (
<ThreadBody publication={publication as LensterPublication} />
) : commentOn ? (
<>
{mainPost ? <ThreadBody publication={mainPost} /> : null}
<ThreadBody publication={commentOn as LensterPublication} />
</>
) : publication?.commentOn ? (
<ThreadBody publication={publication?.commentOn as LensterPublication} />
) : null;
};

Expand Down
44 changes: 11 additions & 33 deletions src/components/Publication/SinglePublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,17 @@ const SinglePublication: FC<Props> = ({
const { push } = useRouter();
const isMirror = publication.__typename === 'Mirror';
const firstComment = feedItem?.comments && feedItem.comments[0];

const getRootPublication = () => {
if (!feedItem) {
return publication;
} else if (firstComment && feedItem.root.__typename !== 'Comment') {
return firstComment;
} else {
return feedItem?.root;
}
};
const rootPublication = getRootPublication();

const getProfile = () => {
if (feedItem) {
return rootPublication.profile;
} else if (isMirror) {
return publication?.mirrorOf?.profile;
} else {
return publication?.profile;
}
};
const profile = getProfile();

const getTimestamp = () => {
if (feedItem) {
return rootPublication.createdAt;
} else if (isMirror) {
return publication?.mirrorOf?.createdAt;
} else {
return publication?.createdAt;
}
};
const timestamp = getTimestamp();
const rootPublication = feedItem ? (firstComment ? firstComment : feedItem?.root) : publication;
const profile = feedItem
? rootPublication.profile
: isMirror
? publication?.mirrorOf?.profile
: publication?.profile;
const timestamp = feedItem
? rootPublication.createdAt
: isMirror
? publication?.mirrorOf?.createdAt
: publication?.createdAt;

return (
<article className="hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer first:rounded-t-xl last:rounded-b-xl p-5">
Expand Down

0 comments on commit 244688f

Please sign in to comment.