move is_needs_attention state to page, reorganize TabView access levels

This commit is contained in:
yggverse 2025-01-30 22:40:47 +02:00
parent 8356c432c1
commit 25db274d2e
5 changed files with 158 additions and 191 deletions

View file

@ -5,21 +5,19 @@ pub struct Table {
// pub app_browser_window_tab_id: i64, not in use
pub is_pinned: bool,
pub is_selected: bool,
pub is_needs_attention: bool,
}
pub fn init(tx: &Transaction) -> Result<usize, Error> {
tx.execute(
"CREATE TABLE IF NOT EXISTS `app_browser_window_tab_item`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_tab_id` INTEGER NOT NULL,
`page_position` INTEGER NOT NULL,
`is_pinned` INTEGER NOT NULL,
`is_selected` INTEGER NOT NULL,
`is_needs_attention` INTEGER NOT NULL,
`page_position` INTEGER NOT NULL,
`is_pinned` INTEGER NOT NULL,
`is_selected` INTEGER NOT NULL,
FOREIGN KEY (`app_browser_window_tab_id`) REFERENCES `app_browser_window_tab`(`id`)
FOREIGN KEY (`app_browser_window_tab_id`) REFERENCES `app_browser_window_tab` (`id`)
)",
[],
)
@ -31,22 +29,19 @@ pub fn insert(
page_position: i32,
is_pinned: bool,
is_selected: bool,
is_needs_attention: bool,
) -> Result<usize, Error> {
tx.execute(
"INSERT INTO `app_browser_window_tab_item` (
`app_browser_window_tab_id`,
`page_position`,
`is_pinned`,
`is_selected`,
`is_needs_attention`
) VALUES (?, ?, ?, ?, ?)",
`is_selected`
) VALUES (?, ?, ?, ?)",
[
app_browser_window_tab_id,
page_position as i64,
is_pinned as i64,
is_selected as i64,
is_needs_attention as i64,
],
)
}
@ -56,8 +51,7 @@ pub fn select(tx: &Transaction, app_browser_window_tab_id: i64) -> Result<Vec<Ta
"SELECT `id`,
`app_browser_window_tab_id`,
`is_pinned`,
`is_selected`,
`is_needs_attention`
`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
@ -69,7 +63,6 @@ pub fn select(tx: &Transaction, app_browser_window_tab_id: i64) -> Result<Vec<Ta
// app_browser_window_tab_id: row.get(1)?, not in use
is_pinned: row.get(2)?,
is_selected: row.get(3)?,
is_needs_attention: row.get(4)?,
})
})?;