Commit 74f6b50a authored by Stan Hu's avatar Stan Hu

Update discussions after note is saved

This still updates both notes in the same transaction.
parent 5a160b7f
...@@ -29,8 +29,9 @@ module Notes ...@@ -29,8 +29,9 @@ module Notes
note_saved = note.with_transaction_returning_status do note_saved = note.with_transaction_returning_status do
break false if only_commands break false if only_commands
before_save(note) note.save.tap do
note.save update_discussions(note)
end
end end
when_saved(note) if note_saved when_saved(note) if note_saved
...@@ -57,7 +58,7 @@ module Notes ...@@ -57,7 +58,7 @@ module Notes
@quick_actions_service ||= QuickActionsService.new(project, current_user) @quick_actions_service ||= QuickActionsService.new(project, current_user)
end end
def before_save(note) def update_discussions(note)
# Ensure that individual notes that are promoted into discussions are # Ensure that individual notes that are promoted into discussions are
# updated in a transaction with the note creation to avoid inconsistencies: # updated in a transaction with the note creation to avoid inconsistencies:
# https://gitlab.com/gitlab-org/gitlab/-/issues/301237 # https://gitlab.com/gitlab-org/gitlab/-/issues/301237
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment