Adding new unread comments.

This commit is contained in:
Dessalines 2022-08-06 21:58:05 -04:00
parent df31cb53cb
commit f76d25bedc
4 changed files with 28 additions and 8 deletions

View file

@ -77,7 +77,7 @@
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1", "husky": "^8.0.1",
"import-sort-style-module": "^6.0.0", "import-sort-style-module": "^6.0.0",
"lemmy-js-client": "0.17.0-rc.39", "lemmy-js-client": "0.17.0-rc.42",
"lint-staged": "^13.0.3", "lint-staged": "^13.0.3",
"mini-css-extract-plugin": "^2.6.1", "mini-css-extract-plugin": "^2.6.1",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",

View file

@ -627,15 +627,34 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
to={`/post/${post_view.post.id}?scrollToComments=true`} to={`/post/${post_view.post.id}?scrollToComments=true`}
> >
<Icon icon="message-square" classes="mr-1" inline /> <Icon icon="message-square" classes="mr-1" inline />
{i18n.t("number_of_comments", { <span class="mr-2">
count: post_view.counts.comments, {i18n.t("number_of_comments", {
formattedCount: numToSI(post_view.counts.comments), count: post_view.counts.comments,
formattedCount: numToSI(post_view.counts.comments),
})}
</span>
{this.unreadCount.match({
some: unreadCount => (
<span class="small text-warning">
({unreadCount} {i18n.t("new")})
</span>
),
none: <></>,
})} })}
</Link> </Link>
</button> </button>
); );
} }
get unreadCount(): Option<number> {
let pv = this.props.post_view;
if (pv.unread_comments == pv.counts.comments || pv.unread_comments == 0) {
return None;
} else {
return Some(pv.unread_comments);
}
}
get mobileVotes() { get mobileVotes() {
// TODO: make nicer // TODO: make nicer
let tippy = showScores() ? { "data-tippy-content": this.pointsTippy } : {}; let tippy = showScores() ? { "data-tippy-content": this.pointsTippy } : {};

View file

@ -45,6 +45,7 @@ export class PostReport extends Component<PostReportProps, any> {
read: false, read: false,
creator_blocked: false, creator_blocked: false,
my_vote: r.my_vote, my_vote: r.my_vote,
unread_comments: 0,
}; };
return ( return (

View file

@ -5056,10 +5056,10 @@ lcid@^1.0.0:
dependencies: dependencies:
invert-kv "^1.0.0" invert-kv "^1.0.0"
lemmy-js-client@0.17.0-rc.39: lemmy-js-client@0.17.0-rc.42:
version "0.17.0-rc.39" version "0.17.0-rc.42"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.39.tgz#b17c5c0d9a0f36c90c17be99845a5703091ab306" resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.42.tgz#1fbfc003882c23c63f4fb67638743a4fe1db3101"
integrity sha512-MsKavo5xOob6DgfjyhbmXyFvXwdW4iwftStJ7Bz3ArlHXy6zGBp+2uy2rU2c5ujivNDX72ol3TupTHBtSXLs4w== integrity sha512-7B3AtHEEWDYAnlm9D7qbHx9ZjHwlPP+KkxA7H/CL1S9cTcOdstZ4H9I6nDyr9xqKImjVMaDwlVZvEukW7GYgbA==
levn@^0.4.1: levn@^0.4.1:
version "0.4.1" version "0.4.1"