Skip to content

Commit d85d224

Browse files
committed
Migrate concern handler to new EditIssueBody database handling
1 parent b86b5e7 commit d85d224

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/handlers/concern.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ use parser::command::concern::ConcernCommand;
1313

1414
const CONCERN_ISSUE_KEY: &str = "CONCERN-ISSUE";
1515

16-
#[derive(Debug, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
16+
#[derive(Debug, PartialEq, Eq, Default, Clone, serde::Serialize, serde::Deserialize)]
1717
struct ConcernData {
1818
concerns: Vec<Concern>,
1919
}
2020

21-
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
21+
#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, serde::Deserialize)]
2222
struct Concern {
2323
title: String,
2424
author: String,
2525
comment_url: String,
2626
status: ConcernStatus,
2727
}
2828

29-
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
29+
#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, serde::Deserialize)]
3030
enum ConcernStatus {
3131
Active,
3232
Resolved { comment_url: String },
@@ -84,8 +84,10 @@ pub(super) async fn handle_command(
8484
return Ok(());
8585
}
8686

87-
let edit = EditIssueBody::new(&issue, CONCERN_ISSUE_KEY);
88-
let mut concern_data: ConcernData = edit.current_data().unwrap_or_default();
87+
let mut client = ctx.db.get().await;
88+
let mut edit: EditIssueBody<'_, ConcernData> =
89+
EditIssueBody::load(&mut client, &issue, CONCERN_ISSUE_KEY).await?;
90+
let concern_data = edit.data_mut();
8991

9092
// Process the command by either adding a new comment or "deactivating" the old one
9193
match cmd {
@@ -142,7 +144,7 @@ pub(super) async fn handle_command(
142144
}
143145

144146
// Apply the new markdown concerns list to the issue
145-
edit.apply(&ctx.github, new_content, concern_data)
147+
edit.apply(&ctx.github, new_content)
146148
.await
147149
.context("failed to apply the new concerns section markdown")?;
148150

0 commit comments

Comments
 (0)