Commit d76d051b authored by Douwe Maan's avatar Douwe Maan

Collapse/hide resolved discussions

parent eeb41c75
......@@ -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
......
......@@ -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.
......
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