Commit d2b89ea7 authored by Ruben Davila's avatar Ruben Davila

Add commands_executed flag to Note objects.

This flag will be used to properly update the sidebar after the slash
commands have been processed.
parent 220663f2
...@@ -162,7 +162,8 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -162,7 +162,8 @@ class Projects::NotesController < Projects::ApplicationController
discussion_id: note.discussion_id, discussion_id: note.discussion_id,
html: note_html(note), html: note_html(note),
award: false, award: false,
note: note.note note: note.note,
commands_executed: note.commands_executed
} }
if note.diff_note? if note.diff_note?
...@@ -194,6 +195,7 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -194,6 +195,7 @@ class Projects::NotesController < Projects::ApplicationController
{ {
valid: false, valid: false,
award: false, award: false,
commands_executed: note.commands_executed,
errors: note.errors errors: note.errors
} }
end end
......
...@@ -19,6 +19,9 @@ class Note < ActiveRecord::Base ...@@ -19,6 +19,9 @@ class Note < ActiveRecord::Base
# Banzai::ObjectRenderer # Banzai::ObjectRenderer
attr_accessor :user_visible_reference_count attr_accessor :user_visible_reference_count
# Flag used to indicate that a Note contains slash commands and they have been executed.
attr_accessor :commands_executed
default_value_for :system, false default_value_for :system, false
attr_mentionable :note, pipeline: :note attr_mentionable :note, pipeline: :note
......
...@@ -32,7 +32,7 @@ module Notes ...@@ -32,7 +32,7 @@ module Notes
todo_service.new_note(note, current_user) todo_service.new_note(note, current_user)
end end
if command_params && command_params.any? if command_params.present?
slash_commands_service.execute(command_params, note) slash_commands_service.execute(command_params, note)
# We must add the error after we call #save because errors are reset # We must add the error after we call #save because errors are reset
...@@ -40,6 +40,8 @@ module Notes ...@@ -40,6 +40,8 @@ module Notes
if only_commands if only_commands
note.errors.add(:commands_only, 'Your commands have been executed!') note.errors.add(:commands_only, 'Your commands have been executed!')
end end
note.commands_executed = true
end end
note note
......
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