mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add recursive counter for links in replies
This commit is contained in:
@@ -17,6 +17,7 @@ import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import useError from '../../hooks/useError';
|
||||
@@ -464,6 +465,7 @@ const AllCatalog = () => {
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const linkCount = countLinks(thread);
|
||||
return (
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||
@@ -522,9 +524,14 @@ const AllCatalog = () => {
|
||||
</div>
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset"}}>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
||||
R:
|
||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
{linkCount > 0 ? (
|
||||
<>
|
||||
/
|
||||
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||
</>
|
||||
) : null}
|
||||
<PostMenu
|
||||
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
||||
position: 'absolute', lineHeight: '1em', marginTop: '-1px', outline: 'none',
|
||||
|
||||
@@ -17,6 +17,7 @@ import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import useAnonModeRef from '../../hooks/useAnonModeRef';
|
||||
@@ -711,8 +712,8 @@ const Catalog = () => {
|
||||
onMouseOver={() => setIsHoveringOnThread('rules')}
|
||||
onMouseLeave={() => setIsHoveringOnThread('')}>
|
||||
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
||||
<div className='meta' title="(R)eplies / (I)mage Replies">
|
||||
R:<b>0</b>
|
||||
<div className='meta' title="(R)eplies / (L)ink Replies">
|
||||
R: <b>0</b> / L: <b>0</b>
|
||||
<div className='thread-icons'
|
||||
style={{position: 'absolute', top: '-2px', right: '15px'}}>
|
||||
<span className="thread-icon sticky-icon" title="Sticky"
|
||||
@@ -795,8 +796,8 @@ const Catalog = () => {
|
||||
</div>
|
||||
) : null}
|
||||
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
||||
<div className='meta' title="(R)eplies / (I)mage Replies">
|
||||
R:<b>0</b>
|
||||
<div className='meta' title="(R)eplies / (L)ink Replies">
|
||||
R: <b>0</b> / L: <b>0</b>
|
||||
{subplebbit.suggested?.avatarUrl ? null : (
|
||||
<div className='thread-icons'
|
||||
style={{position: 'absolute', top: '-2px', right: '15px'}}>
|
||||
@@ -892,6 +893,7 @@ const Catalog = () => {
|
||||
{feed.map((thread, index) => {
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||
const linkCount = countLinks(thread);
|
||||
return (
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||
@@ -951,9 +953,14 @@ const Catalog = () => {
|
||||
) : null}
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset"}}>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
||||
R:
|
||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
{linkCount > 0 ? (
|
||||
<>
|
||||
/
|
||||
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||
</>
|
||||
) : null}
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
commentMediaInfo.type === 'video' ||
|
||||
|
||||
@@ -18,6 +18,7 @@ import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import useError from '../../hooks/useError';
|
||||
@@ -468,6 +469,7 @@ const SubscriptionsCatalog = () => {
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const linkCount = countLinks(thread);
|
||||
return (
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||
@@ -526,9 +528,14 @@ const SubscriptionsCatalog = () => {
|
||||
</div>
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset"}}>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
||||
R:
|
||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
{linkCount > 0 ? (
|
||||
<>
|
||||
/
|
||||
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||
</>
|
||||
) : null}
|
||||
<PostMenu
|
||||
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
||||
position: 'absolute', lineHeight: '1em', marginTop: '-1px', outline: 'none',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
function countLinks(comment) {
|
||||
let linkCount = 0;
|
||||
|
||||
if (comment.replyCount > 0) {
|
||||
for (let reply of comment.replies.pages.topAll.comments) {
|
||||
|
||||
if (reply.link) {
|
||||
linkCount++;
|
||||
}
|
||||
|
||||
if (reply.replyCount > 0) {
|
||||
linkCount += countLinks(reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return linkCount;
|
||||
}
|
||||
|
||||
export default countLinks;
|
||||
Reference in New Issue
Block a user