mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-30 13:19:16 +03:00
Experiment show replies count for questions
This commit is contained in:
parent
d27de2337a
commit
89fb1bbc07
2 changed files with 49 additions and 1 deletions
|
@ -520,6 +520,14 @@
|
||||||
color: inherit;
|
color: inherit;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
.status .content-comment-hint {
|
||||||
|
margin-top: 0.25em;
|
||||||
|
font-size: 90%;
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.status.compact-thread .spoiler-badge {
|
.status.compact-thread .spoiler-badge {
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
color: var(--button-bg-color);
|
color: var(--button-bg-color);
|
||||||
|
|
|
@ -65,6 +65,7 @@ import MenuLink from './menu-link';
|
||||||
import RelativeTime from './relative-time';
|
import RelativeTime from './relative-time';
|
||||||
import TranslationBlock from './translation-block';
|
import TranslationBlock from './translation-block';
|
||||||
|
|
||||||
|
const SHOW_COMMENT_COUNT_LIMIT = 280;
|
||||||
const INLINE_TRANSLATE_LIMIT = 140;
|
const INLINE_TRANSLATE_LIMIT = 140;
|
||||||
const throttle = pThrottle({
|
const throttle = pThrottle({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
@ -1021,6 +1022,40 @@ function Status({
|
||||||
repliesCount,
|
repliesCount,
|
||||||
visibility,
|
visibility,
|
||||||
]);
|
]);
|
||||||
|
const showCommentCount = useMemo(() => {
|
||||||
|
if (
|
||||||
|
card ||
|
||||||
|
poll ||
|
||||||
|
sensitive ||
|
||||||
|
spoilerText ||
|
||||||
|
mediaAttachments?.length ||
|
||||||
|
isThread ||
|
||||||
|
withinContext ||
|
||||||
|
inReplyToId ||
|
||||||
|
repliesCount <= 0
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const questionRegex = /[???︖❓❔⁇⁈⁉¿‽؟]/;
|
||||||
|
const containsQuestion = questionRegex.test(content);
|
||||||
|
if (!containsQuestion) return false;
|
||||||
|
const contentLength = htmlContentLength(content);
|
||||||
|
if (contentLength > 0 && contentLength <= SHOW_COMMENT_COUNT_LIMIT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
card,
|
||||||
|
poll,
|
||||||
|
sensitive,
|
||||||
|
spoilerText,
|
||||||
|
mediaAttachments,
|
||||||
|
reblog,
|
||||||
|
isThread,
|
||||||
|
withinContext,
|
||||||
|
inReplyToId,
|
||||||
|
repliesCount,
|
||||||
|
content,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article
|
<article
|
||||||
|
@ -1184,7 +1219,7 @@ function Status({
|
||||||
: ''
|
: ''
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{showCommentHint ? (
|
{showCommentHint && !showCommentCount ? (
|
||||||
<Icon
|
<Icon
|
||||||
icon="comment2"
|
icon="comment2"
|
||||||
size="s"
|
size="s"
|
||||||
|
@ -1516,6 +1551,11 @@ function Status({
|
||||||
<Card card={card} instance={currentInstance} />
|
<Card card={card} instance={currentInstance} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{!isSizeLarge && showCommentCount && (
|
||||||
|
<div class="content-comment-hint insignificant">
|
||||||
|
<Icon icon="comment2" alt="Replies" /> {repliesCount}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{isSizeLarge && (
|
{isSizeLarge && (
|
||||||
<>
|
<>
|
||||||
<div class="extra-meta">
|
<div class="extra-meta">
|
||||||
|
|
Loading…
Add table
Reference in a new issue