Merge branch 'issue_13300' into 'master'
Increase the notes polling timeout over time Originally by @roperzh at https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2821 Fixes #13300 See merge request !3071
This commit is contained in:
commit
f8c4dc9723
|
@ -11,6 +11,7 @@ v 8.6.0 (unreleased)
|
|||
- Update documentation to reflect Guest role not being enforced on internal projects
|
||||
- Allow search for logged out users
|
||||
- Don't show Issues/MRs from archived projects in Groups view
|
||||
- Increase the notes polling timeout over time (Roberto Dip)
|
||||
|
||||
v 8.5.3
|
||||
- Flush repository caches before renaming projects
|
||||
|
|
|
@ -16,10 +16,12 @@ class @Notes
|
|||
@view = view
|
||||
@noteable_url = document.URL
|
||||
@notesCountBadge ||= $(".issuable-details").find(".notes-tab .badge")
|
||||
@basePollingInterval = 15000
|
||||
@maxPollingSteps = 4
|
||||
|
||||
@cleanBinding()
|
||||
@addBinding()
|
||||
@initRefresh()
|
||||
@setPollingInterval()
|
||||
@setupMainTargetNoteForm()
|
||||
@initTaskList()
|
||||
|
||||
|
@ -91,9 +93,11 @@ class @Notes
|
|||
clearInterval(Notes.interval)
|
||||
Notes.interval = setInterval =>
|
||||
@refresh()
|
||||
, 15000
|
||||
, @pollingInterval
|
||||
|
||||
refresh: ->
|
||||
return if @refreshing is true
|
||||
refreshing = true
|
||||
if not document.hidden and document.URL.indexOf(@noteable_url) is 0
|
||||
@getContent()
|
||||
|
||||
|
@ -105,12 +109,31 @@ class @Notes
|
|||
success: (data) =>
|
||||
notes = data.notes
|
||||
@last_fetched_at = data.last_fetched_at
|
||||
@setPollingInterval(data.notes.length)
|
||||
$.each notes, (i, note) =>
|
||||
if note.discussion_with_diff_html?
|
||||
@renderDiscussionNote(note)
|
||||
else
|
||||
@renderNote(note)
|
||||
always: =>
|
||||
@refreshing = false
|
||||
|
||||
###
|
||||
Increase @pollingInterval up to 120 seconds on every function call,
|
||||
if `shouldReset` has a truthy value, 'null' or 'undefined' the variable
|
||||
will reset to @basePollingInterval.
|
||||
|
||||
Note: this function is used to gradually increase the polling interval
|
||||
if there aren't new notes coming from the server
|
||||
###
|
||||
setPollingInterval: (shouldReset = true) ->
|
||||
nthInterval = @basePollingInterval * Math.pow(2, @maxPollingSteps - 1)
|
||||
if shouldReset
|
||||
@pollingInterval = @basePollingInterval
|
||||
else if @pollingInterval < nthInterval
|
||||
@pollingInterval *= 2
|
||||
|
||||
@initRefresh()
|
||||
|
||||
###
|
||||
Render note in main comments area.
|
||||
|
|
Loading…
Reference in New Issue