diff options
author | Phil Hughes <me@iamphill.com> | 2017-08-08 16:25:00 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-08-15 18:09:36 +0300 |
commit | 554afea059446384783f3c68c09ac56afa0e7d49 (patch) | |
tree | 950495ef2a046ccf514dfeab8cacb38b7e817497 /app | |
parent | 0ec87b3bf0ac27af5f5fedf97d51c8b14b050f50 (diff) |
Fix race condition with dispatcher.js
The dispatcher was trying to create a new instance of a class that is loaded in a file after main.js which would cause the filtered search to not work on issues. This would only happen on the first load when the JS is not cached. If the JS is cached, then everything will be fine.
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diff_notes/diff_notes_bundle.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/main.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/render_gfm.js | 4 | ||||
-rw-r--r-- | app/helpers/version_check_helper.rb | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/_discussion.html.haml | 6 |
6 files changed, 12 insertions, 10 deletions
diff --git a/app/assets/javascripts/diff_notes/diff_notes_bundle.js b/app/assets/javascripts/diff_notes/diff_notes_bundle.js index a2d33b0936e..5decfc1dc01 100644 --- a/app/assets/javascripts/diff_notes/diff_notes_bundle.js +++ b/app/assets/javascripts/diff_notes/diff_notes_bundle.js @@ -42,6 +42,10 @@ $(() => { $components.each(function () { const $this = $(this); const noteId = $this.attr(':note-id'); + const discussionId = $this.attr(':discussion-id'); + + if ($this.is('comment-and-resolve-btn') && !discussionId) return; + const tmp = Vue.extend({ template: $this.get(0).outerHTML }); diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 265e304b957..4183916722f 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -637,7 +637,7 @@ import UserFeatureHelper from './helpers/user_feature_helper'; return Dispatcher; })(); - $(function() { + $(window).on('load', function() { new Dispatcher(); }); }).call(window); diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 42092a34c2f..35dd2add35a 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -135,8 +135,9 @@ import './project_select'; import './project_show'; import './project_variables'; import './projects_list'; -import './render_gfm'; +import './syntax_highlight'; import './render_math'; +import './render_gfm'; import './right_sidebar'; import './search'; import './search_autocomplete'; @@ -144,7 +145,6 @@ import './smart_interval'; import './star'; import './subscription'; import './subscription_select'; -import './syntax_highlight'; import './dispatcher'; diff --git a/app/assets/javascripts/render_gfm.js b/app/assets/javascripts/render_gfm.js index 2c3a9cacd38..bcdc0fd67b8 100644 --- a/app/assets/javascripts/render_gfm.js +++ b/app/assets/javascripts/render_gfm.js @@ -11,7 +11,5 @@ return this; }; - $(document).on('ready load', function() { - return $('body').renderGFM(); - }); + $(() => $('body').renderGFM()); }).call(window); diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb index 3b175251446..456598b4c28 100644 --- a/app/helpers/version_check_helper.rb +++ b/app/helpers/version_check_helper.rb @@ -2,7 +2,7 @@ module VersionCheckHelper def version_status_badge if Rails.env.production? && current_application_settings.version_check_enabled image_url = VersionCheck.new.url - image_tag image_url, class: 'js-version-status-badge', lazy: false + image_tag image_url, class: 'js-version-status-badge' end end end diff --git a/app/views/projects/merge_requests/_discussion.html.haml b/app/views/projects/merge_requests/_discussion.html.haml index b787edb3427..3303aa72604 100644 --- a/app/views/projects/merge_requests/_discussion.html.haml +++ b/app/views/projects/merge_requests/_discussion.html.haml @@ -4,8 +4,8 @@ = link_to 'Close merge request', merge_request_path(@merge_request, merge_request: { state_event: :close }), method: :put, class: "btn btn-nr btn-comment btn-close close-mr-link js-note-target-close", title: "Close merge request", data: { original_text: "Close merge request", alternative_text: "Comment & close merge request"} - if @merge_request.reopenable? = link_to 'Reopen merge request', merge_request_path(@merge_request, merge_request: { state_event: :reopen }), method: :put, class: "btn btn-nr btn-comment btn-reopen reopen-mr-link js-note-target-close js-note-target-reopen", title: "Reopen merge request", data: { original_text: "Reopen merge request", alternative_text: "Comment & reopen merge request"} - %comment-and-resolve-btn{ "inline-template" => true, ":discussion-id" => "" } - %button.btn.btn-nr.btn-default.append-right-10.js-comment-resolve-button{ "v-if" => "showButton", type: "submit", data: { project_path: "#{project_path(@merge_request.project)}" } } - {{ buttonText }} + %comment-and-resolve-btn{ "inline-template" => true } + %button.btn.btn-nr.btn-default.append-right-10.js-comment-resolve-button{ "v-if" => "showButton", type: "submit", data: { project_path: "#{project_path(@merge_request.project)}" } } + {{ buttonText }} #notes= render "shared/notes/notes_with_form", :autocomplete => true |