]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/post/post-listings.tsx
Mark post as read when clicking "Expand here" on the preview image on the post listin...
[lemmy-ui.git] / src / shared / components / post / post-listings.tsx
index 00370f039bfea8b104d206e1fcf497e27e400501..fc77f505a11ff76119bd52658dc4a116bb04603b 100644 (file)
@@ -14,6 +14,7 @@ import {
   FeaturePost,
   Language,
   LockPost,
+  MarkPostAsRead,
   PostView,
   PurgePerson,
   PurgePost,
@@ -21,7 +22,7 @@ import {
   SavePost,
   TransferCommunity,
 } from "lemmy-js-client";
-import { i18n } from "../../i18next";
+import { I18NextService } from "../../services";
 import { PostListing } from "./post-listing";
 
 interface PostListingsProps {
@@ -49,6 +50,7 @@ interface PostListingsProps {
   onAddModToCommunity(form: AddModToCommunity): void;
   onAddAdmin(form: AddAdmin): void;
   onTransferCommunity(form: TransferCommunity): void;
+  onMarkPostAsRead(form: MarkPostAsRead): void;
 }
 
 export class PostListings extends Component<PostListingsProps, any> {
@@ -66,7 +68,7 @@ export class PostListings extends Component<PostListingsProps, any> {
 
   render() {
     return (
-      <div>
+      <div className="post-listings">
         {this.posts.length > 0 ? (
           this.posts.map((post_view, idx) => (
             <>
@@ -95,15 +97,14 @@ export class PostListings extends Component<PostListingsProps, any> {
                 onAddModToCommunity={this.props.onAddModToCommunity}
                 onAddAdmin={this.props.onAddAdmin}
                 onTransferCommunity={this.props.onTransferCommunity}
+                onMarkPostAsRead={this.props.onMarkPostAsRead}
               />
-              {idx + 1 !== this.posts.length && (
-                <hr className="my-3 border border-primary" />
-              )}
+              {idx + 1 !== this.posts.length && <hr className="my-3" />}
             </>
           ))
         ) : (
           <>
-            <div>{i18n.t("no_posts")}</div>
+            <div>{I18NextService.i18n.t("no_posts")}</div>
             {this.props.showCommunity && (
               <T i18nKey="subscribe_to_communities">
                 #<Link to="/communities">#</Link>
@@ -143,7 +144,7 @@ export class PostListings extends Component<PostListingsProps, any> {
     // Sort by oldest
     // Remove the ones that have no length
     for (const e of urlMap.entries()) {
-      if (e[1].length == 1) {
+      if (e[1].length === 1) {
         urlMap.delete(e[0]);
       } else {
         e[1].sort((a, b) => a.post.published.localeCompare(b.post.published));
@@ -157,7 +158,7 @@ export class PostListings extends Component<PostListingsProps, any> {
         const found = urlMap.get(url);
         if (found) {
           // If its the oldest, add
-          if (pv.post.id == found[0].post.id) {
+          if (pv.post.id === found[0].post.id) {
             this.duplicatesMap.set(pv.post.id, found.slice(1));
           }
           // Otherwise, delete it