mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-13 06:08:20 +00:00
Merge branch 'main' into enable_private_messages_setting
This commit is contained in:
commit
d0a4e3d698
|
@ -83,7 +83,7 @@ export const fetchFunction = fetch;
|
||||||
export const imageFetchLimit = 50;
|
export const imageFetchLimit = 50;
|
||||||
export const sampleImage =
|
export const sampleImage =
|
||||||
"https://i.pinimg.com/originals/df/5f/5b/df5f5b1b174a2b4b6026cc6c8f9395c1.jpg";
|
"https://i.pinimg.com/originals/df/5f/5b/df5f5b1b174a2b4b6026cc6c8f9395c1.jpg";
|
||||||
export const sampleSite = "https://yahoo.com";
|
export const sampleSite = "https://google.com";
|
||||||
|
|
||||||
export const alphaUrl = "http://127.0.0.1:8541";
|
export const alphaUrl = "http://127.0.0.1:8541";
|
||||||
export const betaUrl = "http://127.0.0.1:8551";
|
export const betaUrl = "http://127.0.0.1:8551";
|
||||||
|
|
|
@ -85,6 +85,8 @@ pub struct GetPosts {
|
||||||
pub show_read: Option<bool>,
|
pub show_read: Option<bool>,
|
||||||
/// If true, then show the nsfw posts (even if your user setting is to hide them)
|
/// If true, then show the nsfw posts (even if your user setting is to hide them)
|
||||||
pub show_nsfw: Option<bool>,
|
pub show_nsfw: Option<bool>,
|
||||||
|
/// If true, then only show posts with no comments
|
||||||
|
pub no_comments_only: Option<bool>,
|
||||||
pub page_cursor: Option<PaginationCursor>,
|
pub page_cursor: Option<PaginationCursor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub async fn list_posts(
|
||||||
let show_hidden = data.show_hidden;
|
let show_hidden = data.show_hidden;
|
||||||
let show_read = data.show_read;
|
let show_read = data.show_read;
|
||||||
let show_nsfw = data.show_nsfw;
|
let show_nsfw = data.show_nsfw;
|
||||||
|
let no_comments_only = data.no_comments_only;
|
||||||
|
|
||||||
let liked_only = data.liked_only;
|
let liked_only = data.liked_only;
|
||||||
let disliked_only = data.disliked_only;
|
let disliked_only = data.disliked_only;
|
||||||
|
@ -82,6 +83,7 @@ pub async fn list_posts(
|
||||||
show_hidden,
|
show_hidden,
|
||||||
show_read,
|
show_read,
|
||||||
show_nsfw,
|
show_nsfw,
|
||||||
|
no_comments_only,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(&local_site.site, &mut context.pool())
|
.list(&local_site.site, &mut context.pool())
|
||||||
|
|
|
@ -401,6 +401,11 @@ fn queries<'a>() -> Queries<
|
||||||
query = query.filter(person::bot_account.eq(false));
|
query = query.filter(person::bot_account.eq(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Filter to show only posts with no comments
|
||||||
|
if options.no_comments_only.unwrap_or_default() {
|
||||||
|
query = query.filter(post_aggregates::comments.eq(0));
|
||||||
|
};
|
||||||
|
|
||||||
// If its saved only, then filter, and order by the saved time, not the comment creation time.
|
// If its saved only, then filter, and order by the saved time, not the comment creation time.
|
||||||
if options.saved_only.unwrap_or_default() {
|
if options.saved_only.unwrap_or_default() {
|
||||||
query = query
|
query = query
|
||||||
|
@ -617,6 +622,7 @@ pub struct PostQuery<'a> {
|
||||||
pub show_hidden: Option<bool>,
|
pub show_hidden: Option<bool>,
|
||||||
pub show_read: Option<bool>,
|
pub show_read: Option<bool>,
|
||||||
pub show_nsfw: Option<bool>,
|
pub show_nsfw: Option<bool>,
|
||||||
|
pub no_comments_only: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PostQuery<'a> {
|
impl<'a> PostQuery<'a> {
|
||||||
|
@ -1988,4 +1994,34 @@ mod tests {
|
||||||
|
|
||||||
cleanup(data, pool).await
|
cleanup(data, pool).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
|
async fn post_listings_no_comments_only() -> LemmyResult<()> {
|
||||||
|
let pool = &build_db_pool().await?;
|
||||||
|
let pool = &mut pool.into();
|
||||||
|
let data = init_data(pool).await?;
|
||||||
|
|
||||||
|
// Create a comment for a post
|
||||||
|
let comment_form = CommentInsertForm::new(
|
||||||
|
data.local_user_view.person.id,
|
||||||
|
data.inserted_post.id,
|
||||||
|
"a comment".to_owned(),
|
||||||
|
);
|
||||||
|
Comment::create(pool, &comment_form, None).await?;
|
||||||
|
|
||||||
|
// Make sure it doesnt come back with the no_comments option
|
||||||
|
let post_listings_no_comments = PostQuery {
|
||||||
|
sort: Some(PostSortType::New),
|
||||||
|
no_comments_only: Some(true),
|
||||||
|
local_user: Some(&data.local_user_view.local_user),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.list(&data.site, pool)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
assert_eq!(vec![POST_BY_BOT], names(&post_listings_no_comments));
|
||||||
|
|
||||||
|
cleanup(data, pool).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue