mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-10 12:41:34 +00:00
use refs
This commit is contained in:
parent
f463c71d4f
commit
aad0e266f6
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ impl Database {
|
||||
Ok(Self { connection })
|
||||
}
|
||||
|
||||
pub fn add(&self, app_id: i64) -> Result<usize, Error> {
|
||||
pub fn add(&self, app_id: &i64) -> Result<usize, Error> {
|
||||
self.connection
|
||||
.execute("INSERT INTO `app_browser` (`app_id`) VALUES (?)", [app_id])
|
||||
}
|
||||
|
||||
pub fn records(&self, app_id: i64) -> Result<Vec<Table>, Error> {
|
||||
pub fn records(&self, app_id: &i64) -> Result<Vec<Table>, 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<usize, Error> {
|
||||
pub fn delete(&self, id: &i64) -> Result<usize, Error> {
|
||||
self.connection
|
||||
.execute("DELETE FROM `app_browser` WHERE `id` = ?", [id])
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<usize, Error> {
|
||||
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<Vec<Table>, Error> {
|
||||
pub fn records(&self, app_browser_id: &i64) -> Result<Vec<Table>, 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<usize, Error> {
|
||||
pub fn delete(&self, id: &i64) -> Result<usize, Error> {
|
||||
self.connection
|
||||
.execute("DELETE FROM `app_browser_widget` WHERE `id` = ?", [id])
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ impl Database {
|
||||
Ok(records)
|
||||
}
|
||||
|
||||
pub fn delete(&self, id: i64) -> Result<usize, Error> {
|
||||
pub fn delete(&self, id: &i64) -> Result<usize, Error> {
|
||||
self.connection
|
||||
.execute("DELETE FROM `app` WHERE `id` = ?", [id])
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user