diff --git a/app/(home-pages)/reader/ReaderMentionsContent.tsx b/app/(home-pages)/reader/ReaderMentionsContent.tsx index 0b1dd2f8..517e6be0 100644 --- a/app/(home-pages)/reader/ReaderMentionsContent.tsx +++ b/app/(home-pages)/reader/ReaderMentionsContent.tsx @@ -45,9 +45,24 @@ export function ReaderMentionsContent(props: { const postViewMap = new Map(); bskyPosts?.forEach((pv) => postViewMap.set(pv.uri, pv)); + // Sort by engagement: likes count 1, replies and quotes count 1.5 + const sorted = [...props.quotesAndMentions].sort((a, b) => { + const postA = postViewMap.get(a.uri); + const postB = postViewMap.get(b.uri); + const scoreA = + (postA?.likeCount ?? 0) + + (postA?.replyCount ?? 0) * 1.5 + + (postA?.quoteCount ?? 0) * 1.5; + const scoreB = + (postB?.likeCount ?? 0) + + (postB?.replyCount ?? 0) * 1.5 + + (postB?.quoteCount ?? 0) * 1.5; + return scoreB - scoreA; + }); + return (
- {props.quotesAndMentions.map((q, index) => { + {sorted.map((q, index) => { const post = postViewMap.get(q.uri); if (!post) return null; return ( @@ -61,7 +76,7 @@ export function ReaderMentionsContent(props: { className="text-sm" compactEmbed /> - {index < props.quotesAndMentions.length - 1 && ( + {index < sorted.length - 1 && (
)}
diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx index 1c39cde9..3d0d88fa 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx @@ -26,6 +26,15 @@ import { QuoteTiny } from "components/Icons/QuoteTiny"; import { ThreadLink, QuotesLink } from "../PostLinks"; import { BskyPostContent } from "../BskyPostContent"; +function engagementScore(post: PostView | undefined): number { + if (!post) return 0; + return ( + (post.likeCount ?? 0) + + (post.replyCount ?? 0) * 1.5 + + (post.quoteCount ?? 0) * 1.5 + ); +} + // Helper to get SWR key for quotes export function getQuotesSWRKey(uris: string[]) { if (uris.length === 0) return null; @@ -85,6 +94,18 @@ export const MentionsDrawerContent = (props: { postViewMap.set(pv.uri, pv); }); + // Sort by engagement: likes count 1, replies and quotes count 1.5 + const byEngagement = ( + a: { uri: string }, + b: { uri: string }, + ) => { + const scoreA = engagementScore(postViewMap.get(a.uri)); + const scoreB = engagementScore(postViewMap.get(b.uri)); + return scoreB - scoreA; + }; + quotesWithLinks.sort(byEngagement); + directMentions.sort(byEngagement); + return ( <> {props.quotesAndMentions.length === 0 ? (