summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-07-25 22:46:13 -0600
committerDouwe Maan <douwe@selenight.nl>2016-07-25 22:46:13 -0600
commitd76d051b226893a20060c51128e1eb5bfd86fd3f (patch)
tree9993407302f8f1a327caf1d83cbe8946943febe0
parenteeb41c759e246bf96bda8d8f02478860cc6448bb (diff)
downloadgitlab-ce-d76d051b226893a20060c51128e1eb5bfd86fd3f.tar.gz
Collapse/hide resolved discussions
-rw-r--r--app/models/discussion.rb14
-rw-r--r--app/models/note.rb6
2 files changed, 17 insertions, 3 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index cc586933112..50fa814b311 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -87,8 +87,20 @@ class Discussion
self.noteable == target && !diff_discussion?
end
+ def collapsed?
+ return false unless diff_discussion?
+
+ if resolvable?
+ # New diff discussions only disappear once they are marked resolved
+ resolved?
+ else
+ # Old diff discussions disappear once they become outdated
+ !active?
+ end
+ end
+
def expanded?
- !diff_discussion? || active?
+ !collapsed?
end
def reply_attributes
diff --git a/app/models/note.rb b/app/models/note.rb
index 2aff2b40a48..7668f3378e9 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -86,8 +86,10 @@ class Note < ActiveRecord::Base
end
def grouped_diff_discussions
- notes = diff_notes.fresh.select(&:active?)
- Discussion.for_diff_notes(notes).map { |d| [d.line_code, d] }.to_h
+ active_notes = diff_notes.fresh.select(&:active?)
+ Discussion.for_diff_notes(active_notes).
+ reject(&:resolved?).
+ map { |d| [d.line_code, d] }.to_h
end
# Searches for notes matching the given query.