use std::path::Path;
use super::{aimed, asked, down, read};
use crate::state::{Link, Open};
use crate::ui::Channel;
pub(super) fn ask(
link: &Link,
root: &Path,
standing: &crate::state::Standing,
channel: &Channel,
aim: &crate::ui::Aim,
) {
aimed(
link,
root,
channel,
&crate::verbs::conversations(aim.address.clone()),
);
tuning(link, root, standing, channel, aim);
if standing.standing(&Open::Board) {
aimed(
link,
root,
channel,
&crate::verbs::workspace_balls(aim.address.clone()),
);
aimed(
link,
root,
channel,
&crate::verbs::marks(aim.address.clone()),
);
}
fleet(link, root, standing, channel, aim);
if standing.standing(&Open::Login(standing.signin())) {
aimed(
link,
root,
channel,
&crate::verbs::providers(aim.address.clone()),
);
}
if standing.standing(&Open::Clients) {
aimed(
link,
root,
channel,
&crate::verbs::clients(aim.address.clone()),
);
}
config(link, root, standing, channel, aim);
}
pub(super) fn selected(
link: &Link,
root: &Path,
standing: &crate::state::Standing,
channel: &Channel,
wall: &str,
conversation: &str,
) {
aimed(
link,
root,
channel,
&crate::verbs::transcript(wall.to_owned(), conversation.to_owned()),
);
aimed(
link,
root,
channel,
&crate::verbs::agent(wall.to_owned(), conversation.to_owned()),
);
if standing.standing(&Open::Records) {
records(link, root, channel, wall, conversation);
}
}
fn records(link: &Link, root: &Path, channel: &Channel, wall: &str, conversation: &str) {
for ask in [
crate::verbs::steps(wall.to_owned(), conversation.to_owned()),
crate::verbs::files(wall.to_owned(), conversation.to_owned()),
crate::verbs::rail(wall.to_owned(), conversation.to_owned()),
crate::verbs::governing(wall.to_owned(), conversation.to_owned()),
crate::verbs::inbox(wall.to_owned(), conversation.to_owned()),
crate::verbs::lineages(wall.to_owned()),
] {
aimed(link, root, channel, &ask);
}
}
fn tuning(
link: &Link,
root: &Path,
standing: &crate::state::Standing,
channel: &Channel,
aim: &crate::ui::Aim,
) {
let Some(Open::Tuning(providers)) = &standing.open else {
return;
};
aimed(
link,
root,
channel,
&crate::verbs::roles(aim.address.clone()),
);
for provider in providers {
match asked(
root,
&crate::verbs::models(aim.address.clone(), provider.clone()),
) {
Ok(stream) => {
for frame in stream {
link.offering(channel, provider, crate::reply::read(&frame));
}
}
Err(reach) => read(link, Err(reach), channel),
}
}
}
fn fleet(
link: &Link,
root: &Path,
standing: &crate::state::Standing,
channel: &Channel,
aim: &crate::ui::Aim,
) {
if !standing.standing(&Open::Fleet) {
return;
}
aimed(
link,
root,
channel,
&crate::verbs::science(aim.address.clone()),
);
aimed(
link,
root,
channel,
&crate::verbs::work_diff(aim.address.clone()),
);
}
fn config(
link: &Link,
root: &Path,
standing: &crate::state::Standing,
channel: &Channel,
aim: &crate::ui::Aim,
) {
if !standing.standing(&Open::Config(standing.at(), standing.named())) {
return;
}
for ask in [
crate::verbs::lineages(aim.address.clone()),
crate::verbs::proposals(aim.address.clone(), standing.named()),
] {
aimed(link, root, channel, &ask);
}
if let Some(at) = standing.at() {
let gesture = crate::verbs::config(&at);
if at.addresses_a_workspace() {
aimed(link, root, channel, &gesture);
} else {
read(link, down(link, root, channel, &gesture), channel);
}
}
}