link fe: always render up-to-date comment counts

This commit is contained in:
Fang 2020-02-06 15:04:47 +01:00
parent ab21f67ba6
commit 4222ebbfb3
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
4 changed files with 14 additions and 59975 deletions

File diff suppressed because one or more lines are too long

View File

@ -94,7 +94,9 @@ export class LinkDetail extends Component {
hostname = hostname[4];
}
let commentCount = data.commentCount || 0;
const commentCount = props.comments
? props.comments.totalItems
: data.commentCount || 0;
let comments = commentCount + " comment" + ((commentCount === 1) ? "" : "s");

View File

@ -44,9 +44,13 @@ export class Links extends Component {
let LinkList = Object.keys(links)
.map((link) => {
let linksObj = props.links[linkPage];
let { title, url, timestamp, ship, commentCount } = linksObj[link];
let { title, url, timestamp, ship } = linksObj[link];
let members = {};
const commentCount = props.comments[url]
? props.comments[url].totalItems
: linksObj[link].commentCount || 0;
if (!props.members[ship]) {
members[ship] = {'nickname': '', 'avatar': 'TODO', 'color': '0x0'};
} else {

View File

@ -71,6 +71,10 @@ export class Root extends Component {
? links[groupPath]
: {};
let channelComments = !!comments[groupPath]
? comments[groupPath]
: {};
return (
<Skeleton
spinner={state.spinner}
@ -85,6 +89,7 @@ export class Root extends Component {
{...props}
members={groupMembers}
links={channelLinks}
comments={channelComments}
page={page}
path={groupPath}
popout={popout}