use crate::diff::anchor::LinePos;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AnnotationKey {
Thread(crate::api::model::NodeId),
Draft(u64),
Check(usize),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AnnotationComment {
pub author: String,
pub body: String,
pub created_at: String,
pub pending: bool,
pub new: bool,
pub editable: Option<crate::api::edit::Editable>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Place {
File { outdated: bool },
Line { at: LinePos, start: Option<u32> },
Moved(LinePos),
Outdated(Option<u32>),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Annotation {
pub key: AnnotationKey,
pub path: String,
pub place: Place,
pub resolved: bool,
pub comments: Vec<AnnotationComment>,
pub left_out: u64,
pub error: Option<String>,
pub can_reply: bool,
pub can_resolve: bool,
pub can_unresolve: bool,
pub new: bool,
}
impl Annotation {
pub fn is_draft(&self) -> bool {
matches!(self.key, AnnotationKey::Draft(_))
}
pub fn on_line(&self) -> Option<LinePos> {
match self.place {
Place::Line { at, .. } | Place::Moved(at) => Some(at),
Place::File { .. } | Place::Outdated(_) => None,
}
}
pub fn open_by_default(&self) -> bool {
self.is_draft() || !self.resolved
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ThreadRowKind {
Summary,
Head {
comment: usize,
first: bool,
},
Body,
Reactions {
comment: usize,
},
Gap,
Error,
Footer,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ThreadRow {
pub ann: u32,
pub kind: ThreadRowKind,
pub line: crate::ui::comment::CommentLine,
}