From: Dessalines Date: Thu, 3 Sep 2020 13:58:33 +0000 (-0400) Subject: Local timeline (#1111) X-Git-Url: http://these/git/%22https:/image.com/readmes/static/%22%7B%7D/%22?a=commitdiff_plain;h=2aaf4228ac958739abb0c9cb29d00fbb4f80b556;p=lemmy.git Local timeline (#1111) * Adding a local filter. Fixes #1103 * Not showing local if there are no federated instances. --- diff --git a/server/lemmy_db/src/comment_view.rs b/server/lemmy_db/src/comment_view.rs index 1dcdf193..a1751ca6 100644 --- a/server/lemmy_db/src/comment_view.rs +++ b/server/lemmy_db/src/comment_view.rs @@ -241,9 +241,11 @@ impl<'a> CommentQueryBuilder<'a> { query = query.filter(content.ilike(fuzzy_search(&search_term))); }; - if let ListingType::Subscribed = self.listing_type { - query = query.filter(subscribed.eq(true)); - } + query = match self.listing_type { + ListingType::Subscribed => query.filter(subscribed.eq(true)), + ListingType::Local => query.filter(community_local.eq(true)), + _ => query, + }; if self.saved_only { query = query.filter(saved.eq(true)); diff --git a/server/lemmy_db/src/lib.rs b/server/lemmy_db/src/lib.rs index bf7d00ca..4a4748ce 100644 --- a/server/lemmy_db/src/lib.rs +++ b/server/lemmy_db/src/lib.rs @@ -147,6 +147,7 @@ pub enum SortType { #[derive(EnumString, ToString, Debug, Serialize, Deserialize)] pub enum ListingType { All, + Local, Subscribed, Community, } diff --git a/server/lemmy_db/src/post_view.rs b/server/lemmy_db/src/post_view.rs index d7925383..eb2429c6 100644 --- a/server/lemmy_db/src/post_view.rs +++ b/server/lemmy_db/src/post_view.rs @@ -267,9 +267,11 @@ impl<'a> PostQueryBuilder<'a> { let mut query = self.query; - if let ListingType::Subscribed = self.listing_type { - query = query.filter(subscribed.eq(true)); - } + query = match self.listing_type { + ListingType::Subscribed => query.filter(subscribed.eq(true)), + ListingType::Local => query.filter(community_local.eq(true)), + _ => query, + }; if let Some(for_community_id) = self.for_community_id { query = query.filter(community_id.eq(for_community_id)); diff --git a/ui/package.json b/ui/package.json index f50f061f..76920d18 100644 --- a/ui/package.json +++ b/ui/package.json @@ -37,7 +37,7 @@ "inferno-router": "^7.4.2", "js-cookie": "^2.2.0", "jwt-decode": "^2.2.0", - "lemmy-js-client": "^1.0.8", + "lemmy-js-client": "^1.0.9", "markdown-it": "^11.0.0", "markdown-it-container": "^3.0.0", "markdown-it-emoji": "^1.4.0", diff --git a/ui/src/components/listing-type-select.tsx b/ui/src/components/listing-type-select.tsx index 3d12d434..f7d8cc3b 100644 --- a/ui/src/components/listing-type-select.tsx +++ b/ui/src/components/listing-type-select.tsx @@ -6,6 +6,7 @@ import { i18n } from '../i18next'; interface ListingTypeSelectProps { type_: ListingType; + showLocal?: boolean; onChange?(val: ListingType): any; } @@ -31,6 +32,7 @@ export class ListingTypeSelect extends Component< static getDerivedStateFromProps(props: any): ListingTypeSelectProps { return { type_: props.type_, + showLocal: props.showLocal, }; } @@ -53,6 +55,22 @@ export class ListingTypeSelect extends Component< /> {i18n.t('subscribed')} + {this.props.showLocal && ( + + )}