feat: add lesson export and import functionality
- Implemented `LessonExport` and `LessonImport` actions in the action module. - Added corresponding command parsing for lesson export and import. - Created functions to handle lesson export and import in the memory module. - Updated state management to reflect changes after lesson operations. - Introduced deferred operations for handling asynchronous tasks in the event loop. - Enhanced the tool execution context to include graduated checks for file operations. - Added OAuth support with PKCE for secure authorization flows. - Implemented a loopback server for handling OAuth redirects. - Refactored various modules to improve code organization and maintainability.
This commit is contained in:
@@ -1 +1,2 @@
|
||||
#[expect(dead_code)]
|
||||
pub mod sessions;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
use crate::app::state::rest::AppStateRest;
|
||||
use crate::app::state::types::ToastKind;
|
||||
|
||||
pub struct DeferredOp {
|
||||
pub kind: String,
|
||||
pub handler: Box<dyn FnOnce(&mut AppStateRest) + Send>,
|
||||
}
|
||||
|
||||
pub fn run_deferred(state: &mut AppStateRest, op: DeferredOp) {
|
||||
let kind = op.kind.clone();
|
||||
(op.handler)(state);
|
||||
state.push_toast(crate::app::state::types::Toast::new(
|
||||
ToastKind::Info,
|
||||
format!("deferred '{}' completed", kind),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use std::path::PathBuf;
|
||||
use crate::model::session::Session;
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub struct SessionManager {
|
||||
pub current_id: String,
|
||||
pub base_dir: PathBuf,
|
||||
pub sessions: Vec<Session>,
|
||||
}
|
||||
|
||||
impl SessionManager {
|
||||
pub fn new(base_dir: PathBuf) -> Self {
|
||||
SessionManager {
|
||||
current_id: String::new(),
|
||||
base_dir,
|
||||
sessions: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_sessions(&mut self) {
|
||||
self.sessions = Session::list(&self.base_dir);
|
||||
}
|
||||
|
||||
pub fn find_by_id(&self, id: &str) -> Option<&Session> {
|
||||
self.sessions.iter().find(|s| s.id == id)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user