use crate::reply::roster::WsRow;
use crate::ui::{Chunk, Model, convs, theme};
mod controls;
pub const NO_NAME_HERE: &str = "no entry here names it, so nothing typed here can address it";
pub const PIN: &str = "pin";
pub const UNPIN: &str = "unpin";
pub fn render(ui: &mut egui::Ui, model: &mut Model, chunk: &Chunk, row: &WsRow, reveal: bool) {
let Some(address) = chunk.channel.address(row) else {
theme::paint::row(
ui,
&format!("{} — {NO_NAME_HERE}", line(row)),
theme::INK_FAINT,
None,
false,
0.0,
);
return;
};
let aim = crate::ui::Aim {
channel: chunk.channel.name.clone(),
address: address.clone(),
};
let aimed = model.aim.as_ref() == Some(&aim);
let state = if row.attention > 0 {
Some(theme::accent(theme::State::Attention))
} else if row.running {
Some(theme::accent(theme::State::Working))
} else {
None
};
let seat = theme::paint::row(ui, &line(row), theme::INK, state, aimed, 0.0);
crate::ui::act::tag(&seat, &[crate::verbs::CONVERSATIONS.word]);
if aimed && reveal {
seat.scroll_to_me(None);
}
if seat.clicked() {
model.aim_at(&chunk.channel.name.clone(), &address);
}
if !aimed {
return;
}
if !model.covered() {
ui.horizontal_wrapped(|ui| {
ui.add_space(theme::space::L);
controls::render(ui, model, row);
});
}
convs::under(ui, model, &aim, reveal);
}
pub fn line(row: &WsRow) -> String {
let mut said = vec![format!(
"{} ({}) {} conversations",
row.workspace,
row.kind.label(),
row.agents
)];
if row.attention > 0 {
said.push(format!("{} waiting", row.attention));
}
if row.running {
said.push("running".to_owned());
}
said.join(" ")
}
#[cfg(test)]
mod tests;