Skip to content

Commit b86b5e7

Browse files
committed
Migrate note handler to new EditIssueBody database handling
1 parent 44f7f11 commit b86b5e7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/handlers/note.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl PartialOrd for NoteDataEntry {
6969
}
7070
}
7171

72-
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Default)]
72+
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Default, Clone)]
7373
struct NoteData {
7474
entries_by_url: HashMap<String, NoteDataEntry>,
7575
}
@@ -122,9 +122,11 @@ pub(super) async fn handle_command(
122122
cmd: NoteCommand,
123123
) -> anyhow::Result<()> {
124124
let issue = event.issue().unwrap();
125-
let e = EditIssueBody::new(&issue, "SUMMARY");
126125

127-
let mut current: NoteData = e.current_data().unwrap_or_default();
126+
let mut client = ctx.db.get().await;
127+
let mut e: EditIssueBody<'_, NoteData> =
128+
EditIssueBody::load(&mut client, &issue, "SUMMARY").await?;
129+
let current = e.data_mut();
128130

129131
let comment_url = String::from(event.html_url().unwrap());
130132
let author = event.user().login.to_owned();
@@ -158,7 +160,7 @@ pub(super) async fn handle_command(
158160
let new_markdown = current.to_markdown(&ctx.username);
159161
log::debug!("New MD: {:#?}", new_markdown);
160162

161-
e.apply(&ctx.github, new_markdown, current).await?;
163+
e.apply(&ctx.github, new_markdown).await?;
162164

163165
Ok(())
164166
}

0 commit comments

Comments
 (0)