use crate::diff;
use inflorescence_iced_widget::nav_scrollable;
use libflorescence::{file, repo};
use std::collections::HashSet;
#[derive(Debug, Default)]
pub struct FilesAndState {
/// All the hashes in this set have `diffs` loaded.
pub changes_with_loaded_diffs: HashSet<repo::ChangeHash>,
/// All the diffs in this map have the change hash present in
/// `change_with_loaded_diffs`
pub diffs: file::LogIdMap<diff::FileAndState>,
}
#[derive(Debug, Default)]
pub struct Navs {
/// Log change's files scrollable nav. Only the currently selected nav is
/// kept.
pub files_nav: nav_scrollable::State,
/// Log file's diffs scrollable nav. Only the currently selected nav is
/// kept.
pub diffs_nav: nav_scrollable::State,
#[cfg(debug_assertions)]
pub change_hash: Option<repo::ChangeHash>,
#[cfg(debug_assertions)]
pub file_id: Option<file::LogIdHash>,
}
pub fn init_files_nav(navs: &mut Navs, hash: repo::ChangeHash) {
navs.files_nav = nav_scrollable::State::default();
#[cfg(debug_assertions)]
{
navs.change_hash = Some(hash);
navs.file_id = None;
}
#[cfg(not(debug_assertions))]
let _ = hash;
}
pub fn init_diffs_nav(
navs: &mut Navs,
file_id: file::LogIdHash,
) -> &mut nav_scrollable::State {
navs.diffs_nav = nav_scrollable::State::default();
#[cfg(debug_assertions)]
{
navs.file_id = Some(file_id);
}
#[cfg(not(debug_assertions))]
let _ = file_id;
&mut navs.diffs_nav
}