summaryrefslogtreecommitdiff
path: root/app/models/legacy_diff_discussion.rb
blob: 7d78c580fa22c4a1601a38e0e07ba6c6656690df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true

# A discussion on merge request or commit diffs consisting of `LegacyDiffNote` notes.
#
# All new diff discussions are of the type `DiffDiscussion`, but any diff discussions created
# before the introduction of the new implementation still use `LegacyDiffDiscussion`.
#
# A discussion of this type is never resolvable.
class LegacyDiffDiscussion < Discussion
  include DiscussionOnDiff

  memoized_values << :active

  def self.note_class
    LegacyDiffNote
  end

  def legacy_diff_discussion?
    true
  end

  def on_image?
    false
  end

  def on_text?
    true
  end

  def active?(*args)
    return @active if @active.present?

    @active = first_note.active?(*args)
  end

  def collapsed?
    !active?
  end

  def merge_request_version_params
    return unless for_merge_request?

    if active?
      {}
    else
      nil
    end
  end

  def reply_attributes
    super.merge(line_code: line_code)
  end
end