diff --git a/src/app.rs b/src/app.rs index 95136e66..93a419d3 100644 --- a/src/app.rs +++ b/src/app.rs @@ -115,7 +115,7 @@ impl App { match database.records() { Ok(records) => { for record in records { - browser.restore(record.id); + browser.restore(&record.id); } } Err(error) => panic!("{error}"), // @TODO @@ -138,10 +138,10 @@ impl App { Ok(records) => { // Cleanup previous session records for record in records { - match database.delete(record.id) { + match database.delete(&record.id) { Ok(_) => { // Delegate clean action to childs - browser.clean(record.id); + browser.clean(&record.id); } Err(error) => panic!("{error}"), // @TODO } @@ -151,7 +151,7 @@ impl App { match database.add() { Ok(_) => { // Delegate save action to childs - browser.save(database.last_insert_id()); + browser.save(&database.last_insert_id()); } Err(error) => panic!("{error}"), // @TODO } diff --git a/src/app/browser.rs b/src/app/browser.rs index 58df588f..24592b88 100644 --- a/src/app/browser.rs +++ b/src/app/browser.rs @@ -227,17 +227,17 @@ impl Browser { } // Actions - pub fn clean(&self, app_id: i64) { + pub fn clean(&self, app_id: &i64) { match self.database.records(app_id) { Ok(records) => { for record in records { - match self.database.delete(record.id) { + match self.database.delete(&record.id) { Ok(_) => { // Delegate clean action to childs // @TODO // self.header.clean(record.id); // self.main.clean(record.id); - self.widget.clean(record.id); + self.widget.clean(&record.id); } Err(error) => panic!("{error}"), // @TODO } @@ -247,11 +247,11 @@ impl Browser { } } - pub fn restore(&self, app_id: i64) { + pub fn restore(&self, app_id: &i64) { // @TODO } - pub fn save(&self, app_id: i64) { + pub fn save(&self, app_id: &i64) { match self.database.add(app_id) { Ok(_) => { // Delegate save action to childs @@ -259,7 +259,7 @@ impl Browser { // @TODO // self.header.save(id); // self.main.save(id); - self.widget.save(id); + self.widget.save(&id); } Err(error) => panic!("{error}"), // @TODO } diff --git a/src/app/browser/database.rs b/src/app/browser/database.rs index 5a6ddf56..0ad44ba4 100644 --- a/src/app/browser/database.rs +++ b/src/app/browser/database.rs @@ -24,12 +24,12 @@ impl Database { Ok(Self { connection }) } - pub fn add(&self, app_id: i64) -> Result { + pub fn add(&self, app_id: &i64) -> Result { self.connection .execute("INSERT INTO `app_browser` (`app_id`) VALUES (?)", [app_id]) } - pub fn records(&self, app_id: i64) -> Result, Error> { + pub fn records(&self, app_id: &i64) -> Result, Error> { let mut statement = self .connection .prepare("SELECT `id`, `app_id` WHERE `app_id` = ?")?; @@ -51,7 +51,7 @@ impl Database { Ok(records) } - pub fn delete(&self, id: i64) -> Result { + pub fn delete(&self, id: &i64) -> Result { self.connection .execute("DELETE FROM `app_browser` WHERE `id` = ?", [id]) } diff --git a/src/app/browser/widget.rs b/src/app/browser/widget.rs index 39d821ec..175428ec 100644 --- a/src/app/browser/widget.rs +++ b/src/app/browser/widget.rs @@ -45,11 +45,11 @@ impl Widget { } // Actions - pub fn clean(&self, app_browser_id: i64) { + pub fn clean(&self, app_browser_id: &i64) { match self.database.records(app_browser_id) { Ok(records) => { for record in records { - match self.database.delete(record.id) { + match self.database.delete(&record.id) { Ok(_) => { // Delegate clean action to childs // nothing yet.. @@ -66,12 +66,12 @@ impl Widget { // @TODO } - pub fn save(&self, app_browser_id: i64) { + pub fn save(&self, app_browser_id: &i64) { match self.database.add( app_browser_id, - self.application_window.default_width(), - self.application_window.default_height(), - self.application_window.is_maximized(), + &self.application_window.default_width(), + &self.application_window.default_height(), + &self.application_window.is_maximized(), ) { Ok(_) => { // Delegate save action to childs diff --git a/src/app/browser/widget/database.rs b/src/app/browser/widget/database.rs index e0753c6e..f232e820 100644 --- a/src/app/browser/widget/database.rs +++ b/src/app/browser/widget/database.rs @@ -32,10 +32,10 @@ impl Database { pub fn add( &self, - app_browser_id: i64, - default_width: i32, - default_height: i32, - is_maximized: bool, + app_browser_id: &i64, + default_width: &i32, + default_height: &i32, + is_maximized: &bool, ) -> Result { self.connection.execute( "INSERT INTO `app_browser_widget` ( @@ -46,17 +46,17 @@ impl Database { ) VALUES (?, ?, ?, ?)", [ app_browser_id, - default_width as i64, - default_height as i64, + &(*default_width as i64), + &(*default_height as i64), match is_maximized { - true => 1, - false => 0, + true => &1, + false => &0, }, ], ) } - pub fn records(&self, app_browser_id: i64) -> Result, Error> { + pub fn records(&self, app_browser_id: &i64) -> Result, Error> { let mut statement = self.connection.prepare( "SELECT `id`, `app_browser_id`, @@ -85,7 +85,7 @@ impl Database { Ok(records) } - pub fn delete(&self, id: i64) -> Result { + pub fn delete(&self, id: &i64) -> Result { self.connection .execute("DELETE FROM `app_browser_widget` WHERE `id` = ?", [id]) } diff --git a/src/app/database.rs b/src/app/database.rs index 462a03ef..2c97a534 100644 --- a/src/app/database.rs +++ b/src/app/database.rs @@ -44,7 +44,7 @@ impl Database { Ok(records) } - pub fn delete(&self, id: i64) -> Result { + pub fn delete(&self, id: &i64) -> Result { self.connection .execute("DELETE FROM `app` WHERE `id` = ?", [id]) }