use iced::Task;
use crate::message::Message;
use crate::state::GitKraft;
use super::commands;
pub fn update(state: &mut GitKraft, message: Message) -> Task<Message> {
match message {
Message::Fetch => {
let remote_name = state
.active_tab()
.remotes
.first()
.map(|r| r.name.clone())
.unwrap_or_else(|| "origin".to_string());
with_repo!(
state,
loading,
format!("Fetching from '{remote_name}'…"),
|repo_path| commands::fetch_remote(repo_path, remote_name)
)
}
Message::FetchCompleted(result) => {
state.on_ok_refresh(result, "Fetch completed.", "Fetch failed")
}
_ => Task::none(),
}
}