Mark all read on an OPML subscription
Marking the subscription read did nothing: its own row holds no entries. read-all now resolves the feeds grouped under the id -- via subscriptions(), so a child promoted to config is included -- and marks those. Button sits before Unsubscribe, where every other feed keeps it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AdXho5tTkjFLeUXKbEjKBh
This commit is contained in:
10
src/db.rs
10
src/db.rs
@@ -681,9 +681,15 @@ impl Db {
|
||||
}
|
||||
|
||||
/// Marks every entry in a feed read, for the "mark all read" button.
|
||||
pub fn mark_all_read(&self, feed_id: &str) -> Result<usize> {
|
||||
/// Marks every entry of the given feeds read. Takes a list because an OPML subscription
|
||||
/// holds no entries itself -- marking it read means the feeds inside it.
|
||||
pub fn mark_all_read(&self, feed_ids: &[String]) -> Result<usize> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
Ok(conn.execute("UPDATE entries SET read = 1 WHERE feed_id = ?1 AND read = 0", [feed_id])?)
|
||||
let mut n = 0;
|
||||
for id in feed_ids {
|
||||
n += conn.execute("UPDATE entries SET read = 1 WHERE feed_id = ?1 AND read = 0", [id])?;
|
||||
}
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
/// The next N enclosures with no file, newest entry first -- what "download latest"
|
||||
|
||||
10
src/web.rs
10
src/web.rs
@@ -660,7 +660,15 @@ async fn read_all(
|
||||
State(state): State<WebState>,
|
||||
Path(id): Path<String>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let n = state.ctx.db.mark_all_read(&id)?;
|
||||
// A subscription's own row has no entries, so marking it read means everything under it.
|
||||
let mut ids = vec![id.clone()];
|
||||
ids.extend(
|
||||
crate::subscriptions(&state.ctx)?
|
||||
.into_iter()
|
||||
.filter(|s| s.cfg.group.as_deref() == Some(id.as_str()))
|
||||
.map(|s| s.id),
|
||||
);
|
||||
let n = state.ctx.db.mark_all_read(&ids)?;
|
||||
Ok(Json(serde_json::json!({ "marked": n })))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user