summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-listings.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-04-20 12:42:52 -0700
committerDessalines <tyhou13@gmx.com>2019-04-20 12:42:52 -0700
commitddabc4286118419280520c430adaf6d7f49ff9ca (patch)
tree2bd867453066655d68c10f24cbefba5282e7885c /ui/src/components/post-listings.tsx
parentbe08352cfdef1d1e9a3f2de8fa28aad8767aeeec (diff)
Adding support for an /all route
- Fixes #85
Diffstat (limited to 'ui/src/components/post-listings.tsx')
-rw-r--r--ui/src/components/post-listings.tsx22
1 files changed, 14 insertions, 8 deletions
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<PostListingsProps, PostListingsState
moderators: [],
posts: [],
sortType: SortType.Hot,
- type_: this.props.communityId
- ? ListingType.Community
- : UserService.Instance.user
- ? ListingType.Subscribed
- : ListingType.All,
- page: 1,
- loading: true
+ type_: (this.props.type !== undefined) ? this.props.type :
+ this.props.communityId
+ ? ListingType.Community
+ : UserService.Instance.user
+ ? ListingType.Subscribed
+ : ListingType.All,
+ page: 1,
+ loading: true
}
constructor(props: any, context: any) {
super(props, context);
-
this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
@@ -147,6 +148,11 @@ export class PostListings extends Component<PostListingsProps, PostListingsState
handleTypeChange(i: PostListings, event: any) {
i.state.type_ = Number(event.target.value);
i.state.page = 1;
+ if (i.state.type_ == ListingType.All) {
+ i.context.router.history.push('/all');
+ } else {
+ i.context.router.history.push('/');
+ }
i.setState(i.state);
i.refetch();
}