refactor: remove unused review state and duplicate storage reads
This commit is contained in:
+4
-16
@@ -59,10 +59,6 @@ impl Anchor {
|
||||
self.start.row..=end
|
||||
}
|
||||
|
||||
pub fn matches(&self, revision: &str, path: &Path, side: Side, text: &str) -> bool {
|
||||
self.revision == revision && self.path == path && self.side == side && self.content == text
|
||||
}
|
||||
|
||||
pub fn matches_lines(
|
||||
&self,
|
||||
revision: &str,
|
||||
@@ -116,7 +112,6 @@ impl Default for Review {
|
||||
pub struct ReviewState {
|
||||
pub document: Review,
|
||||
pub initialized: bool,
|
||||
pub choices: Vec<(i64, String)>,
|
||||
pub path: Option<PathBuf>,
|
||||
pub selected: Option<u64>,
|
||||
pub pending_navigation: Option<u64>,
|
||||
@@ -407,7 +402,7 @@ impl Store {
|
||||
Ok(Self { connection })
|
||||
}
|
||||
|
||||
pub fn list(&self, root: &Path) -> Result<Vec<(i64, String)>, String> {
|
||||
pub fn list(&self, root: &Path) -> Result<Vec<Review>, String> {
|
||||
let root = fs::canonicalize(root).map_err(|error| error.to_string())?;
|
||||
let root_text = root
|
||||
.to_str()
|
||||
@@ -419,18 +414,11 @@ impl Store {
|
||||
)
|
||||
.map_err(database_error)?;
|
||||
let mut rows = statement.query([root_text]).map_err(database_error)?;
|
||||
let mut choices = Vec::new();
|
||||
let mut reviews = Vec::new();
|
||||
while let Some(row) = rows.next().map_err(database_error)? {
|
||||
let review = stored_review(row, &root)?;
|
||||
let id = review.storage_id.unwrap();
|
||||
let label = review
|
||||
.summary
|
||||
.lines()
|
||||
.find(|line| !line.trim().is_empty())
|
||||
.map_or_else(|| format!("Review {id}"), |line| line.trim().to_owned());
|
||||
choices.push((id, label));
|
||||
reviews.push(stored_review(row, &root)?);
|
||||
}
|
||||
Ok(choices)
|
||||
Ok(reviews)
|
||||
}
|
||||
|
||||
pub fn load(&self, root: &Path, id: i64) -> Result<Review, String> {
|
||||
|
||||
Reference in New Issue
Block a user