mirror of https://github.com/LemmyNet/lemmy
Merge branch 'dev'
commit
088f47c611
@ -0,0 +1,2 @@
|
||||
alter table user_ drop column default_sort_type;
|
||||
alter table user_ drop column default_listing_type;
|
@ -0,0 +1,2 @@
|
||||
alter table user_ add column default_sort_type smallint default 0 not null;
|
||||
alter table user_ add column default_listing_type smallint default 1 not null;
|
@ -0,0 +1,68 @@
|
||||
import { Component, linkEvent } from 'inferno';
|
||||
import { ListingType } from '../interfaces';
|
||||
import { UserService } from '../services';
|
||||
|
||||
import { i18n } from '../i18next';
|
||||
|
||||
interface ListingTypeSelectProps {
|
||||
type_: ListingType;
|
||||
onChange?(val: ListingType): any;
|
||||
}
|
||||
|
||||
interface ListingTypeSelectState {
|
||||
type_: ListingType;
|
||||
}
|
||||
|
||||
export class ListingTypeSelect extends Component<
|
||||
ListingTypeSelectProps,
|
||||
ListingTypeSelectState
|
||||
> {
|
||||
private emptyState: ListingTypeSelectState = {
|
||||
type_: this.props.type_,
|
||||
};
|
||||
|
||||
constructor(props: any, context: any) {
|
||||
super(props, context);
|
||||
this.state = this.emptyState;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div class="btn-group btn-group-toggle">
|
||||
<label
|
||||
className={`btn btn-sm btn-secondary
|
||||
${this.state.type_ == ListingType.Subscribed && 'active'}
|
||||
${UserService.Instance.user == undefined ? 'disabled' : 'pointer'}
|
||||
`}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
value={ListingType.Subscribed}
|
||||
checked={this.state.type_ == ListingType.Subscribed}
|
||||
onChange={linkEvent(this, this.handleTypeChange)}
|
||||
disabled={UserService.Instance.user == undefined}
|
||||
/>
|
||||
{i18n.t('subscribed')}
|
||||
</label>
|
||||
<label
|
||||
className={`pointer btn btn-sm btn-secondary ${this.state.type_ ==
|
||||
ListingType.All && 'active'}`}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
value={ListingType.All}
|
||||
checked={this.state.type_ == ListingType.All}
|
||||
onChange={linkEvent(this, this.handleTypeChange)}
|
||||
/>
|
||||
{i18n.t('all')}
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
handleTypeChange(i: ListingTypeSelect, event: any) {
|
||||
i.state.type_ = Number(event.target.value);
|
||||
i.setState(i.state);
|
||||
i.props.onChange(i.state.type_);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
import { Component, linkEvent } from 'inferno';
|
||||
import { SortType } from '../interfaces';
|
||||
|
||||
import { T } from 'inferno-i18next';
|
||||
|
||||
interface SortSelectProps {
|
||||
sort: SortType;
|
||||
onChange?(val: SortType): any;
|
||||
hideHot?: boolean;
|
||||
}
|
||||
|
||||
interface SortSelectState {
|
||||
sort: SortType;
|
||||
}
|
||||
|
||||
export class SortSelect extends Component<SortSelectProps, SortSelectState> {
|
||||
private emptyState: SortSelectState = {
|
||||
sort: this.props.sort,
|
||||
};
|
||||
|
||||
constructor(props: any, context: any) {
|
||||
super(props, context);
|
||||
this.state = this.emptyState;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<select
|
||||
value={this.state.sort}
|
||||
onChange={linkEvent(this, this.handleSortChange)}
|
||||
class="custom-select custom-select-sm w-auto"
|
||||
>
|
||||
<option disabled>
|
||||
<T i18nKey="sort_type">#</T>
|
||||
</option>
|
||||
{!this.props.hideHot && (
|
||||
<option value={SortType.Hot}>
|
||||
<T i18nKey="hot">#</T>
|
||||
</option>
|
||||
)}
|
||||
<option value={SortType.New}>
|
||||
<T i18nKey="new">#</T>
|
||||
</option>
|
||||
<option disabled>─────</option>
|
||||
<option value={SortType.TopDay}>
|
||||
<T i18nKey="top_day">#</T>
|
||||
</option>
|
||||
<option value={SortType.TopWeek}>
|
||||
<T i18nKey="week">#</T>
|
||||
</option>
|
||||
<option value={SortType.TopMonth}>
|
||||
<T i18nKey="month">#</T>
|
||||
</option>
|
||||
<option value={SortType.TopYear}>
|
||||
<T i18nKey="year">#</T>
|
||||
</option>
|
||||
<option value={SortType.TopAll}>
|
||||
<T i18nKey="all">#</T>
|
||||
</option>
|
||||
</select>
|
||||
);
|
||||
}
|
||||
|
||||
handleSortChange(i: SortSelect, event: any) {
|
||||
i.state.sort = Number(event.target.value);
|
||||
i.setState(i.state);
|
||||
i.props.onChange(i.state.sort);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue