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 ModerationModal from '../modals/ModerationModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import SettingsModal from '../modals/SettingsModal';
|
import SettingsModal from '../modals/SettingsModal';
|
||||||
|
import countLinks from '../../utils/countLinks';
|
||||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||||
import handleStyleChange from '../../utils/handleStyleChange';
|
import handleStyleChange from '../../utils/handleStyleChange';
|
||||||
import useError from '../../hooks/useError';
|
import useError from '../../hooks/useError';
|
||||||
@@ -464,6 +465,7 @@ const AllCatalog = () => {
|
|||||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||||
|
const linkCount = countLinks(thread);
|
||||||
return (
|
return (
|
||||||
<div key={`thread-${index}`} className="thread"
|
<div key={`thread-${index}`} className="thread"
|
||||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||||
@@ -522,9 +524,14 @@ const AllCatalog = () => {
|
|||||||
</div>
|
</div>
|
||||||
<BoardForm selectedStyle={selectedStyle}
|
<BoardForm selectedStyle={selectedStyle}
|
||||||
style={{ all: "unset"}}>
|
style={{ all: "unset"}}>
|
||||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||||
R:
|
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
{linkCount > 0 ? (
|
||||||
|
<>
|
||||||
|
/
|
||||||
|
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<PostMenu
|
<PostMenu
|
||||||
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
||||||
position: 'absolute', lineHeight: '1em', marginTop: '-1px', outline: 'none',
|
position: 'absolute', lineHeight: '1em', marginTop: '-1px', outline: 'none',
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import VerifiedAuthor from '../VerifiedAuthor';
|
|||||||
import ModerationModal from '../modals/ModerationModal';
|
import ModerationModal from '../modals/ModerationModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import SettingsModal from '../modals/SettingsModal';
|
import SettingsModal from '../modals/SettingsModal';
|
||||||
|
import countLinks from '../../utils/countLinks';
|
||||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||||
import handleStyleChange from '../../utils/handleStyleChange';
|
import handleStyleChange from '../../utils/handleStyleChange';
|
||||||
import useAnonModeRef from '../../hooks/useAnonModeRef';
|
import useAnonModeRef from '../../hooks/useAnonModeRef';
|
||||||
@@ -711,8 +712,8 @@ const Catalog = () => {
|
|||||||
onMouseOver={() => setIsHoveringOnThread('rules')}
|
onMouseOver={() => setIsHoveringOnThread('rules')}
|
||||||
onMouseLeave={() => setIsHoveringOnThread('')}>
|
onMouseLeave={() => setIsHoveringOnThread('')}>
|
||||||
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
||||||
<div className='meta' title="(R)eplies / (I)mage Replies">
|
<div className='meta' title="(R)eplies / (L)ink Replies">
|
||||||
R:<b>0</b>
|
R: <b>0</b> / L: <b>0</b>
|
||||||
<div className='thread-icons'
|
<div className='thread-icons'
|
||||||
style={{position: 'absolute', top: '-2px', right: '15px'}}>
|
style={{position: 'absolute', top: '-2px', right: '15px'}}>
|
||||||
<span className="thread-icon sticky-icon" title="Sticky"
|
<span className="thread-icon sticky-icon" title="Sticky"
|
||||||
@@ -795,8 +796,8 @@ const Catalog = () => {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
||||||
<div className='meta' title="(R)eplies / (I)mage Replies">
|
<div className='meta' title="(R)eplies / (L)ink Replies">
|
||||||
R:<b>0</b>
|
R: <b>0</b> / L: <b>0</b>
|
||||||
{subplebbit.suggested?.avatarUrl ? null : (
|
{subplebbit.suggested?.avatarUrl ? null : (
|
||||||
<div className='thread-icons'
|
<div className='thread-icons'
|
||||||
style={{position: 'absolute', top: '-2px', right: '15px'}}>
|
style={{position: 'absolute', top: '-2px', right: '15px'}}>
|
||||||
@@ -892,6 +893,7 @@ const Catalog = () => {
|
|||||||
{feed.map((thread, index) => {
|
{feed.map((thread, index) => {
|
||||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||||
|
const linkCount = countLinks(thread);
|
||||||
return (
|
return (
|
||||||
<div key={`thread-${index}`} className="thread"
|
<div key={`thread-${index}`} className="thread"
|
||||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||||
@@ -951,9 +953,14 @@ const Catalog = () => {
|
|||||||
) : null}
|
) : null}
|
||||||
<BoardForm selectedStyle={selectedStyle}
|
<BoardForm selectedStyle={selectedStyle}
|
||||||
style={{ all: "unset"}}>
|
style={{ all: "unset"}}>
|
||||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||||
R:
|
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
{linkCount > 0 ? (
|
||||||
|
<>
|
||||||
|
/
|
||||||
|
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{(commentMediaInfo && (
|
{(commentMediaInfo && (
|
||||||
commentMediaInfo.type === 'image' ||
|
commentMediaInfo.type === 'image' ||
|
||||||
commentMediaInfo.type === 'video' ||
|
commentMediaInfo.type === 'video' ||
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import VerifiedAuthor from '../VerifiedAuthor';
|
|||||||
import ModerationModal from '../modals/ModerationModal';
|
import ModerationModal from '../modals/ModerationModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import SettingsModal from '../modals/SettingsModal';
|
import SettingsModal from '../modals/SettingsModal';
|
||||||
|
import countLinks from '../../utils/countLinks';
|
||||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||||
import handleStyleChange from '../../utils/handleStyleChange';
|
import handleStyleChange from '../../utils/handleStyleChange';
|
||||||
import useError from '../../hooks/useError';
|
import useError from '../../hooks/useError';
|
||||||
@@ -468,6 +469,7 @@ const SubscriptionsCatalog = () => {
|
|||||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||||
|
const linkCount = countLinks(thread);
|
||||||
return (
|
return (
|
||||||
<div key={`thread-${index}`} className="thread"
|
<div key={`thread-${index}`} className="thread"
|
||||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||||
@@ -526,9 +528,14 @@ const SubscriptionsCatalog = () => {
|
|||||||
</div>
|
</div>
|
||||||
<BoardForm selectedStyle={selectedStyle}
|
<BoardForm selectedStyle={selectedStyle}
|
||||||
style={{ all: "unset"}}>
|
style={{ all: "unset"}}>
|
||||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||||
R:
|
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
{linkCount > 0 ? (
|
||||||
|
<>
|
||||||
|
/
|
||||||
|
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<PostMenu
|
<PostMenu
|
||||||
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
||||||
position: 'absolute', lineHeight: '1em', marginTop: '-1px', outline: '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