Commit 16970d07 authored by Phil Hughes's avatar Phil Hughes

Returns created todos to control rather than re-query

parent 8abd7b35
class Projects::TodosController < Projects::ApplicationController
def create
TodoService.new.mark_todo(issuable, current_user)
todos = TodoService.new.mark_todo(issuable, current_user)
render json: {
todo: current_user.todos.find_by(state: :pending, action: Todo::MARKED, target_id: issuable.id),
todo: todos,
count: current_user.todos.pending.count,
}
end
......
......@@ -148,7 +148,7 @@ class TodoService
private
def create_todos(users, attributes)
Array(users).each do |user|
Array(users).map do |user|
next if pending_todos(user, attributes).exists?
Todo.create(attributes.merge(user_id: user.id))
end
......
......@@ -27,7 +27,7 @@
%li
= link_to dashboard_todos_path, title: 'Todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('bell fw')
%span.badge.todos-pending-count{ class: ("hidden" if todos_pending_count == 0)}
%span.badge.todos-pending-count{ class: ("hidden" if todos_pending_count == 0) }
= todos_pending_count
- if current_user.can_create_project?
%li
......
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