Commit dc55127c1dce5f3563a090f65f20b689749f5297

Authored by Dmitriy Zaporozhets
2 parents c7dc20c1 c8cf90d2

Merge branch 'refresh_unless_hidden' into 'master'

Refresh Notes unless the tab is hidden
CHANGELOG
... ... @@ -7,6 +7,7 @@ v 6.9.0
7 7 - Add ability to set different ssh host, if different from http/https
8 8 - Fix syntax highlighting for code comments blocks
9 9 - Improve comments loading logic
  10 + - Stop refreshing comments when the tab is hidden
10 11  
11 12 v 6.8.0
12 13 - Ability to at mention users that are participating in issue and merge req. discussion
... ...
app/assets/javascripts/notes.js.coffee
... ... @@ -50,6 +50,9 @@ class Notes
50 50 # hide diff note form
51 51 $(document).on "click", ".js-close-discussion-note-form", @cancelDiscussionForm
52 52  
  53 + # fetch notes when tab becomes visible
  54 + $(document).on "visibilitychange", @visibilityChange
  55 +
53 56 cleanBinding: ->
54 57 $(document).off "ajax:success", ".js-main-target-form"
55 58 $(document).off "ajax:success", ".js-discussion-note-form"
... ... @@ -63,6 +66,7 @@ class Notes
63 66 $(document).off "click", ".js-choose-note-attachment-button"
64 67 $(document).off "click", ".js-discussion-reply-button"
65 68 $(document).off "click", ".js-add-diff-note-button"
  69 + $(document).off "visibilitychange"
66 70  
67 71  
68 72 initRefresh: ->
... ... @@ -72,7 +76,7 @@ class Notes
72 76 , 15000
73 77  
74 78 refresh: ->
75   - @getContent()
  79 + @getContent() unless document.hidden
76 80  
77 81 getContent: ->
78 82 $.ajax
... ... @@ -453,4 +457,10 @@ class Notes
453 457 filename = $(this).val().replace(/^.*[\\\/]/, "")
454 458 form.find(".js-attachment-filename").text filename
455 459  
  460 + ###
  461 + Called when the tab visibility changes
  462 + ###
  463 + visibilityChange: =>
  464 + @refresh()
  465 +
456 466 @Notes = Notes
... ...