}
interface HomeProps {
- listingType: ListingType;
+ listingType?: ListingType;
dataType: DataType;
sort: SortType;
page: number;
return type ? DataType[type] : DataType.Post;
}
-function getListingTypeFromQuery(type?: string): ListingType {
+function getListingTypeFromQuery(type?: string): ListingType | undefined {
const myListingType =
UserService.Instance.myUserInfo?.local_user_view?.local_user
?.default_listing_type;
- return (type ? (type as ListingType) : myListingType) ?? "Local";
+ return type ? (type as ListingType) : myListingType;
}
function getSortTypeFromQuery(type?: string): SortType {
client,
auth,
query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
+ site,
}: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
const dataType = getDataTypeFromQuery(urlDataType);
-
- // TODO figure out auth default_listingType, default_sort_type
- const type_ = getListingTypeFromQuery(listingType);
+ const type_ =
+ getListingTypeFromQuery(listingType) ??
+ site.site_view.local_site.default_post_listing_type;
const sort = getSortTypeFromQuery(urlSort);
const page = urlPage ? Number(urlPage) : 1;
</div>
<div className="col-auto">
<ListingTypeSelect
- type_={listingType}
+ type_={
+ listingType ??
+ this.state.siteRes.site_view.local_site.default_post_listing_type
+ }
showLocal={showLocal(this.isoData)}
showSubscribed
onChange={this.handleListingTypeChange}
<div className="col-auto">
<SortSelect sort={sort} onChange={this.handleSortChange} />
</div>
- <div className="col-auto ps-0">{getRss(listingType)}</div>
+ <div className="col-auto ps-0">
+ {getRss(
+ listingType ??
+ this.state.siteRes.site_view.local_site.default_post_listing_type
+ )}
+ </div>
</div>
);
}