eazygit 0.5.1

A fast TUI for Git with staging, conflicts, rebase, and palette-first UX
Documentation
use crate::app::{actions::Action, state::AppState};

pub fn handle(state: &mut AppState, action: &Action) -> bool {
    match action {
        Action::TogglePushFFOnly => {
            state.push_ff_only_enforce = !state.push_ff_only_enforce;
            state.feedback_message = Some(if state.push_ff_only_enforce { "Push ff-only guard ON" } else { "Push ff-only guard OFF" }.into());
        }
        Action::RequestPruneMergedBranches => {
            state.prune_merged_pending = true;
            state.feedback_message = Some("Confirm prune merged branches: press again to execute".into());
        }
        Action::PruneMergedBranches => {
            state.prune_merged_pending = false;
        }
        Action::RequestRemotePrune(remote) => {
            state.remote_prune_pending = true;
            state.feedback_message = Some(format!("Confirm remote prune {}: press again to execute", remote));
        }
        Action::RemotePrune(_) => {
            state.remote_prune_pending = false;
        }
        Action::ToggleFFOnly => {
            state.pull_ff_only = !state.pull_ff_only;
            state.feedback_message = Some(if state.pull_ff_only { "Pull ff-only ON" } else { "Pull ff-only OFF" }.into());
        }
        Action::ToggleAutostash => {
            state.pull_autostash = !state.pull_autostash;
            state.feedback_message = Some(if state.pull_autostash { "Autostash ON" } else { "Autostash OFF" }.into());
        }
        Action::ToggleAutoFetch => {
            state.auto_fetch_enabled = !state.auto_fetch_enabled;
            state.feedback_message = Some(if state.auto_fetch_enabled { "Auto-fetch ON" } else { "Auto-fetch OFF" }.into());
            if !state.auto_fetch_enabled {
                state.auto_fetch_last_check = None;
            }
        }
        Action::SetAutoFetchInterval(secs) => {
            state.auto_fetch_interval_secs = *secs;
            state.feedback_message = Some(format!("Auto-fetch interval {}s", secs));
        }
        Action::SetAutoFetchRemote(remote) => {
            state.auto_fetch_remote = remote.clone();
            state.feedback_message = Some(format!("Auto-fetch remote {}", remote));
        }
        Action::SetPullTimeout(secs) => {
            state.pull_timeout_secs = *secs;
            state.feedback_message = Some(format!("Pull timeout set to {}s", secs));
        }
        Action::SetRebaseTimeout(secs) => {
            state.rebase_timeout_secs = *secs;
            state.feedback_message = Some(format!("Rebase timeout set to {}s", secs));
        }
        _ => return false,
    }
    true
}