use super::super::act;
use super::ConfigState;
use super::branch_pane::reread;
use crate::AppModel;
use crate::boundary::Action;
use crate::boundary::config::ConfigFile;
use std::path::Path;
pub(super) fn edit(model: &mut AppModel, config: &mut ConfigState, ws: &Path) {
let action = Action::ApplyConfig {
file: ConfigFile::Branch {
workspace: model.snap.ws_name(ws),
lineage: config.cb_name.clone(),
origin: config.cb_origin.clone(),
path: config.cb_path.clone(),
},
text: config.cb_body.clone(),
};
config.cb_act.fire(
model,
&action,
"sent — staged and committed by `lernie config`",
);
}
pub(super) fn settle(model: &mut AppModel, config: &mut ConfigState, ws: &Path) {
let Some(landed) = config.cb_act.landed(model) else {
return;
};
if let Some(why) = act::trouble(&landed) {
let said = format!("{} — ⚠ {why}", config.cb_act.line());
config.cb_act.say(said);
}
reread(config, Some(ws));
}