Skip to content

Commit c6a59f2

Browse files
committed
Avoid re-adding a concern when editing an issue
1 parent 4032d04 commit c6a59f2

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/handlers/concern.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,23 @@ pub(super) async fn handle_command(
8787
let edit = EditIssueBody::new(&issue, CONCERN_ISSUE_KEY);
8888
let mut concern_data: ConcernData = edit.current_data().unwrap_or_default();
8989

90-
// Process the command by either adding a new comment or "deactivating" the old one
90+
// Process the command by either adding a new concern or resolving the old one
9191
match cmd {
92-
ConcernCommand::Concern { title } => concern_data.concerns.push(Concern {
93-
title,
94-
author,
95-
status: ConcernStatus::Active,
96-
comment_url: comment_url.to_string(),
97-
}),
92+
ConcernCommand::Concern { title } => {
93+
// Only add a concern if it wasn't already added, we could be in an edit
94+
if !concern_data
95+
.concerns
96+
.iter()
97+
.any(|c| c.title == title && c.comment_url == comment_url)
98+
{
99+
concern_data.concerns.push(Concern {
100+
title,
101+
author,
102+
status: ConcernStatus::Active,
103+
comment_url: comment_url.to_string(),
104+
});
105+
}
106+
}
98107
ConcernCommand::Resolve { title } => concern_data
99108
.concerns
100109
.iter_mut()

0 commit comments

Comments
 (0)