gitkraft_gui/features/remotes/
update.rs1use iced::Task;
4
5use crate::message::Message;
6use crate::state::GitKraft;
7
8use super::commands;
9
10pub fn update(state: &mut GitKraft, message: Message) -> Task<Message> {
13 match message {
14 Message::Fetch => {
15 let remote_name = state
18 .active_tab()
19 .remotes
20 .first()
21 .map(|r| r.name.clone())
22 .unwrap_or_else(|| "origin".to_string());
23
24 with_repo!(
25 state,
26 loading,
27 format!("Fetching from '{remote_name}'…"),
28 |repo_path| commands::fetch_remote(repo_path, remote_name)
29 )
30 }
31
32 Message::FetchCompleted(result) => {
33 state.on_ok_refresh(result, "Fetch completed.", "Fetch failed")
34 }
35
36 _ => Task::none(),
37 }
38}