summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-listings.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-04-07 22:19:02 -0700
committerDessalines <tyhou13@gmx.com>2019-04-07 22:19:02 -0700
commit49bf16e7d451388d894f93a994f3bf18571f9594 (patch)
tree1802bf775a0dd97503670c38ceb13d9aa78d95b6 /ui/src/components/post-listings.tsx
parenta61516439406b7884e19d9ae8a1875c728bbe628 (diff)
Adding user details / overview page.
- Fixes #19
Diffstat (limited to 'ui/src/components/post-listings.tsx')
-rw-r--r--ui/src/components/post-listings.tsx36
1 files changed, 17 insertions, 19 deletions
diff --git a/ui/src/components/post-listings.tsx b/ui/src/components/post-listings.tsx
index 98fe8f21..bb36cabc 100644
--- a/ui/src/components/post-listings.tsx
+++ b/ui/src/components/post-listings.tsx
@@ -2,12 +2,10 @@ import { Component, linkEvent } from 'inferno';
import { Link } from 'inferno-router';
import { Subscription } from "rxjs";
import { retryWhen, delay, take } from 'rxjs/operators';
-import { UserOperation, Community as CommunityI, GetCommunityResponse, CommunityResponse, Post, GetPostsForm, ListingSortType, ListingType, GetPostsResponse, CreatePostLikeForm, CreatePostLikeResponse, CommunityUser} from '../interfaces';
+import { UserOperation, Community as CommunityI, Post, GetPostsForm, SortType, ListingType, GetPostsResponse, CreatePostLikeResponse, CommunityUser} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { MomentTime } from './moment-time';
import { PostListing } from './post-listing';
-import { Sidebar } from './sidebar';
-import { msgOp, mdToHtml } from '../utils';
+import { msgOp } from '../utils';
interface PostListingsProps {
@@ -18,7 +16,7 @@ interface PostListingsState {
community: CommunityI;
moderators: Array<CommunityUser>;
posts: Array<Post>;
- sortType: ListingSortType;
+ sortType: SortType;
type_: ListingType;
}
@@ -41,7 +39,7 @@ export class PostListings extends Component<PostListingsProps, PostListingsState
},
moderators: [],
posts: [],
- sortType: ListingSortType.Hot,
+ sortType: SortType.Hot,
type_: this.props.communityId
? ListingType.Community
: UserService.Instance.loggedIn
@@ -49,7 +47,7 @@ export class PostListings extends Component<PostListingsProps, PostListingsState
: ListingType.All
}
- constructor(props, context) {
+ constructor(props: any, context: any) {
super(props, context);
@@ -67,7 +65,7 @@ export class PostListings extends Component<PostListingsProps, PostListingsState
type_: ListingType[this.state.type_],
community_id: this.props.communityId,
limit: 10,
- sort: ListingSortType[ListingSortType.Hot],
+ sort: SortType[SortType.Hot],
}
WebSocketService.Instance.getPosts(getPostsForm);
}
@@ -94,14 +92,14 @@ export class PostListings extends Component<PostListingsProps, PostListingsState
<div className="mb-2">
<select value={this.state.sortType} onChange={linkEvent(this, this.handleSortChange)} class="custom-select w-auto">
<option disabled>Sort Type</option>
- <option value={ListingSortType.Hot}>Hot</option>
- <option value={ListingSortType.New}>New</option>
+ <option value={SortType.Hot}>Hot</option>
+ <option value={SortType.New}>New</option>
<option disabled>──────────</option>
- <option value={ListingSortType.TopDay}>Top Day</option>
- <option value={ListingSortType.TopWeek}>Week</option>
- <option value={ListingSortType.TopMonth}>Month</option>
- <option value={ListingSortType.TopYear}>Year</option>
- <option value={ListingSortType.TopAll}>All</option>
+ <option value={SortType.TopDay}>Top Day</option>
+ <option value={SortType.TopWeek}>Week</option>
+ <option value={SortType.TopMonth}>Month</option>
+ <option value={SortType.TopYear}>Year</option>
+ <option value={SortType.TopAll}>All</option>
</select>
{!this.props.communityId &&
UserService.Instance.loggedIn &&
@@ -117,26 +115,26 @@ export class PostListings extends Component<PostListingsProps, PostListingsState
}
- handleSortChange(i: PostListings, event) {
+ handleSortChange(i: PostListings, event: any) {
i.state.sortType = Number(event.target.value);
i.setState(i.state);
let getPostsForm: GetPostsForm = {
community_id: i.state.community.id,
limit: 10,
- sort: ListingSortType[i.state.sortType],
+ sort: SortType[i.state.sortType],
type_: ListingType[ListingType.Community]
}
WebSocketService.Instance.getPosts(getPostsForm);
}
- handleTypeChange(i: PostListings, event) {
+ handleTypeChange(i: PostListings, event: any) {
i.state.type_ = Number(event.target.value);
i.setState(i.state);
let getPostsForm: GetPostsForm = {
limit: 10,
- sort: ListingSortType[i.state.sortType],
+ sort: SortType[i.state.sortType],
type_: ListingType[i.state.type_]
}
WebSocketService.Instance.getPosts(getPostsForm);