diff options
author | derek <wwsage@gmail.com> | 2020-07-14 01:13:43 -0400 |
---|---|---|
committer | derek <wwsage@gmail.com> | 2020-07-14 01:13:43 -0400 |
commit | ef62f4698a62e996bcd54faa1f360eff89b8ac4b (patch) | |
tree | ce5d6397d6ee1134fd58f23e2088b932da9ebfb0 /ui/src/components/community.tsx | |
parent | 563a66b053dfbb189193f18775c15180eb36bd7d (diff) |
ui.components: fix ts types, move user pagination to user details
Diffstat (limited to 'ui/src/components/community.tsx')
-rw-r--r-- | ui/src/components/community.tsx | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index d7d08ee8..99b692ca 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -65,6 +65,18 @@ interface State { site: Site; } +interface CommunityProps { + dataType: DataType; + sort: SortType; + page: number; +} + +interface UrlParams { + dataType?: string; + sort?: string; + page?: number; +} + export class Community extends Component<any, State> { private subscription: Subscription; private emptyState: State = { @@ -143,7 +155,7 @@ export class Community extends Component<any, State> { this.subscription.unsubscribe(); } - static getDerivedStateFromProps(props) { + static getDerivedStateFromProps(props: any): CommunityProps { return { dataType: getDataTypeFromProps(props), sort: getSortTypeFromProps(props), @@ -151,7 +163,7 @@ export class Community extends Component<any, State> { }; } - componentDidUpdate(_, lastState) { + componentDidUpdate(_: any, lastState: State) { if ( lastState.dataType !== this.state.dataType || lastState.sort !== this.state.sort || @@ -293,17 +305,13 @@ export class Community extends Component<any, State> { } handleDataTypeChange(val: DataType) { - this.updateUrl({ data_type: DataType[val].toLowerCase(), page: 1 }); + this.updateUrl({ dataType: DataType[val].toLowerCase(), page: 1 }); window.scrollTo(0, 0); } - updateUrl(paramUpdates: { - data_type?: string; - sort?: string; - page?: number; - }) { + updateUrl(paramUpdates: UrlParams) { const dataTypeStr = - paramUpdates.data_type || DataType[this.state.dataType].toLowerCase(); + paramUpdates.dataType || DataType[this.state.dataType].toLowerCase(); const sortStr = paramUpdates.sort || SortType[this.state.sort].toLowerCase(); const page = paramUpdates.page || this.state.page; |