From: jcgurango Date: Tue, 4 Jul 2023 21:06:34 +0000 (+0800) Subject: Fix home page not using site-level listing type #1612 (#1778) X-Git-Url: http://these/git/%22https:/image.com/README.zh.hans.md?a=commitdiff_plain;h=26ff0f7e06bf32024161a60a5503e1a041ab778c;p=lemmy-ui.git Fix home page not using site-level listing type #1612 (#1778) * Fix home page not using site-level listing type * Use null handling instead --- diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 5e73367..741dfa5 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -114,7 +114,7 @@ interface HomeState { } interface HomeProps { - listingType: ListingType; + listingType?: ListingType; dataType: DataType; sort: SortType; page: number; @@ -163,12 +163,12 @@ function getDataTypeFromQuery(type?: string): DataType { 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 { @@ -311,11 +311,12 @@ export class Home extends Component { client, auth, query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort }, + site, }: InitialFetchRequest>): Promise { 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; @@ -761,7 +762,10 @@ export class Home extends Component {
{
-
{getRss(listingType)}
+
+ {getRss( + listingType ?? + this.state.siteRes.site_view.local_site.default_post_listing_type + )} +
); }