mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-23 03:11:25 +00:00
Merge pull request #344 from LemmyNet/fix/add_communities_listing_type_filter
Fix/add communities listing type filter
This commit is contained in:
commit
d964bd3d1f
3 changed files with 11 additions and 9 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 6baf8609698c19f698d3056a3d804cb2ae6eddb4
|
||||
Subproject commit e34e6fc90f5702683870ab548ebe98a29c70abb3
|
|
@ -13,10 +13,10 @@ import {
|
|||
import { Subscription } from "rxjs";
|
||||
import { InitialFetchRequest } from "shared/interfaces";
|
||||
import { i18n } from "../../i18next";
|
||||
import { UserService, WebSocketService } from "../../services";
|
||||
import { WebSocketService } from "../../services";
|
||||
import {
|
||||
authField,
|
||||
getListingTypeFromProps,
|
||||
getListingTypeFromPropsNoDefault,
|
||||
getPageFromProps,
|
||||
isBrowser,
|
||||
setIsoData,
|
||||
|
@ -57,7 +57,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
|||
communities: [],
|
||||
loading: true,
|
||||
page: getPageFromProps(this.props),
|
||||
listingType: getListingTypeFromProps(this.props),
|
||||
listingType: getListingTypeFromPropsNoDefault(this.props),
|
||||
site_view: this.isoData.site_res.site_view,
|
||||
searchText: "",
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
|||
|
||||
static getDerivedStateFromProps(props: any): CommunitiesProps {
|
||||
return {
|
||||
listingType: getListingTypeFromProps(props),
|
||||
listingType: getListingTypeFromPropsNoDefault(props),
|
||||
page: getPageFromProps(props),
|
||||
};
|
||||
}
|
||||
|
@ -298,10 +298,6 @@ export class Communities extends Component<any, CommunitiesState> {
|
|||
let pathSplit = req.path.split("/");
|
||||
let type_: ListingType = pathSplit[3]
|
||||
? ListingType[pathSplit[3]]
|
||||
: UserService.Instance.localUserView
|
||||
? Object.values(ListingType)[
|
||||
UserService.Instance.localUserView.local_user.default_listing_type
|
||||
]
|
||||
: ListingType.Local;
|
||||
let page = pathSplit[5] ? Number(pathSplit[5]) : 1;
|
||||
let listCommunitiesForm: ListCommunities = {
|
||||
|
|
|
@ -854,6 +854,12 @@ export function getListingTypeFromProps(props: any): ListingType {
|
|||
: ListingType.Local;
|
||||
}
|
||||
|
||||
export function getListingTypeFromPropsNoDefault(props: any): ListingType {
|
||||
return props.match.params.listing_type
|
||||
? routeListingTypeToEnum(props.match.params.listing_type)
|
||||
: ListingType.Local;
|
||||
}
|
||||
|
||||
// TODO might need to add a user setting for this too
|
||||
export function getDataTypeFromProps(props: any): DataType {
|
||||
return props.match.params.data_type
|
||||
|
|
Loading…
Reference in a new issue