mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
use refs
This commit is contained in:
parent
f463c71d4f
commit
aad0e266f6
6 changed files with 30 additions and 30 deletions
|
|
@ -115,7 +115,7 @@ impl App {
|
||||||
match database.records() {
|
match database.records() {
|
||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
for record in records {
|
for record in records {
|
||||||
browser.restore(record.id);
|
browser.restore(&record.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => panic!("{error}"), // @TODO
|
Err(error) => panic!("{error}"), // @TODO
|
||||||
|
|
@ -138,10 +138,10 @@ impl App {
|
||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
// Cleanup previous session records
|
// Cleanup previous session records
|
||||||
for record in records {
|
for record in records {
|
||||||
match database.delete(record.id) {
|
match database.delete(&record.id) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate clean action to childs
|
// Delegate clean action to childs
|
||||||
browser.clean(record.id);
|
browser.clean(&record.id);
|
||||||
}
|
}
|
||||||
Err(error) => panic!("{error}"), // @TODO
|
Err(error) => panic!("{error}"), // @TODO
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +151,7 @@ impl App {
|
||||||
match database.add() {
|
match database.add() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate save action to childs
|
// Delegate save action to childs
|
||||||
browser.save(database.last_insert_id());
|
browser.save(&database.last_insert_id());
|
||||||
}
|
}
|
||||||
Err(error) => panic!("{error}"), // @TODO
|
Err(error) => panic!("{error}"), // @TODO
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,17 +227,17 @@ impl Browser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn clean(&self, app_id: i64) {
|
pub fn clean(&self, app_id: &i64) {
|
||||||
match self.database.records(app_id) {
|
match self.database.records(app_id) {
|
||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
for record in records {
|
for record in records {
|
||||||
match self.database.delete(record.id) {
|
match self.database.delete(&record.id) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate clean action to childs
|
// Delegate clean action to childs
|
||||||
// @TODO
|
// @TODO
|
||||||
// self.header.clean(record.id);
|
// self.header.clean(record.id);
|
||||||
// self.main.clean(record.id);
|
// self.main.clean(record.id);
|
||||||
self.widget.clean(record.id);
|
self.widget.clean(&record.id);
|
||||||
}
|
}
|
||||||
Err(error) => panic!("{error}"), // @TODO
|
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
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save(&self, app_id: i64) {
|
pub fn save(&self, app_id: &i64) {
|
||||||
match self.database.add(app_id) {
|
match self.database.add(app_id) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate save action to childs
|
// Delegate save action to childs
|
||||||
|
|
@ -259,7 +259,7 @@ impl Browser {
|
||||||
// @TODO
|
// @TODO
|
||||||
// self.header.save(id);
|
// self.header.save(id);
|
||||||
// self.main.save(id);
|
// self.main.save(id);
|
||||||
self.widget.save(id);
|
self.widget.save(&id);
|
||||||
}
|
}
|
||||||
Err(error) => panic!("{error}"), // @TODO
|
Err(error) => panic!("{error}"), // @TODO
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ impl Database {
|
||||||
Ok(Self { connection })
|
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
|
self.connection
|
||||||
.execute("INSERT INTO `app_browser` (`app_id`) VALUES (?)", [app_id])
|
.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
|
let mut statement = self
|
||||||
.connection
|
.connection
|
||||||
.prepare("SELECT `id`, `app_id` WHERE `app_id` = ?")?;
|
.prepare("SELECT `id`, `app_id` WHERE `app_id` = ?")?;
|
||||||
|
|
@ -51,7 +51,7 @@ impl Database {
|
||||||
Ok(records)
|
Ok(records)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(&self, id: i64) -> Result<usize, Error> {
|
pub fn delete(&self, id: &i64) -> Result<usize, Error> {
|
||||||
self.connection
|
self.connection
|
||||||
.execute("DELETE FROM `app_browser` WHERE `id` = ?", [id])
|
.execute("DELETE FROM `app_browser` WHERE `id` = ?", [id])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ impl Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn clean(&self, app_browser_id: i64) {
|
pub fn clean(&self, app_browser_id: &i64) {
|
||||||
match self.database.records(app_browser_id) {
|
match self.database.records(app_browser_id) {
|
||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
for record in records {
|
for record in records {
|
||||||
match self.database.delete(record.id) {
|
match self.database.delete(&record.id) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate clean action to childs
|
// Delegate clean action to childs
|
||||||
// nothing yet..
|
// nothing yet..
|
||||||
|
|
@ -66,12 +66,12 @@ impl Widget {
|
||||||
// @TODO
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save(&self, app_browser_id: i64) {
|
pub fn save(&self, app_browser_id: &i64) {
|
||||||
match self.database.add(
|
match self.database.add(
|
||||||
app_browser_id,
|
app_browser_id,
|
||||||
self.application_window.default_width(),
|
&self.application_window.default_width(),
|
||||||
self.application_window.default_height(),
|
&self.application_window.default_height(),
|
||||||
self.application_window.is_maximized(),
|
&self.application_window.is_maximized(),
|
||||||
) {
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate save action to childs
|
// Delegate save action to childs
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ impl Database {
|
||||||
|
|
||||||
pub fn add(
|
pub fn add(
|
||||||
&self,
|
&self,
|
||||||
app_browser_id: i64,
|
app_browser_id: &i64,
|
||||||
default_width: i32,
|
default_width: &i32,
|
||||||
default_height: i32,
|
default_height: &i32,
|
||||||
is_maximized: bool,
|
is_maximized: &bool,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
self.connection.execute(
|
self.connection.execute(
|
||||||
"INSERT INTO `app_browser_widget` (
|
"INSERT INTO `app_browser_widget` (
|
||||||
|
|
@ -46,17 +46,17 @@ impl Database {
|
||||||
) VALUES (?, ?, ?, ?)",
|
) VALUES (?, ?, ?, ?)",
|
||||||
[
|
[
|
||||||
app_browser_id,
|
app_browser_id,
|
||||||
default_width as i64,
|
&(*default_width as i64),
|
||||||
default_height as i64,
|
&(*default_height as i64),
|
||||||
match is_maximized {
|
match is_maximized {
|
||||||
true => 1,
|
true => &1,
|
||||||
false => 0,
|
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(
|
let mut statement = self.connection.prepare(
|
||||||
"SELECT `id`,
|
"SELECT `id`,
|
||||||
`app_browser_id`,
|
`app_browser_id`,
|
||||||
|
|
@ -85,7 +85,7 @@ impl Database {
|
||||||
Ok(records)
|
Ok(records)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(&self, id: i64) -> Result<usize, Error> {
|
pub fn delete(&self, id: &i64) -> Result<usize, Error> {
|
||||||
self.connection
|
self.connection
|
||||||
.execute("DELETE FROM `app_browser_widget` WHERE `id` = ?", [id])
|
.execute("DELETE FROM `app_browser_widget` WHERE `id` = ?", [id])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ impl Database {
|
||||||
Ok(records)
|
Ok(records)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(&self, id: i64) -> Result<usize, Error> {
|
pub fn delete(&self, id: &i64) -> Result<usize, Error> {
|
||||||
self.connection
|
self.connection
|
||||||
.execute("DELETE FROM `app` WHERE `id` = ?", [id])
|
.execute("DELETE FROM `app` WHERE `id` = ?", [id])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue