Commit 0b914e7ceb28c67a50d19c7fac10a95b3ea4a1fa
1 parent
e52f50c2
Exists in
spb-stable
and in
2 other branches
Refresh notes when the page becomes visible
Showing
1 changed file
with
10 additions
and
0 deletions
Show diff stats
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: -> |
... | ... | @@ -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 | ... | ... |