From ddabc4286118419280520c430adaf6d7f49ff9ca Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 20 Apr 2019 12:42:52 -0700 Subject: [PATCH] Adding support for an /all route - Fixes #85 --- ui/src/components/home.tsx | 10 +++++++++- ui/src/components/main.tsx | 15 ++++++++++----- ui/src/components/navbar.tsx | 2 +- ui/src/components/post-listings.tsx | 22 ++++++++++++++-------- ui/src/index.tsx | 1 + 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/ui/src/components/home.tsx b/ui/src/components/home.tsx index 8fced5be..eff09f7e 100644 --- a/ui/src/components/home.tsx +++ b/ui/src/components/home.tsx @@ -1,12 +1,20 @@ import { Component } from 'inferno'; import { Main } from './main'; +import { ListingType } from '../interfaces'; export class Home extends Component { + constructor(props: any, context: any) { + super(props, context); + } + render() { return ( -
+
) } + listType(): ListingType { + return (this.props.match.path == '/all') ? ListingType.All : ListingType.Subscribed; + } } diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index e3d6f844..6e0b96b6 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -2,22 +2,27 @@ import { Component } from 'inferno'; import { Link } from 'inferno-router'; import { Subscription } from "rxjs"; import { retryWhen, delay, take } from 'rxjs/operators'; -import { UserOperation, CommunityUser, GetFollowedCommunitiesResponse, ListCommunitiesForm, ListCommunitiesResponse, Community, SortType, GetSiteResponse, GetRepliesResponse, GetRepliesForm } from '../interfaces'; +import { UserOperation, CommunityUser, GetFollowedCommunitiesResponse, ListCommunitiesForm, ListCommunitiesResponse, Community, SortType, GetSiteResponse, GetRepliesResponse, GetRepliesForm, ListingType } from '../interfaces'; import { WebSocketService, UserService } from '../services'; import { PostListings } from './post-listings'; import { msgOp, repoUrl, mdToHtml } from '../utils'; -interface State { + +interface MainProps { + type: ListingType; +} + +interface MainState { subscribedCommunities: Array; trendingCommunities: Array; site: GetSiteResponse; loading: boolean; } -export class Main extends Component { +export class Main extends Component { private subscription: Subscription; - private emptyState: State = { + private emptyState: MainState = { subscribedCommunities: [], trendingCommunities: [], site: { @@ -83,7 +88,7 @@ export class Main extends Component {
- +
{this.state.loading ? diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index fed49e6f..5fc6ed7e 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -71,7 +71,7 @@ export class Navbar extends Component { {
  • 🖂 - {this.state.unreadCount> 0 && {this.state.unreadCount}} + {this.state.unreadCount> 0 && {this.state.unreadCount}}
  • } diff --git a/ui/src/components/post-listings.tsx b/ui/src/components/post-listings.tsx index b1e48a61..37b7a648 100644 --- a/ui/src/components/post-listings.tsx +++ b/ui/src/components/post-listings.tsx @@ -8,6 +8,7 @@ import { PostListing } from './post-listing'; import { msgOp, fetchLimit } from '../utils'; interface PostListingsProps { + type?: ListingType; communityId?: number; } @@ -27,19 +28,19 @@ export class PostListings extends Component {
    + -- 2.44.1