draft bookmark toggle action

This commit is contained in:
yggverse 2024-11-14 09:30:40 +02:00
parent feca899c5b
commit 232f67b9cc
4 changed files with 49 additions and 5 deletions

View file

@ -4,12 +4,13 @@ mod memory;
use database::Database;
use memory::Memory;
use gtk::glib::DateTime;
use sqlite::{Connection, Transaction};
use std::{rc::Rc, sync::RwLock};
pub struct Bookmark {
database: Rc<Database>,
memory: Rc<Memory>,
database: Rc<Database>, // permanent storage
memory: Rc<Memory>, // fast search index
}
impl Bookmark {
@ -43,7 +44,19 @@ impl Bookmark {
}
}
// @TODO add new record with index update
/// Toggle record in bookmarks database, update emory index
pub fn toggle(&self, request: &str) {
let time = DateTime::now_local().unwrap();
if self.has_request(request, false) {
// @TODO
} else {
match self.database.add(time.clone(), request.into()) {
Ok(_) => self.memory.set(request.into(), time),
Err(_) => todo!(),
};
}
}
}
// Tools