diff options
author | Phil Hughes <me@iamphill.com> | 2016-07-29 11:19:56 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-07-29 11:19:56 +0100 |
commit | efb74875cfe1a1e2b3696f0129b819fc8e204876 (patch) | |
tree | 53bc2e8a9e45f6c31dcc729bf4646532c1e6b41a /app/assets/javascripts/diff_notes/services | |
parent | d9a949c17c29c8531b2b0a1c227ab0b3341f0ba3 (diff) | |
download | gitlab-ce-efb74875cfe1a1e2b3696f0129b819fc8e204876.tar.gz |
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/services')
-rw-r--r-- | app/assets/javascripts/diff_notes/services/resolve.js.es6 | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/app/assets/javascripts/diff_notes/services/resolve.js.es6 b/app/assets/javascripts/diff_notes/services/resolve.js.es6 index 50392e76fbe..0be938448b2 100644 --- a/app/assets/javascripts/diff_notes/services/resolve.js.es6 +++ b/app/assets/javascripts/diff_notes/services/resolve.js.es6 @@ -24,17 +24,7 @@ } toggleResolveForDiscussion(namespace, mergeRequestId, discussionId) { - const noteIds = CommentsStore.notesForDiscussion(discussionId); - let isResolved = true; - - for (let i = 0; i < noteIds.length; i++) { - const noteId = noteIds[i]; - const resolved = CommentsStore.state[discussionId][noteId].resolved; - - if (!resolved) { - isResolved = false; - } - } + const isResolved = CommentsStore.state[discussionId].isResolved(); if (isResolved) { return this.unResolveAll(namespace, mergeRequestId, discussionId); @@ -55,9 +45,11 @@ }, {}).then((response) => { const data = response.data; const user = data ? data.resolved_by : null; + const discussion = CommentsStore.state[discussionId]; + discussion.resolveAllNotes(user); + CommentsStore.loading[discussionId] = false; - CommentsStore.updateCommentsForDiscussion(discussionId, true, user); this.updateUpdatedHtml(discussionId, data); }); @@ -74,9 +66,10 @@ discussionId }, {}).then((response) => { const data = response.data; - CommentsStore.loading[discussionId] = false; + const discussion = CommentsStore.state[discussionId]; + discussion.unResolveAllNotes(); - CommentsStore.updateCommentsForDiscussion(discussionId, false); + CommentsStore.loading[discussionId] = false; this.updateUpdatedHtml(discussionId, data); }); |