Make /c/local the default for not-logged-in users. Fixes #52

This commit is contained in:
Dessalines 2020-10-04 21:11:48 -05:00
parent 7b95c8e184
commit b74eecc724
3 changed files with 14 additions and 7 deletions

View file

@ -73,7 +73,10 @@ export class ListingTypeSelect extends Component<
)}
<label
className={`pointer btn btn-outline-secondary ${
this.state.type_ == ListingType.All && 'active'
(this.state.type_ == ListingType.All && 'active') ||
(!this.props.showLocal &&
this.state.type_ == ListingType.Local &&
'active')
}`}
>
<input

View file

@ -188,7 +188,7 @@ export class Main extends Component<any, MainState> {
? Object.values(ListingType)[
UserService.Instance.user.default_listing_type
]
: ListingType.All;
: ListingType.Local;
let sort: SortType = pathSplit[7]
? SortType[pathSplit[7]]
: UserService.Instance.user
@ -587,10 +587,7 @@ export class Main extends Component<any, MainState> {
<span class="mr-3">
<ListingTypeSelect
type_={this.state.listingType}
showLocal={
this.state.siteRes.federated_instances &&
this.state.siteRes.federated_instances.length > 0
}
showLocal={this.showLocal}
onChange={this.handleListingTypeChange}
/>
</span>
@ -649,6 +646,13 @@ export class Main extends Component<any, MainState> {
);
}
get showLocal(): boolean {
return (
this.isoData.site.federated_instances !== null &&
this.isoData.site.federated_instances.length > 0
);
}
get canAdmin(): boolean {
return (
UserService.Instance.user &&

View file

@ -817,7 +817,7 @@ export function getListingTypeFromProps(props: any): ListingType {
? routeListingTypeToEnum(props.match.params.listing_type)
: UserService.Instance.user
? Object.values(ListingType)[UserService.Instance.user.default_listing_type]
: ListingType.All;
: ListingType.Local;
}
// TODO might need to add a user setting for this too