mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
draft bookmark toggle action
This commit is contained in:
parent
feca899c5b
commit
232f67b9cc
4 changed files with 49 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue