quote chronological cursor scroll, icon

This commit is contained in:
2026-04-08 03:01:52 +02:00
parent d56fcc3f4c
commit f2eab97c15
4 changed files with 50 additions and 11 deletions

View File

@@ -113,6 +113,24 @@ impl Quote {
None => Ok(None),
}
}
pub fn get_chronological_cursorscroll(
conn: &Connection,
cursor: Option<Uuid>,
amount: i64,
) -> Result<Vec<Quote>, QuoteError> {
let ids = match cursor {
Some(c) => conn
.prepare("SELECT id FROM quotes WHERE id < ?1 ORDER BY id DESC LIMIT ?2")?
.query_map((c, amount), |r| r.get(0))?
.collect::<Result<Vec<Uuid>, _>>()?,
None => conn
.prepare("SELECT id FROM quotes ORDER BY id DESC LIMIT ?1")?
.query_map((amount,), |r| r.get(0))?
.collect::<Result<Vec<Uuid>, _>>()?,
};
ids.iter().map(|id| Self::get_by_id(conn, *id)).collect()
}
pub fn create(
conn: &Connection,
lines: Vec<(String, Name)>,