diff --git a/src/app/browser/window/tab/item/page/navigation/request.rs b/src/app/browser/window/tab/item/page/navigation/request.rs index 26211bd2..3b2d8ae4 100644 --- a/src/app/browser/window/tab/item/page/navigation/request.rs +++ b/src/app/browser/window/tab/item/page/navigation/request.rs @@ -151,6 +151,7 @@ impl Request { transaction: &Transaction, app_browser_window_tab_item_page_navigation_id: &i64, ) -> Result<(), String> { + // Keep value in memory until operation complete let text = self.widget.text(); match Database::add( diff --git a/src/app/browser/window/tab/item/widget.rs b/src/app/browser/window/tab/item/widget.rs index 053d3a70..00c7dee4 100644 --- a/src/app/browser/window/tab/item/widget.rs +++ b/src/app/browser/window/tab/item/widget.rs @@ -93,10 +93,16 @@ impl Widget { transaction: &Transaction, app_browser_window_tab_item_id: &i64, ) -> Result<(), String> { + // Keep value in memory until operation complete + let title = self.gobject.title(); + match Database::add( transaction, app_browser_window_tab_item_id, - Some(&self.gobject.title().to_string()), + match title.is_empty() { + true => None, + false => Some(title.as_str()), + }, ) { Ok(_) => { // let id = Database::last_insert_id(transaction); diff --git a/src/app/browser/window/tab/item/widget/database.rs b/src/app/browser/window/tab/item/widget/database.rs index eeb108ce..617f3d4c 100644 --- a/src/app/browser/window/tab/item/widget/database.rs +++ b/src/app/browser/window/tab/item/widget/database.rs @@ -3,7 +3,7 @@ use sqlite::{Error, Transaction}; pub struct Table { pub id: i64, // pub app_browser_window_tab_item_id: i64, not in use - pub title: Option, + pub title: Option, // can be stored as NULL } pub struct Database { @@ -17,7 +17,7 @@ impl Database { ( `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `app_browser_window_tab_item_id` INTEGER NOT NULL, - `title` TEXT + `title` VARCHAR(1024) )", [], ) @@ -26,7 +26,7 @@ impl Database { pub fn add( tx: &Transaction, app_browser_window_tab_item_id: &i64, - title: Option<&String>, + title: Option<&str>, ) -> Result { tx.execute( "INSERT INTO `app_browser_window_tab_item_widget` (