Collapse a project's sessions by clicking its name

This commit is contained in:
Georg Bauer
2026-07-25 23:58:21 +02:00
parent e44680541d
commit ce18a2db9b
7 changed files with 49 additions and 17 deletions

View File

@@ -257,6 +257,8 @@ pub struct Project {
pub id: i32,
pub name: String,
pub path: String,
/// Sidebar state: hides this project's session rows.
pub collapsed: bool,
}
#[derive(Insertable)]
@@ -536,6 +538,18 @@ impl Database {
.map_err(|error| error.to_string())
}
pub fn set_project_collapsed(
&mut self,
project_id: i32,
collapsed: bool,
) -> Result<(), String> {
diesel::update(projects::table.find(project_id))
.set(projects::collapsed.eq(collapsed))
.execute(&mut self.connection)
.map(|_| ())
.map_err(|error| error.to_string())
}
pub fn delete_project(&mut self, project_id: i32) -> Result<(), String> {
self.connection
.transaction(|connection| {
@@ -863,6 +877,9 @@ mod tests {
database.set_sidebar_collapsed(true).unwrap();
database.set_last_project(Some(project.id)).unwrap();
assert!(!loaded[0].project.collapsed);
database.set_project_collapsed(project.id, true).unwrap();
assert!(database.load_projects().unwrap()[0].project.collapsed);
database.delete_project(project.id).unwrap();
assert!(database.load_projects().unwrap().is_empty());