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
discussion_id: note.discussion_id,
html: note_html(note),
award: false,
note: note.note
note: note.note,
commands_executed: note.commands_executed
}
if note.diff_note?
......@@ -194,6 +195,7 @@ class Projects::NotesController < Projects::ApplicationController
{
valid: false,
award: false,
commands_executed: note.commands_executed,
errors: note.errors
}
end
......
......@@ -19,6 +19,9 @@ class Note < ActiveRecord::Base
# Banzai::ObjectRenderer
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
attr_mentionable :note, pipeline: :note
......
......@@ -32,7 +32,7 @@ module Notes
todo_service.new_note(note, current_user)
end
if command_params && command_params.any?
if command_params.present?
slash_commands_service.execute(command_params, note)
# We must add the error after we call #save because errors are reset
......@@ -40,6 +40,8 @@ module Notes
if only_commands
note.errors.add(:commands_only, 'Your commands have been executed!')
end
note.commands_executed = true
end
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