fix tabs order on session restore

This commit is contained in:
yggverse 2025-01-31 12:53:40 +02:00
parent e7c55e1b19
commit 8b67f70573
2 changed files with 10 additions and 5 deletions

View file

@ -331,8 +331,10 @@ impl Tab {
for tab_record in tab_records {
for item_record in item::restore(transaction, tab_record.id)? {
// Generate new `TabPage` with blank `Widget`
let (tab_page, target_child) =
new_tab_page(&self.tab_view, Position::After);
let (tab_page, target_child) = new_tab_page(
&self.tab_view,
Position::Number(item_record.page_position),
);
// Init new tab item
let item = Rc::new(Item::build(

View file

@ -3,6 +3,7 @@ use sqlite::{Error, Transaction};
pub struct Table {
pub id: i64,
// pub app_browser_window_tab_id: i64, not in use
pub page_position: i32,
pub is_pinned: 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(
"SELECT `id`,
`app_browser_window_tab_id`,
`page_position`,
`is_pinned`,
`is_selected`
FROM `app_browser_window_tab_item`
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| {
Ok(Table {
id: row.get(0)?,
// app_browser_window_tab_id: row.get(1)?, not in use
is_pinned: row.get(2)?,
is_selected: row.get(3)?,
page_position: row.get(2)?,
is_pinned: row.get(3)?,
is_selected: row.get(4)?,
})
})?;