mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
make item id optional as queued for database insert, rename item constructor, add comments
This commit is contained in:
parent
841bb171bd
commit
0bd7131937
2 changed files with 12 additions and 4 deletions
|
|
@ -30,7 +30,7 @@ impl History {
|
|||
pub fn open(&self, request: GString, title: Option<GString>) {
|
||||
let mut memory = self.memory.borrow_mut();
|
||||
if !memory.open(&request) {
|
||||
memory.add(Item::create(0, request, title)) // @TODO
|
||||
memory.add(Item::init(request, title))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,27 @@ use gtk::glib::{DateTime, GString};
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct Item {
|
||||
pub id: i64,
|
||||
/// Queued for DB insert on value is `None` (e.g. on app close)
|
||||
pub id: Option<i64>,
|
||||
/// The value for navigation request entry
|
||||
pub request: GString,
|
||||
/// Some history items may contain title (e.g. gemtext documents and system tabs)
|
||||
/// * used as the additional criteria for search in the navbar suggestions widget
|
||||
pub title: Option<GString>,
|
||||
/// Collect opened count with event time
|
||||
/// * used for sort order search results in the navbar suggestions widget
|
||||
pub opened: Vec<DateTime>,
|
||||
/// Collect tab closed count with event time
|
||||
/// * used in recently closed pages menu
|
||||
pub closed: Vec<DateTime>,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
// Constructors
|
||||
|
||||
pub fn create(id: i64, request: GString, title: Option<GString>) -> Self {
|
||||
pub fn init(request: GString, title: Option<GString>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
id: None,
|
||||
request,
|
||||
title,
|
||||
opened: vec![now()],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue