refactor(session): rethink and so ... remove useless close_session command
This commit is contained in:
parent
93fc1bf829
commit
4c1af08fb7
3 changed files with 14 additions and 41 deletions
|
|
@ -63,7 +63,6 @@ impl DocumentManager {
|
||||||
// Session lifecycle
|
// Session lifecycle
|
||||||
SessionCommand::NewSession { name } => self.new_session(&name),
|
SessionCommand::NewSession { name } => self.new_session(&name),
|
||||||
SessionCommand::OpenSession { path } => self.open_session_file(&path),
|
SessionCommand::OpenSession { path } => self.open_session_file(&path),
|
||||||
SessionCommand::CloseSession => self.close_session(),
|
|
||||||
SessionCommand::DeleteSession => self.delete_session(),
|
SessionCommand::DeleteSession => self.delete_session(),
|
||||||
SessionCommand::SaveSession => self.save_session(),
|
SessionCommand::SaveSession => self.save_session(),
|
||||||
SessionCommand::SelectSession { name } => self.select_session(&name),
|
SessionCommand::SelectSession { name } => self.select_session(&name),
|
||||||
|
|
@ -150,27 +149,18 @@ impl DocumentManager {
|
||||||
match store::load_sessions(path) {
|
match store::load_sessions(path) {
|
||||||
Ok(mut loaded) => {
|
Ok(mut loaded) => {
|
||||||
for session in &mut loaded {
|
for session in &mut loaded {
|
||||||
match session.kind {
|
session.items.retain(|item| {
|
||||||
CollectionKind::DirectoryBrowser => {
|
if item.path.exists() {
|
||||||
if let Some(dir) = session.path.clone() {
|
true
|
||||||
scan_directory_into(session, &dir);
|
} else {
|
||||||
}
|
warn!(
|
||||||
|
"Session '{}': {}",
|
||||||
|
session.name,
|
||||||
|
Error::NotFound(item.path.display().to_string())
|
||||||
|
);
|
||||||
|
false
|
||||||
}
|
}
|
||||||
CollectionKind::DocumentCollection => {
|
});
|
||||||
session.items.retain(|item| {
|
|
||||||
if item.path.exists() {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
warn!(
|
|
||||||
"Session '{}': {}",
|
|
||||||
session.name,
|
|
||||||
Error::NotFound(item.path.display().to_string())
|
|
||||||
);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let browser_index = loaded
|
let browser_index = loaded
|
||||||
|
|
@ -189,13 +179,9 @@ impl DocumentManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_session(&mut self) {
|
// We have no 'Close session' it wouldbe only removes it from runtime, keeps it in .ron file
|
||||||
// Close session only removes it from runtime, keeps it in .ron file
|
// For actual deletion, use delete_session()
|
||||||
// For actual deletion, use delete_session()
|
// So 'close_session' from ui view is save_session and close session view.
|
||||||
// Currently acts same as delete for backwards compatibility
|
|
||||||
// TODO: Implement proper close behavior (hide from UI but keep in .ron)
|
|
||||||
self.delete_session();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn delete_session(&mut self) {
|
fn delete_session(&mut self) {
|
||||||
let Some(idx) = self.active_session_index else {
|
let Some(idx) = self.active_session_index else {
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ pub enum SessionCommand {
|
||||||
NewSession { name: String },
|
NewSession { name: String },
|
||||||
/// Load sessions from an existing .ron file.
|
/// Load sessions from an existing .ron file.
|
||||||
OpenSession { path: PathBuf },
|
OpenSession { path: PathBuf },
|
||||||
/// Close the active session (removes from runtime, kept in .ron file).
|
|
||||||
CloseSession,
|
|
||||||
/// Persist all sessions to the .ron file.
|
/// Persist all sessions to the .ron file.
|
||||||
SaveSession,
|
SaveSession,
|
||||||
/// Set the active session cursor by name.
|
/// Set the active session cursor by name.
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -338,17 +338,6 @@ fn run_session_test(mgr: &mut DocumentManager, active_name: &str) {
|
||||||
};
|
};
|
||||||
println!(" {marker} {}", session.name);
|
println!(" {marker} {}", session.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec(
|
|
||||||
mgr,
|
|
||||||
"CloseSession (closes 'Archive')",
|
|
||||||
SessionCommand::CloseSession,
|
|
||||||
);
|
|
||||||
|
|
||||||
step("All sessions after close:");
|
|
||||||
for session in mgr.sessions() {
|
|
||||||
println!(" {DIM}-{RESET} {}", session.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_cli(args: Args) {
|
fn run_cli(args: Args) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue