]> Untitled Git - lemmy-ui.git/commitdiff
Make /c/local the default for not-logged-in users. Fixes #52
authorDessalines <tyhou13@gmx.com>
Mon, 5 Oct 2020 02:11:48 +0000 (21:11 -0500)
committerDessalines <tyhou13@gmx.com>
Mon, 5 Oct 2020 02:11:48 +0000 (21:11 -0500)
src/shared/components/listing-type-select.tsx
src/shared/components/main.tsx
src/shared/utils.ts

index f7d8cc3b2acd477eb6bff1bb8d8f42c9200ab816..89ec0b9fd2498ef7e114b8b2830a138af84a2b3b 100644 (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
index e83e7056e79022a972f72ba3af223aa3ffd8d51b..149f9790874be2dabc87379ab12f3a5e1a4b0f2b 100644 (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 &&
index 9d4725b6950e37f5b05370717e2a1d5b790ba56c..b3479d3b6e06456a6d35c9a6bb188e5da5e8dbb1 100644 (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