mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-29 20:44:25 +00:00
fix tab items order
This commit is contained in:
parent
0a0d7b0481
commit
de09688dd8
@ -250,22 +250,24 @@ impl Tab {
|
|||||||
// Delegate save action to childs
|
// Delegate save action to childs
|
||||||
let id = Database::last_insert_id(transaction);
|
let id = Database::last_insert_id(transaction);
|
||||||
|
|
||||||
// Read HashMap index collected
|
// At least one active page wanted to continue
|
||||||
let mut page_number = 0;
|
if let Some(current_page) = self.widget.gobject().current_page() {
|
||||||
|
// Read collected HashMap index
|
||||||
// @TODO incorrect order
|
for (_, item) in self.index.borrow().iter() {
|
||||||
for (_, item) in self.index.borrow().iter() {
|
// Get page number as HashMap does not keep order, no page_reorder listener also
|
||||||
item.save(
|
match self.widget.gobject().page_num(item.page()) {
|
||||||
transaction,
|
Some(page_number) => {
|
||||||
&id,
|
item.save(
|
||||||
&match self.widget.gobject().current_page() {
|
transaction,
|
||||||
Some(number) => number == page_number,
|
&id,
|
||||||
None => false,
|
&page_number,
|
||||||
},
|
&(current_page == page_number),
|
||||||
)?;
|
)?;
|
||||||
|
}
|
||||||
page_number += 1;
|
None => panic!(), // page number expected at this point @TODO Err?
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Err(e) => return Err(e.to_string()),
|
Err(e) => return Err(e.to_string()),
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,15 @@ impl Item {
|
|||||||
&self,
|
&self,
|
||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
app_browser_window_tab_id: &i64,
|
app_browser_window_tab_id: &i64,
|
||||||
|
page_number: &u32,
|
||||||
is_initially_current: &bool,
|
is_initially_current: &bool,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
match Database::add(transaction, app_browser_window_tab_id, is_initially_current) {
|
match Database::add(
|
||||||
|
transaction,
|
||||||
|
app_browser_window_tab_id,
|
||||||
|
page_number,
|
||||||
|
is_initially_current,
|
||||||
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let id = Database::last_insert_id(transaction);
|
let id = Database::last_insert_id(transaction);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ impl Database {
|
|||||||
(
|
(
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
`app_browser_window_tab_id` INTEGER NOT NULL,
|
`app_browser_window_tab_id` INTEGER NOT NULL,
|
||||||
|
`page_number` INTEGER NOT NULL,
|
||||||
`is_initially_current` INTEGER NOT NULL
|
`is_initially_current` INTEGER NOT NULL
|
||||||
)",
|
)",
|
||||||
[],
|
[],
|
||||||
@ -26,14 +27,20 @@ impl Database {
|
|||||||
pub fn add(
|
pub fn add(
|
||||||
tx: &Transaction,
|
tx: &Transaction,
|
||||||
app_browser_window_tab_id: &i64,
|
app_browser_window_tab_id: &i64,
|
||||||
|
page_number: &u32,
|
||||||
is_initially_current: &bool,
|
is_initially_current: &bool,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
tx.execute(
|
tx.execute(
|
||||||
"INSERT INTO `app_browser_window_tab_item` (
|
"INSERT INTO `app_browser_window_tab_item` (
|
||||||
`app_browser_window_tab_id`,
|
`app_browser_window_tab_id`,
|
||||||
|
`page_number`,
|
||||||
`is_initially_current`
|
`is_initially_current`
|
||||||
) VALUES (?, ?)",
|
) VALUES (?, ?, ?)",
|
||||||
[app_browser_window_tab_id, &(*is_initially_current as i64)],
|
[
|
||||||
|
app_browser_window_tab_id,
|
||||||
|
&(*page_number as i64),
|
||||||
|
&(*is_initially_current as i64),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +49,8 @@ impl Database {
|
|||||||
"SELECT `id`,
|
"SELECT `id`,
|
||||||
`app_browser_window_tab_id`,
|
`app_browser_window_tab_id`,
|
||||||
`is_initially_current` FROM `app_browser_window_tab_item`
|
`is_initially_current` FROM `app_browser_window_tab_item`
|
||||||
WHERE `app_browser_window_tab_id` = ?",
|
WHERE `app_browser_window_tab_id` = ?
|
||||||
|
ORDER BY `page_number` ASC", // just order by, no store in struct wanted
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let result = stmt.query_map([app_browser_window_tab_id], |row| {
|
let result = stmt.query_map([app_browser_window_tab_id], |row| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user