feat: show likesCount and hide viewCount for shorts

This commit is contained in:
DIYgod 2023-09-19 21:55:38 +08:00
parent 493dff4ddb
commit 070c339749
No known key found for this signature in database
5 changed files with 20 additions and 13 deletions

View File

@ -216,12 +216,13 @@ const Card = ({
<FormattedNumber value={post.stat?.viewDetailCount} />
</span>
)}
{post.stat?.commentsCount ? (
{!!post.stat?.commentsCount && (
<span className="xlog-post-views inline-flex items-center">
<i className="icon-[mingcute--comment-line] mr-[2px] text-base" />
<FormattedNumber value={post.stat.commentsCount} />
</span>
) : (
)}
{!post.stat?.commentsCount && (
<span className="xlog-post-word-count sm:inline-flex items-center hidden">
<i className="icon-[mingcute--sandglass-line] mr-[2px] text-sm" />
<span
@ -274,12 +275,20 @@ const Card = ({
<span className="text-zinc-400 hidden sm:inline-block">·</span>
</>
)}
{isShort && !!post.stat?.viewCount && (
{isShort && (
<span className="xlog-post-meta text-zinc-400 flex items-center text-[13px] truncate space-x-2">
<span className="xlog-post-views inline-flex items-center">
<i className="icon-[mingcute--eye-line] mr-[2px] text-base" />
<FormattedNumber value={post.stat?.viewCount} />
</span>
{!!post.stat?.likesCount && (
<span className="xlog-post-views inline-flex items-center">
<i className="icon-[mingcute--thumb-up-2-line] mr-[2px] text-base" />
<FormattedNumber value={post.stat?.likesCount} />
</span>
)}
{!!post.stat?.commentsCount && (
<span className="xlog-post-views inline-flex items-center">
<i className="icon-[mingcute--comment-line] mr-[2px] text-base" />
<FormattedNumber value={post.stat?.commentsCount} />
</span>
)}
</span>
)}
{!isShort && (

View File

@ -138,8 +138,9 @@ export const expandCrossbellNote = async ({
)
).json()
expandedNote.stat = stat
} else if ((expandedNote as any)._count?.fromNotes) {
} else if ((expandedNote as any)._count) {
expandedNote.stat.commentsCount = (expandedNote as any)._count.fromNotes
expandedNote.stat.likesCount = (expandedNote as any)._count.links
}
}

View File

@ -101,10 +101,10 @@ export type ExpandedNote = NoteEntity & {
}
stat?: {
viewDetailCount?: number
viewCount?: number
hotScore?: number
portfolio?: PortfolioStats
commentsCount?: number
likesCount?: number
}
local?: boolean
}

View File

@ -300,9 +300,6 @@ export async function getFeed({
${cursorQuery}
) {
${resultFields}
stat {
viewCount
}
}
}
`,

View File

@ -237,10 +237,10 @@ export async function getPagesBySite(input: {
? `
stat {
viewDetailCount
viewCount
}
_count {
fromNotes
links
}
`
: ""