Commit d76d051b authored by Douwe Maan's avatar Douwe Maan

Collapse/hide resolved discussions

parent eeb41c75
...@@ -87,8 +87,20 @@ class Discussion ...@@ -87,8 +87,20 @@ class Discussion
self.noteable == target && !diff_discussion? self.noteable == target && !diff_discussion?
end 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? def expanded?
!diff_discussion? || active? !collapsed?
end end
def reply_attributes def reply_attributes
......
...@@ -86,8 +86,10 @@ class Note < ActiveRecord::Base ...@@ -86,8 +86,10 @@ class Note < ActiveRecord::Base
end end
def grouped_diff_discussions def grouped_diff_discussions
notes = diff_notes.fresh.select(&:active?) active_notes = diff_notes.fresh.select(&:active?)
Discussion.for_diff_notes(notes).map { |d| [d.line_code, d] }.to_h Discussion.for_diff_notes(active_notes).
reject(&:resolved?).
map { |d| [d.line_code, d] }.to_h
end end
# Searches for notes matching the given query. # Searches for notes matching the given query.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment