import { Component, linkEvent } from "inferno"; import { ListingType } from "lemmy-js-client"; import { i18n } from "../../i18next"; import { UserService } from "../../services"; import { randomStr } from "../../utils"; interface ListingTypeSelectProps { type_: ListingType; showLocal: boolean; showSubscribed: boolean; onChange(val: ListingType): void; } interface ListingTypeSelectState { type_: ListingType; } export class ListingTypeSelect extends Component< ListingTypeSelectProps, ListingTypeSelectState > { private id = `listing-type-input-${randomStr()}`; state: ListingTypeSelectState = { type_: this.props.type_, }; constructor(props: any, context: any) { super(props, context); } static getDerivedStateFromProps( props: ListingTypeSelectProps ): ListingTypeSelectState { return { type_: props.type_, }; } render() { return (
{this.props.showSubscribed && ( )} {this.props.showLocal && ( )}
); } handleTypeChange(i: ListingTypeSelect, event: any) { i.props.onChange(event.target.value); } }