]> Untitled Git - lemmy.git/blob - ui/src/components/post-listings.tsx
Merge branch 'dev' into richardj-feature/frontend-a11y
[lemmy.git] / ui / src / components / post-listings.tsx
1 import { Component } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { Post } from '../interfaces';
4 import { PostListing } from './post-listing';
5 import { i18n } from '../i18next';
6 import { T } from 'inferno-i18next';
7
8 interface PostListingsProps {
9   posts: Array<Post>;
10   showCommunity?: boolean;
11 }
12
13 export class PostListings extends Component<PostListingsProps, any> {
14   constructor(props: any, context: any) {
15     super(props, context);
16   }
17
18   render() {
19     return (
20       <div>
21         {this.props.posts.length > 0 ? (
22           this.props.posts.map(post => (
23             <>
24               <PostListing
25                 post={post}
26                 showCommunity={this.props.showCommunity}
27               />
28               <hr class="d-md-none my-2" />
29               <div class="d-none d-md-block my-2"></div>
30             </>
31           ))
32         ) : (
33           <>
34             <h5>
35               { i18n.t('no_posts') }
36             </h5>
37             {this.props.showCommunity !== undefined && (
38               <div>
39                 <Link to="/communities">{ i18n.t('subscribe_to_communities') }</Link>
40               </div>
41             )}
42           </>
43         )}
44       </div>
45     );
46   }
47 }