diff options
author | Phil Hughes <me@iamphill.com> | 2016-07-29 13:19:56 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-07-29 13:19:56 +0300 |
commit | efb74875cfe1a1e2b3696f0129b819fc8e204876 (patch) | |
tree | 53bc2e8a9e45f6c31dcc729bf4646532c1e6b41a /app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 | |
parent | d9a949c17c29c8531b2b0a1c227ab0b3341f0ba3 (diff) |
Moved most of the data handling into discussion & notes models
Reduced some duplicated code with compiling components
Fixed bug with resolve button tooltip not updating after resolving discussion
Diffstat (limited to 'app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6')
-rw-r--r-- | app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 b/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 index a0c859ab7f6..3c30f9df058 100644 --- a/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 +++ b/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 @@ -10,40 +10,31 @@ }, computed: { allResolved: function () { - let allResolved = true; - for (const discussionId in this.discussions) { - const discussion = this.discussions[discussionId]; - - for (const noteId in discussion) { - const note = discussion[noteId]; - - if (!note.resolved) { - allResolved = false; - } - } - } - - return allResolved; + const discussion = this.discussions[discussionId]; + return discussion.isResolved(); } }, methods: { jumpToNextUnresolvedDiscussion: function () { - let nextUnresolvedDiscussionId; + let nextUnresolvedDiscussionId, + firstUnresolvedDiscussionId; if (!this.discussionId) { + let i = 0; for (const discussionId in this.discussions) { const discussion = this.discussions[discussionId]; + const isResolved = discussion.isResolved(); - for (const noteId in discussion) { - const note = discussion[noteId]; + if (!firstUnresolvedDiscussionId && !isResolved) { + firstUnresolvedDiscussionId = discussionId; + } - if (!note.resolved) { - nextUnresolvedDiscussionId = discussionId; - break; - } + if (!isResolved) { + nextUnresolvedDiscussionId = discussionId; + break; } - if (nextUnresolvedDiscussionId) break; + i++; } } else { const discussionKeys = Object.keys(this.discussions), @@ -52,9 +43,16 @@ if (nextDiscussionId) { nextUnresolvedDiscussionId = nextDiscussionId; + } else { + firstUnresolvedDiscussionId = discussionKeys[0]; } } + if (firstUnresolvedDiscussionId) { + // Jump to first unresolved discussion + nextUnresolvedDiscussionId = firstUnresolvedDiscussionId; + } + if (nextUnresolvedDiscussionId) { $.scrollTo(`.discussion[data-discussion-id="${nextUnresolvedDiscussionId}"]`, { offset: -($('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight()) |