Commit 7ec5ff4d authored by Jacob Vosmaer's avatar Jacob Vosmaer

Pass last_fetched_at for notes to javascript

parent bbfa4a77
class Notes class Notes
@interval: null @interval: null
constructor: (notes_url, note_ids) -> constructor: (notes_url, note_ids, last_fetched_at) ->
@notes_url = notes_url @notes_url = notes_url
@notes_url = gon.relative_url_root + @notes_url if gon.relative_url_root? @notes_url = gon.relative_url_root + @notes_url if gon.relative_url_root?
@note_ids = note_ids @note_ids = note_ids
@last_fetched_at = last_fetched_at
@initRefresh() @initRefresh()
@setupMainTargetNoteForm() @setupMainTargetNoteForm()
@cleanBinding() @cleanBinding()
...@@ -76,9 +77,11 @@ class Notes ...@@ -76,9 +77,11 @@ class Notes
getContent: -> getContent: ->
$.ajax $.ajax
url: @notes_url url: @notes_url
data: "last_fetched_at=" + @last_fetched_at
dataType: "json" dataType: "json"
success: (data) => success: (data) =>
notes = data.notes notes = data.notes
@last_fetched_at = data.last_fetched_at
$.each notes, (i, note) => $.each notes, (i, note) =>
@renderNote(note) @renderNote(note)
......
...@@ -5,9 +5,10 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -5,9 +5,10 @@ class Projects::NotesController < Projects::ApplicationController
before_filter :authorize_admin_note!, only: [:update, :destroy] before_filter :authorize_admin_note!, only: [:update, :destroy]
def index def index
current_fetched_at = Time.now
@notes = NotesFinder.new.execute(project, current_user, params) @notes = NotesFinder.new.execute(project, current_user, params)
notes_json = { notes: [] } notes_json = { notes: [], last_fetched_at: current_fetched_at }
@notes.each do |note| @notes.each do |note|
notes_json[:notes] << { notes_json[:notes] << {
......
...@@ -7,4 +7,4 @@ ...@@ -7,4 +7,4 @@
= render "projects/notes/form" = render "projects/notes/form"
:javascript :javascript
new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}) new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, Time.now)
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