mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-05-20 02:38:05 +00:00
Add ignore_page_limits for custom emojis
EmojiPicker needs to be able to retrieve all emojis in 1 call
This commit is contained in:
parent
999e9845e7
commit
1f629cc02d
|
@ -65,4 +65,5 @@ pub struct ListCustomEmojis {
|
|||
pub page: Option<i64>,
|
||||
pub limit: Option<i64>,
|
||||
pub category: Option<String>,
|
||||
pub ignore_page_limits: Option<bool>,
|
||||
}
|
||||
|
|
|
@ -12,8 +12,14 @@ pub async fn list_custom_emojis(
|
|||
local_user_view: Option<LocalUserView>,
|
||||
context: Data<LemmyContext>,
|
||||
) -> Result<Json<ListCustomEmojisResponse>, LemmyError> {
|
||||
let custom_emojis =
|
||||
CustomEmojiView::list(&mut context.pool(), &data.category, data.page, data.limit).await?;
|
||||
let custom_emojis = CustomEmojiView::list(
|
||||
&mut context.pool(),
|
||||
&data.category,
|
||||
data.page,
|
||||
data.limit,
|
||||
data.ignore_page_limits.unwrap_or(false),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(ListCustomEmojisResponse { custom_emojis }))
|
||||
}
|
||||
|
|
|
@ -58,15 +58,21 @@ impl CustomEmojiView {
|
|||
category: &Option<String>,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
ignore_page_limits: bool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
|
||||
let mut query = custom_emoji::table
|
||||
.left_join(
|
||||
custom_emoji_keyword::table.on(custom_emoji_keyword::custom_emoji_id.eq(custom_emoji::id)),
|
||||
)
|
||||
.into_boxed();
|
||||
|
||||
if !ignore_page_limits {
|
||||
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||
query = query.limit(limit).offset(offset);
|
||||
}
|
||||
|
||||
if let Some(category) = category {
|
||||
query = query.filter(custom_emoji::category.eq(category))
|
||||
}
|
||||
|
@ -78,8 +84,6 @@ impl CustomEmojiView {
|
|||
custom_emoji::all_columns,
|
||||
custom_emoji_keyword::all_columns.nullable(), // (or all the columns if you want)
|
||||
))
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.load::<CustomEmojiTuple>(conn)
|
||||
.await?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue