From a7dedaf273b6fd2ebd9c9b8b9d6a7d227f376797 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 20 Oct 2019 17:49:13 -0700 Subject: Externalize into sort-select component. - Fixes #311 --- ui/src/components/main.tsx | 50 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) (limited to 'ui/src/components/main.tsx') diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index b1ddef4c..e4ff5a50 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -20,6 +20,7 @@ import { } from '../interfaces'; import { WebSocketService, UserService } from '../services'; import { PostListings } from './post-listings'; +import { SortSelect } from './sort-select'; import { SiteForm } from './site-form'; import { msgOp, @@ -99,6 +100,7 @@ export class Main extends Component { this.state = this.emptyState; this.handleEditCancel = this.handleEditCancel.bind(this); + this.handleSortChange = this.handleSortChange.bind(this); this.subscription = WebSocketService.Instance.subject .pipe( @@ -450,37 +452,9 @@ export class Main extends Component { {i18n.t('all')} - + + + ); } @@ -543,13 +517,13 @@ export class Main extends Component { window.scrollTo(0, 0); } - handleSortChange(i: Main, event: any) { - i.state.sort = Number(event.target.value); - i.state.page = 1; - i.state.loading = true; - i.setState(i.state); - i.updateUrl(); - i.fetchPosts(); + handleSortChange(val: SortType) { + this.state.sort = val; + this.state.page = 1; + this.state.loading = true; + this.setState(this.state); + this.updateUrl(); + this.fetchPosts(); window.scrollTo(0, 0); } -- cgit v1.2.3