httpd: Allow removing of reactions from issues

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez 2023-08-14 16:40:33 +02:00
parent 15b50ce6a5
commit 6abbd39926
No known key found for this signature in database
3 changed files with 17 additions and 7 deletions

View File

@ -323,7 +323,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
let (comment_id, _) = term::io::comment_select(&issue).unwrap();
*comment_id
});
issue.react(comment_id, reaction, &signer)?;
issue.react(comment_id, reaction, true, &signer)?;
}
}
Operation::Open {

View File

@ -553,8 +553,12 @@ async fn issue_update_handler(
return Err(Error::BadRequest("`replyTo` missing".to_owned()));
}
}
issue::Action::CommentReact { id, reaction, .. } => {
issue.react(id, reaction, &signer)?;
issue::Action::CommentReact {
id,
reaction,
active,
} => {
issue.react(id, reaction, active, &signer)?;
}
issue::Action::CommentEdit { .. } => {
todo!();

View File

@ -291,11 +291,16 @@ impl store::Transaction<Issue> {
}
/// React to an issue comment.
pub fn react(&mut self, id: CommentId, reaction: Reaction) -> Result<(), store::Error> {
pub fn react(
&mut self,
id: CommentId,
reaction: Reaction,
active: bool,
) -> Result<(), store::Error> {
self.push(Action::CommentReact {
id,
reaction,
active: true,
active,
})
}
@ -406,9 +411,10 @@ where
&mut self,
to: CommentId,
reaction: Reaction,
active: bool,
signer: &G,
) -> Result<EntryId, Error> {
self.transaction("React", signer, |tx| tx.react(to, reaction))
self.transaction("React", signer, |tx| tx.react(to, reaction, active))
}
pub fn transaction<G, F>(
@ -875,7 +881,7 @@ mod test {
let (comment, _) = issue.root();
let comment = *comment;
let reaction = Reaction::new('🥳').unwrap();
issue.react(comment, reaction, &node.signer).unwrap();
issue.react(comment, reaction, true, &node.signer).unwrap();
let id = issue.id;
let issue = issues.get(&id).unwrap().unwrap();