diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-08 14:58:08 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-08 14:58:08 -0500 |
commit | 1817f877e19628417dd8209f070386b111de59c4 (patch) | |
tree | 597679f8c2e1051f7c6317bb33dc797776c8a3d7 /app/models | |
parent | a8339fe1aa95d489e00cb0b79a20557d711639ec (diff) | |
download | gitlab-ce-1817f877e19628417dd8209f070386b111de59c4.tar.gz |
Some code tweaks
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/discussion_on_diff.rb | 8 | ||||
-rw-r--r-- | app/models/concerns/note_on_diff.rb | 4 | ||||
-rw-r--r-- | app/models/legacy_diff_discussion.rb | 8 |
3 files changed, 12 insertions, 8 deletions
diff --git a/app/models/concerns/discussion_on_diff.rb b/app/models/concerns/discussion_on_diff.rb index 87db0c810c3..67b1cace3eb 100644 --- a/app/models/concerns/discussion_on_diff.rb +++ b/app/models/concerns/discussion_on_diff.rb @@ -5,8 +5,6 @@ module DiscussionOnDiff included do NUMBER_OF_TRUNCATED_DIFF_LINES = 16 - memoized_values << :active - delegate :line_code, :original_line_code, :diff_file, @@ -29,12 +27,6 @@ module DiscussionOnDiff true end - def active? - return @active if @active.present? - - @active = first_note.active? - end - # Returns an array of at most 16 highlighted lines above a diff note def truncated_diff_lines(highlight: true) lines = highlight ? highlighted_diff_lines : diff_lines diff --git a/app/models/concerns/note_on_diff.rb b/app/models/concerns/note_on_diff.rb index ac4c3099c00..6c27dd5aa5c 100644 --- a/app/models/concerns/note_on_diff.rb +++ b/app/models/concerns/note_on_diff.rb @@ -26,6 +26,10 @@ module NoteOnDiff raise NotImplementedError end + def active?(diff_refs = nil) + raise NotImplementedError + end + private def noteable_diff_refs diff --git a/app/models/legacy_diff_discussion.rb b/app/models/legacy_diff_discussion.rb index cb2651a03f8..e617ce36f56 100644 --- a/app/models/legacy_diff_discussion.rb +++ b/app/models/legacy_diff_discussion.rb @@ -7,6 +7,8 @@ class LegacyDiffDiscussion < Discussion include DiscussionOnDiff + memoized_values << :active + def legacy_diff_discussion? true end @@ -15,6 +17,12 @@ class LegacyDiffDiscussion < Discussion LegacyDiffNote end + def active?(*args) + return @active if @active.present? + + @active = first_note.active?(*args) + end + def collapsed? !active? end |