mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
fix tabs order on session restore
This commit is contained in:
parent
e7c55e1b19
commit
8b67f70573
2 changed files with 10 additions and 5 deletions
|
|
@ -331,8 +331,10 @@ impl Tab {
|
||||||
for tab_record in tab_records {
|
for tab_record in tab_records {
|
||||||
for item_record in item::restore(transaction, tab_record.id)? {
|
for item_record in item::restore(transaction, tab_record.id)? {
|
||||||
// Generate new `TabPage` with blank `Widget`
|
// Generate new `TabPage` with blank `Widget`
|
||||||
let (tab_page, target_child) =
|
let (tab_page, target_child) = new_tab_page(
|
||||||
new_tab_page(&self.tab_view, Position::After);
|
&self.tab_view,
|
||||||
|
Position::Number(item_record.page_position),
|
||||||
|
);
|
||||||
|
|
||||||
// Init new tab item
|
// Init new tab item
|
||||||
let item = Rc::new(Item::build(
|
let item = Rc::new(Item::build(
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use sqlite::{Error, Transaction};
|
||||||
pub struct Table {
|
pub struct Table {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
// pub app_browser_window_tab_id: i64, not in use
|
// pub app_browser_window_tab_id: i64, not in use
|
||||||
|
pub page_position: i32,
|
||||||
pub is_pinned: bool,
|
pub is_pinned: bool,
|
||||||
pub is_selected: bool,
|
pub is_selected: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -50,19 +51,21 @@ pub fn select(tx: &Transaction, app_browser_window_tab_id: i64) -> Result<Vec<Ta
|
||||||
let mut stmt = tx.prepare(
|
let mut stmt = tx.prepare(
|
||||||
"SELECT `id`,
|
"SELECT `id`,
|
||||||
`app_browser_window_tab_id`,
|
`app_browser_window_tab_id`,
|
||||||
|
`page_position`,
|
||||||
`is_pinned`,
|
`is_pinned`,
|
||||||
`is_selected`
|
`is_selected`
|
||||||
FROM `app_browser_window_tab_item`
|
FROM `app_browser_window_tab_item`
|
||||||
WHERE `app_browser_window_tab_id` = ?
|
WHERE `app_browser_window_tab_id` = ?
|
||||||
ORDER BY `page_position` ASC", // just order by, no store in struct wanted
|
ORDER BY `page_position` ASC", // important to keep this order on items restore
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let result = stmt.query_map([app_browser_window_tab_id], |row| {
|
let result = stmt.query_map([app_browser_window_tab_id], |row| {
|
||||||
Ok(Table {
|
Ok(Table {
|
||||||
id: row.get(0)?,
|
id: row.get(0)?,
|
||||||
// app_browser_window_tab_id: row.get(1)?, not in use
|
// app_browser_window_tab_id: row.get(1)?, not in use
|
||||||
is_pinned: row.get(2)?,
|
page_position: row.get(2)?,
|
||||||
is_selected: row.get(3)?,
|
is_pinned: row.get(3)?,
|
||||||
|
is_selected: row.get(4)?,
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue