support badge
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-set-overlay-icon",
|
||||
"opener:default",
|
||||
"notification:default"
|
||||
]
|
||||
|
||||
@@ -220,3 +220,10 @@ pub fn toggle_reminder(path: &str, id: i64, is_completed: bool) -> anyhow::Resul
|
||||
conn.execute("UPDATE reminders SET is_completed=?1 WHERE id=?2", params![is_completed, id])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_overdue_reminders_count(path: &str, date: &str, minute: i32) -> anyhow::Result<i32> {
|
||||
let conn = Connection::open(path)?;
|
||||
let mut stmt = conn.prepare("SELECT COUNT(*) FROM reminders WHERE is_completed = 0 AND (date < ?1 OR (date = ?1 AND minute < ?2))")?;
|
||||
let count: i32 = stmt.query_row(params![date, minute], |row| row.get(0))?;
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
@@ -100,6 +100,13 @@ pub fn toggle_reminder(state: tauri::State<'_, AppState>, id: i64, is_completed:
|
||||
crate::db::toggle_reminder(path, id, is_completed).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_overdue_reminders_count(state: tauri::State<'_, AppState>, date: String, minute: i32) -> Result<i32, String> {
|
||||
let path = state.db_path.lock().unwrap();
|
||||
let path = path.as_ref().ok_or("Database path not set")?;
|
||||
crate::db::get_overdue_reminders_count(path, &date, minute).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn update_interval(state: tauri::State<'_, AppState>, seconds: u64) {
|
||||
state.capture_interval_secs.store(seconds, Ordering::SeqCst);
|
||||
|
||||
@@ -36,6 +36,7 @@ pub fn run() {
|
||||
engine::save_reminder,
|
||||
engine::delete_reminder,
|
||||
engine::toggle_reminder,
|
||||
engine::get_overdue_reminders_count,
|
||||
engine::write_file
|
||||
])
|
||||
.setup(|app| {
|
||||
|
||||
Reference in New Issue
Block a user