From 9e3ce8f4cbfbc60ae850c018f2b7bcfe677f9fed Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 31 Aug 2020 16:42:54 -0500 Subject: [PATCH] Adding a local filter. Fixes #1103 --- server/lemmy_db/src/comment_view.rs | 8 +++++--- server/lemmy_db/src/lib.rs | 1 + server/lemmy_db/src/post_view.rs | 8 +++++--- ui/package.json | 2 +- ui/src/components/listing-type-select.tsx | 14 ++++++++++++++ ui/translations/en.json | 1 + ui/yarn.lock | 13 +++++++++---- 7 files changed, 36 insertions(+), 11 deletions(-) diff --git a/server/lemmy_db/src/comment_view.rs b/server/lemmy_db/src/comment_view.rs index 1dcdf1934..a1751ca67 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 a5805ef95..ee1ae2dcd 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 d79253836..eb2429c6f 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 f50f061f1..76920d184 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 3d12d4343..1e4f99d60 100644 --- a/ui/src/components/listing-type-select.tsx +++ b/ui/src/components/listing-type-select.tsx @@ -67,6 +67,20 @@ export class ListingTypeSelect extends Component< /> {i18n.t('all')} + ); } diff --git a/ui/translations/en.json b/ui/translations/en.json index de1fc8268..e7aa4b315 100644 --- a/ui/translations/en.json +++ b/ui/translations/en.json @@ -139,6 +139,7 @@ "month": "Month", "year": "Year", "all": "All", + "local": "Local", "top": "Top", "api": "API", "docs": "Docs", diff --git a/ui/yarn.lock b/ui/yarn.lock index a474636ed..b50cf0782 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -4938,10 +4938,10 @@ lego-api@^1.0.7: dependencies: chain-able "^3.0.0" -lemmy-js-client@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.8.tgz#98e34c8e3cd07427f883f60fad376dc4d6f46e7f" - integrity sha512-YZxD3+8RGz7cRKdI8EIe5iQqQIMm5WzdNz6zZ7/CdkMtXUv6YuMOEv8HLTvBoGuaWIJwlMJ+23NIarxlT26IEw== +lemmy-js-client@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.9.tgz#23cab713613612a524085d6bb3fc1d4042d262a8" + integrity sha512-QJc4d1HkSxjv555yH3MAOYbTfgbhmmvvuC1uhFvPwBlL5B5MTry/fWPRbtLfkYTxdZWftE+PYvLVKPr3/dFmxw== leven@^3.1.0: version "3.1.0" @@ -7017,6 +7017,11 @@ regexpu-core@^4.1.3: unicode-match-property-ecmascript "^1.0.4" unicode-match-property-value-ecmascript "^1.2.0" +register-service-worker@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/register-service-worker/-/register-service-worker-1.7.1.tgz#6308347ac6c0af0f6c0b22ea5d59d25e836bc932" + integrity sha512-IdTfUZ4u8iJL8o1w8es8l6UMGPmkwHolUdT+UmM1UypC80IB4KbpuIlvwWVj8UDS7eJwkEYRcKRgfRX+oTmJsw== + registry-auth-token@^3.0.1: version "3.4.0" resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e"