diff --git a/core/src/local/store.rs b/core/src/local/store.rs index 2a7d175..060ae79 100644 --- a/core/src/local/store.rs +++ b/core/src/local/store.rs @@ -452,15 +452,14 @@ pub fn get_note(conn: &Connection, id: &str) -> rusqlite::Result { load_note(conn, id) } +/// Which notes' reminders are this device's to fire: the owner's, out of the trash. +/// A note shared with us neither alerts us nor is ours to clear, the same as on the +/// server. +const OWN_REMINDERS: &str = "trashed = 0 AND remind_at IS NOT NULL AND permission = 'owner'"; + pub fn reminders(conn: &Connection) -> rusqlite::Result> { - // The owner's reminders: a note shared with us neither alerts us nor is ours to - // clear, the same as on the server. - notes_where( - conn, - "SELECT id FROM notes WHERE trashed = 0 AND remind_at IS NOT NULL AND permission = 'owner' - ORDER BY remind_at ASC", - [], - ) + let sql = format!("SELECT id FROM notes WHERE {OWN_REMINDERS} ORDER BY remind_at ASC"); + notes_where(conn, &sql, []) } /// Reminders due at or before `now_ms`, soonest first, trash excluded. @@ -470,11 +469,9 @@ pub fn reminders(conn: &Connection) -> rusqlite::Result> { /// parse is left out: it can never come due, and announcing it would be a guess. pub fn due_reminders(conn: &Connection, now_ms: i64) -> rusqlite::Result> { let set: Vec<(String, String)> = { - let mut stmt = conn.prepare( - "SELECT id, remind_at FROM notes - WHERE trashed = 0 AND remind_at IS NOT NULL AND permission = 'owner' - ORDER BY remind_at ASC", - )?; + let mut stmt = conn.prepare(&format!( + "SELECT id, remind_at FROM notes WHERE {OWN_REMINDERS} ORDER BY remind_at ASC" + ))?; let rows = stmt.query_map([], |r| Ok((r.get(0)?, r.get(1)?)))?; rows.collect::>()? };