mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
Changing unwrap_default to unwrap_or(false)
This commit is contained in:
parent
ed31deab00
commit
6d3778cafe
8 changed files with 11 additions and 19 deletions
|
@ -171,7 +171,7 @@ impl Perform for BanFromCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove/Restore their data if that's desired
|
// Remove/Restore their data if that's desired
|
||||||
if data.remove_data.unwrap_or_default() {
|
if data.remove_data.unwrap_or(false) {
|
||||||
// Posts
|
// Posts
|
||||||
blocking(context.pool(), move |conn: &'_ _| {
|
blocking(context.pool(), move |conn: &'_ _| {
|
||||||
Post::update_removed_for_creator(conn, banned_person_id, Some(community_id), true)
|
Post::update_removed_for_creator(conn, banned_person_id, Some(community_id), true)
|
||||||
|
|
|
@ -397,7 +397,7 @@ impl Perform for BanPerson {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove their data if that's desired
|
// Remove their data if that's desired
|
||||||
if data.remove_data.unwrap_or_default() {
|
if data.remove_data.unwrap_or(false) {
|
||||||
// Posts
|
// Posts
|
||||||
blocking(context.pool(), move |conn: &'_ _| {
|
blocking(context.pool(), move |conn: &'_ _| {
|
||||||
Post::update_removed_for_creator(conn, banned_person_id, None, true)
|
Post::update_removed_for_creator(conn, banned_person_id, None, true)
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl PerformCrud for GetPersonDetails {
|
||||||
|
|
||||||
// If its saved only, you don't care what creator it was
|
// If its saved only, you don't care what creator it was
|
||||||
// Or, if its not saved, then you only want it for that specific creator
|
// Or, if its not saved, then you only want it for that specific creator
|
||||||
if !saved_only.unwrap_or_default() {
|
if !saved_only.unwrap_or(false) {
|
||||||
posts_query = posts_query.creator_id(person_details_id);
|
posts_query = posts_query.creator_id(person_details_id);
|
||||||
comments_query = comments_query.creator_id(person_details_id);
|
comments_query = comments_query.creator_id(person_details_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,13 +196,7 @@ pub enum SearchType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_opt_str_to_opt_enum<T: std::str::FromStr>(opt: &Option<String>) -> Option<T> {
|
pub fn from_opt_str_to_opt_enum<T: std::str::FromStr>(opt: &Option<String>) -> Option<T> {
|
||||||
match opt {
|
opt.as_ref().map(|t| T::from_str(t).ok()).flatten()
|
||||||
Some(t) => match T::from_str(&t) {
|
|
||||||
Ok(r) => Some(r),
|
|
||||||
Err(_) => None,
|
|
||||||
},
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fuzzy_search(q: &str) -> String {
|
pub fn fuzzy_search(q: &str) -> String {
|
||||||
|
|
|
@ -350,7 +350,7 @@ impl<'a> CommentQueryBuilder<'a> {
|
||||||
.filter(comment::removed.eq(false));
|
.filter(comment::removed.eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.unread_only.unwrap_or_default() {
|
if self.unread_only.unwrap_or(false) {
|
||||||
query = query.filter(comment::read.eq(false));
|
query = query.filter(comment::read.eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,14 +378,13 @@ impl<'a> CommentQueryBuilder<'a> {
|
||||||
|
|
||||||
if let Some(listing_type) = self.listing_type {
|
if let Some(listing_type) = self.listing_type {
|
||||||
query = match listing_type {
|
query = match listing_type {
|
||||||
// ListingType::Subscribed => query.filter(community_follower::subscribed.eq(true)),
|
|
||||||
ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()), // TODO could be this: and(community_follower::person_id.eq(person_id_join)),
|
ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()), // TODO could be this: and(community_follower::person_id.eq(person_id_join)),
|
||||||
ListingType::Local => query.filter(community::local.eq(true)),
|
ListingType::Local => query.filter(community::local.eq(true)),
|
||||||
_ => query,
|
_ => query,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.saved_only.unwrap_or_default() {
|
if self.saved_only.unwrap_or(false) {
|
||||||
query = query.filter(comment_saved::id.is_not_null());
|
query = query.filter(comment_saved::id.is_not_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ impl<'a> PostQueryBuilder<'a> {
|
||||||
|
|
||||||
if let Some(listing_type) = self.listing_type {
|
if let Some(listing_type) = self.listing_type {
|
||||||
query = match listing_type {
|
query = match listing_type {
|
||||||
ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()), // TODO could be this: and(community_follower::person_id.eq(person_id_join)),
|
ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()),
|
||||||
ListingType::Local => query.filter(community::local.eq(true)),
|
ListingType::Local => query.filter(community::local.eq(true)),
|
||||||
_ => query,
|
_ => query,
|
||||||
};
|
};
|
||||||
|
@ -364,12 +364,11 @@ impl<'a> PostQueryBuilder<'a> {
|
||||||
query = query.filter(person::bot_account.eq(false));
|
query = query.filter(person::bot_account.eq(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO These two might be wrong
|
if self.saved_only.unwrap_or(false) {
|
||||||
if self.saved_only.unwrap_or_default() {
|
|
||||||
query = query.filter(post_saved::id.is_not_null());
|
query = query.filter(post_saved::id.is_not_null());
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.unread_only.unwrap_or_default() {
|
if self.unread_only.unwrap_or(false) {
|
||||||
query = query.filter(post_read::id.is_not_null());
|
query = query.filter(post_read::id.is_not_null());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl<'a> PrivateMessageQueryBuilder<'a> {
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
// If its unread, I only want the ones to me
|
// If its unread, I only want the ones to me
|
||||||
if self.unread_only.unwrap_or_default() {
|
if self.unread_only.unwrap_or(false) {
|
||||||
query = query
|
query = query
|
||||||
.filter(private_message::read.eq(false))
|
.filter(private_message::read.eq(false))
|
||||||
.filter(private_message::recipient_id.eq(self.recipient_id));
|
.filter(private_message::recipient_id.eq(self.recipient_id));
|
||||||
|
|
|
@ -264,7 +264,7 @@ impl<'a> PersonMentionQueryBuilder<'a> {
|
||||||
query = query.filter(person_mention::recipient_id.eq(recipient_id));
|
query = query.filter(person_mention::recipient_id.eq(recipient_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.unread_only.unwrap_or_default() {
|
if self.unread_only.unwrap_or(false) {
|
||||||
query = query.filter(person_mention::read.eq(false));
|
query = query.filter(person_mention::read.eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue